SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Six habits, kept for 153 packages

A collection is worth taking as a set only if the next package behaves like the last one. These 153 were written one at a time, over a couple of years, and what makes them a collection is not a shared build or a shared release — it is six habits that recur in every one of them.

1. Failure is a value

Nothing throws past you; every failure is a Result.

2. The platform is the baseline

The runtime first, a dependency only when it falls short.

3. Implement the spec

Where a standard exists, the package follows it.

4. One contract, adapters

The vendor sits behind a driver you can swap, or fake.

5. Own the core

Write what is load-bearing, depend only at the rim.

6. Framework-free core

The Remix binding is an export you opt into.

153packages that share the habits
56need nothing from outside the set
55depend on no framework
98add an optional Remix binding

1. Failure is a value

Every fallible entry point answers with a Result. Parsing a document, reading a cache, verifying a signature, sending a message — none of them throw past you, and each failure carries where it happened, which for a parser means the line and column in the source you handed it.

The cost is real and it is paid at every call site: you check before you use. What it buys is that the type signature stops lying. A function that says it returns a document returns a document, and the ones that might not say so in the type rather than in a paragraph of prose nobody reads.

app/posts/parse.ts
import { Markdown } from "@sdxc/markdown";
import { isFailure } from "@sdxc/result";

let parsed = Markdown.parse(source);
if (isFailure(parsed)) {
	let at = parsed.error.position?.start;
	ctx.log.fail(parsed.error, {
		line: at?.line,
		column: at?.column,
	});
	return renderError(parsed.error.message);
}

let { document } = parsed.data;

2. The platform is the baseline

Request, Response, Web Crypto, Intl, <dialog>, the Popover API, Invoker Commands. The starting assumption is that the runtime already has the answer, and a dependency is what you reach for once it demonstrably does not.

  • Dates are formatted through Intl and nothing else

  • The crypto primitives are Web Crypto with a smaller surface over them

  • Caching is the HTTP specification's own semantics, not an invented policy object

Each of those had a well-known library available. Each of them would have shipped a second implementation of something the runtime already does, and a second thing to keep current.

app/posts/byline.ts
import { formatDate, formatRelative } from "@sdxc/dates";

let publishedAt = new Date("2026-07-29T10:00:00Z");
let now = new Date("2026-08-01T10:00:00Z");
let locale = "en-US";
let timeZone = "America/New_York";

formatDate(publishedAt, { locale, timeZone });
// "Jul 29, 2026"

formatRelative(publishedAt, { locale, now });
// "3 days ago"

3. Implement the spec, don't invent one

Where a standard exists, follow it. The knowledge transfers, the data interoperates, and the argument about what the right shape is has already been had by people with more context than a single author has.

  • Webhooks are Standard Webhooks

  • Feature flags are OpenFeature

  • Feeds are Atom and JSON Feed as published

  • Sitemaps are the sitemaps protocol

app/webhooks/invoices.ts
import { isFailure } from "@sdxc/result";
import * as Webhooks from "@sdxc/webhooks";

let delivery = await Webhooks.verify(request, {
	secret: env.WEBHOOK_SECRET,
	schema: InvoiceEvent,
});
if (isFailure(delivery)) {
	return new Response(null, { status: 401 });
}

let { payload } = delivery.data;

4. One contract, adapters at the edge

The shape recurs so often it is the easiest habit to spot: a vendor-neutral core, and the vendor behind a driver you can swap, or fake.

  • Mail has transports, and rate limiting has stores

  • Billing has providers, and jobs have queue adapters

  • Caching has a memory adapter and a Workers KV one

The point is not portability between vendors, which almost nobody actually exercises. It is that a test runs the real code against an in-process adapter, so the thing under test is the thing you deploy.

app/posts/published.ts
import type { Cache } from "@sdxc/cache";

import { isFailure } from "@sdxc/result";

type Load = () => Promise<Post[]>;

export async function publishedPosts(cache: Cache, load: Load) {
	let posts = await cache.fetch("posts:published", load, {
		ttl: "5 minutes",
	});
	return isFailure(posts) ? [] : posts.data;
}
app/initializers/cache.ts
import { WorkerKVCache } from "@sdxc/cache/worker-kv";

let cache = new WorkerKVCache(env.CACHE, {
	waitUntil: ctx.waitUntil.bind(ctx),
});

await publishedPosts(cache, () => Post.published(db));
app/posts/published.test.ts
import { MemoryCache } from "@sdxc/cache/memory";

test("loads the posts once", async () => {
	let cache = new MemoryCache();
	let load = vi.fn(async () => [post]);

	await publishedPosts(cache, load);
	await publishedPosts(cache, load);

	expect(load).toHaveBeenCalledOnce();
});

5. Own the core, depend at the rim

When a dependency would own something load-bearing — the parser your content pipeline is built on, the code that decides what a signature means — write it instead. 56 of the 153 pull in nothing from outside the collection.

  • XML parsing and serialization, and syntax highlighting

  • Frontmatter, YAML and markdown, the last of which parsed this page

The rim is where dependencies belong, and there are some: a JOSE implementation, a DOM, an internationalization runtime. The test is whether replacing it later would be an afternoon or a rewrite.

app/docs/frontmatter.ts
import { isFailure } from "@sdxc/result";
import { parse } from "@sdxc/yaml";

let result = parse(`
title: API Keys
order: 3
tags: [remix, workers]
`);
if (isFailure(result)) return result;

result.data;
// { title: "API Keys", order: 3, tags: ["remix", "workers"] }

6. Framework-free core, Remix where it helps

Most of these packages are about the web platform, not a framework. 55 of the 153 depend on no framework at all and run anywhere fetch does: Cloudflare Workers, where most of them are used, and Bun, Deno and Node as well.

The other 98 bind something to Remix — the middleware, the routing bindings, the context integration — because Remix is what the apps built on them use.

The habit is about where that binding sits: the logic goes in a core that needs no framework, and the binding is an export you opt into. The authentication core is independent of Remix and gets its Remix surface as a subpath, and services reach a request through Remix's own request context rather than a container of this collection's invention.

handler.ts
import { Markdown } from "@sdxc/markdown";
import { toHTML } from "@sdxc/markdown/html";
import { isFailure } from "@sdxc/result";

export async function handle(request: Request) {
	let parsed = Markdown.parse(await request.text());
	if (isFailure(parsed)) {
		return new Response(parsed.error.message, {
			status: 422,
		});
	}

	return new Response(toHTML(parsed.data.document), {
		headers: { "content-type": "text/html; charset=utf-8" },
	});
}
app/controllers/post.tsx
import { Markdown } from "@sdxc/markdown";
import { toRemix } from "@sdxc/markdown/remix";
import { isFailure } from "@sdxc/result";

let parsed = Markdown.parse(post.body);
if (isFailure(parsed)) return renderError(parsed.error);

let body = toRemix(parsed.data.document, { components });
return ctx.render(<article>{body}</article>);
[ Reversals ]

What was tried and undone

The habits above are what survived. Some things did not. A service container was adopted here, and eight workspaces took it up. It was removed three months later, once someone counted what it was actually carrying: one service, almost everywhere, that the framework's own request context already carries — with one mechanism instead of two.

That reversal is recorded rather than quietly dropped, and it is the more useful half of the record. A set of habits is only evidence if it is not a highlight reel, so the decisions that were taken back are written down beside the ones that held.

[ Sponsors ]

People who fund this work

The collection is written and maintained in the open, funded through GitHub Sponsors by the people and teams below.

Read the reasoning, then decide.

Each habit was argued out in a decision the repository still carries, in the open. A habit you can read the reasoning for is one you can decide you disagree with.