# The fence

> For agents: start with the [agent guide](https://ratstack.sh/llms.txt). Every page is Markdown by default; add `Accept: text/html` for HTML.

New on /news: [tla-ts 0.0.9 adds TLC's -continue](/news).

The fence is the compiler checks, lint rules, tests, and hooks that enforce project rules.

“Cheating is uncomfortable” means the repo must stop bad shortcuts. Type-aware Oxlint checks project boundaries and patterns. Effect language-service diagnostics run through TypeScript. Lefthook runs checks before a commit, and harness hooks block `git … --no-verify`.

If an enforced check and a paragraph disagree, follow the enforced rule and fix the paragraph.

The pieces live in `oxlint.config.ts`, `scripts/oxlint-plugin-boundaries.ts`, `scripts/oxlint-plugin-patterns.ts`, `tsconfig.base.json`, `lefthook.yml`, and `scripts/vcs-command-policy.js`. `pnpm turbo run check test build` is the required validation command. Do not weaken a hook to get a green result.

A fence has limits. The lint rules use syntax and known aliases; they do not resolve every dynamic import, package condition, or cross-file re-export. The public Brain note [Oxlint rule limits](/resources/lint-rule-limits) lists those cases.

When lint misses a case, improve the rule or boundary. These rules cannot establish whole-program behavior.

## Where to enforce a correction

Lauren Tan describes five places to put a correction, from more durable to less enforceable: the codebase, static analysis, rules, skills, and style guides. She says to move a correction as high on that ladder as it can go. [Watch from 15:00](https://video.twimg.com/amplify_video/2101938030122868736/vid/avc1/3442x2160/BQlPlAZCEVPDemv1.mp4#t=900) [18:20](https://video.twimg.com/amplify_video/2101938030122868736/vid/avc1/3442x2160/BQlPlAZCEVPDemv1.mp4#t=1100).

Her Dune talk describes an agent-oriented framework where each folder has an owner and process boundaries are visible in the code tree. She sums up the design goal as making the shortcut the right path. [Watch from 19:01](https://video.twimg.com/amplify_video/2101938030122868736/vid/avc1/3442x2160/BQlPlAZCEVPDemv1.mp4#t=1141) [27:45](https://video.twimg.com/amplify_video/2101938030122868736/vid/avc1/3442x2160/BQlPlAZCEVPDemv1.mp4#t=1665).

See [Lauren Tan's talk](/lore/poteto-lauren-tan-2500-prs-dune) for the source and [no comments](/lore/no-comments) for one house rule the fence enforces. See [tests that earn their place](/lore/tests-that-earn-their-place) for the testing law.

## Sources

1. [rat-stack/AGENTS.md at main · joelhooks/rat-stack · GitHub](https://github.com/joelhooks/rat-stack/blob/main/AGENTS.md)
   GitHub joelhooks/rat-stack. Repo law; used for enforcing rules rather than relying on prose. Accessed 2026-10-01.

2. [rat-stack/oxlint.config.ts at main · joelhooks/rat-stack · GitHub](https://github.com/joelhooks/rat-stack/blob/main/oxlint.config.ts)
   GitHub joelhooks/rat-stack. Lint configuration; used for type-aware boundary and pattern checks. Accessed 2026-10-01.

3. [rat-stack/lefthook.yml at main · joelhooks/rat-stack · GitHub](https://github.com/joelhooks/rat-stack/blob/main/lefthook.yml)
   GitHub joelhooks/rat-stack. Commit hooks; used for the validation gate. Accessed 2026-10-01.

4. [rat-stack/.brain/resources/lint-rule-limits.svx at main · joelhooks/rat-stack · GitHub](https://github.com/joelhooks/rat-stack/blob/main/.brain/resources/lint-rule-limits.svx)
   GitHub joelhooks/rat-stack. Rule-limit note; used for the limits of syntax-based enforcement. Accessed 2026-10-01.

## Lore on this page

- [Lauren Tan](/lore/lauren-tan)
- [A clean playground](/lore/a-clean-playground)

## Linked from

- A clean playground → rat-stack does real work with packages that stay easy to add and remove. → [Read page](https://ratstack.sh/lore/a-clean-playground)

- add-a-capability → Learn how one contract and its handler become a command, HTTP route, MCP tool, browser RPC, and sandbox call. → [Read page](https://ratstack.sh/skills/add-a-capability)

- add-a-store → Add persistence through a service named for an application job, with validation, vendor Layers, migrations, bounded reads, and shared backend tests. → [Read page](https://ratstack.sh/skills/add-a-store)

- Agent guide → An Effect stack so pure (aspirational) Kit Langton will blush. → [Read page](https://ratstack.sh/llms.txt)

- Agents explore, tests remember → Let agent users explore scenarios; turn a good bug reproduction into a repeatable test. → [Read page](https://ratstack.sh/lore/agents-explore-tests-remember)

- Build and run rat-stack (README.md) → What is in the repo, how the example works, and how to run it. → [Read page](https://ratstack.sh/README.md)

- CAFE names the Cloudflare, Alchemy, Foldkit and Effect stack → CAFE is a named stack: Cloudflare runs the app, Alchemy declares it, Foldkit draws the UI, and Effect does the typed work. → [Read page](https://ratstack.sh/lore/cafe-stack)

- Change log → What changed in the files served here, newest first. → [Read page](https://ratstack.sh/log)

- Code snippets quote a pinned source → Shipped design brief: pinned Git objects, typed diagnostics, and one build-only snippet model for both views. → [Read page](https://ratstack.sh/lore/code-snippets)

- durability → Keep a rat-stack app standing when a provider, pool, or dependency slows down or a worker dies. Use at any I/O boundary, connection pool, provider call, shared waiter, fan-out, flag, gate, or work that can outlive a request, or when asked "what happens when this is slow", "add a timeout", "make this durable", or "what survives a crash". → [Read page](https://ratstack.sh/skills/durability)

- Durability → Seven durable Effect patterns, each with its seam, its fence, and the incident that taught it. → [Read page](https://ratstack.sh/systems/durability)

- Effect + Alchemy peer patterns → Source-grounded patterns from repos on nearby Effect and Alchemy pins. → [Read page](https://ratstack.sh/resources/same-version-repos)

- Effect 4 study: September 2026 → Dated Effect 4 source studies from September 2026; current versions live in pins.md. → [Read page](https://ratstack.sh/resources/effect-4-reference-projects)

- Effect keeps the surfaces on one contract → Schema owns values, projections build interfaces, and Layers supply implementations. → [Read page](https://ratstack.sh/lore/how-we-do-it-with-effect)

- Feature flags → Typed feature flags with owners, removal dates, and stable subject rollouts. → [Read page](https://ratstack.sh/systems/flags)

- Fence → Strict effect-tsrs diagnostics, lint, and hooks protect the gate; patched tsc checks compiler parity on checker bumps. → [Read page](https://ratstack.sh/systems/fence)

- Flags climb on evidence → A flag ladder connects each rollout step to scoped measurements, approval, and a durable receipt. → [Read page](https://ratstack.sh/lore/flags-climb-on-evidence)

- Full agent guide → An Effect stack so pure (aspirational) Kit Langton will blush. → [Read page](https://ratstack.sh/llms-full.txt)

- Infrastructure as effects → Sam Goodwin relates application operations to infrastructure requirements in one typed program. → [Read page](https://ratstack.sh/lore/infrastructure-as-effects)

- Lauren Tan: Dune, trust, and agent skills → Lauren Tan describes verification, a trust ladder, and an application framework designed for coding agents. → [Read page](https://ratstack.sh/lore/poteto-lauren-tan-2500-prs-dune)

- learn → Present Effect, Alchemy, XState, and application-design concepts during real work when the operator enables learn mode. Use for adaptive explanations and local learning progress. → [Read page](https://ratstack.sh/skills/learn)

- learn-alchemy → Learn how Alchemy 2 turns an Effect program into a planned Cloudflare deployment. → [Read page](https://ratstack.sh/skills/learn-alchemy)

- learn-rat-stack → Trace a capability through Effect, XState, five projections, the CLI, and Alchemy. Try hosted search and read. → [Read page](https://ratstack.sh/skills/learn-rat-stack)

- Lifecycles are machines → XState owns finite lifecycle states while declared Effect actors own side effects. → [Read page](https://ratstack.sh/lore/lifecycles-are-machines)

- Lint and type escape ledger (debt.md) → A source-linked count of repo-owned lint and type escapes. → [Read page](https://ratstack.sh/debt.md)

- mdsvex left unified → The next parser leaves unified; the CommonMark migrator still uses remark. → [Read page](https://ratstack.sh/lore/mdsvex-left-unified)

- No comments → Code comments are banned because names, types, tests, and boundaries should carry the meaning. → [Read page](https://ratstack.sh/lore/no-comments)

- No verify | rat-stack → The rat looks disappointed. The hook still runs. → [Read page](https://ratstack.sh/--no-verify)

- Purpose and boundaries of rat-stack (VISION.md) → What this starter is for and what a useful copy should keep. → [Read page](https://ratstack.sh/VISION.md)

- query-design → Design or review SQL reads, writes, scans, backfills, and slow database paths. Use before changing a store method or any loop that queries. Covers round-trip arithmetic, batching, keyset paging, index evidence, row budgets, PlanetScale Vitess limits, Hyperdrive connections, statement-count tests, and statement-template fences. → [Read page](https://ratstack.sh/skills/query-design)

- Rat Stack lore | rat-stack → Short, source-grounded notes on the ideas and decisions behind rat-stack. → [Read page](https://ratstack.sh/lore)

- Rat Stack systems | rat-stack → The systems rat-stack ships, the standard each keeps, and how to check it. → [Read page](https://ratstack.sh/systems)

- rat-stack → An Effect stack so pure (aspirational) Kit Langton will blush. → [Read page](https://ratstack.sh/)

- rat-stack-mode → Route non-trivial rat-stack code, data, design, investigation, and documentation tasks to every matching playbook and principle. → [Read page](https://ratstack.sh/skills/rat-stack-mode)

- Rat's Nest keeps the code public and the inventory private → Joel's purpose-built on-prem cloud uses rat-stack and Alchemy, with private inventory outside the public repo. → [Read page](https://ratstack.sh/lore/rats-nest)

- Ratstack Tube → Curated videos for learning the stack, ranked S to F, with a short take on each, built from one data file. → [Read page](https://ratstack.sh/systems/tube)

- Scopes release resources when work ends → Acquire resources lazily, keep their use inside the owner, and release them after success, failure, or interruption. → [Read page](https://ratstack.sh/lore/scopes-own-resources)

- Shared caches hold completed values → Keep pending request I/O out of isolate-scoped caches. → [Read page](https://ratstack.sh/lore/cache-completed-values)

- ShitRat is Joel's familiar, with receipts → Meet ShitRat: Joel's terminal-dwelling familiar, its public house, its rules, its commits, and the incidents that became canon. → [Read page](https://ratstack.sh/lore/shitrat)

- ShitRat wants receipts before claims → The familiar's creed: read the file, run the command, give the number, admit uncertainty, and spare everyone the corporate sludge. → [Read page](https://ratstack.sh/lore/shitrat-creed)

- ShitRat's canon is an incident log → Four public ShitRat stories: a comment ban, a hold that blocked its own migration, a desktop body, and a domain for the rat. → [Read page](https://ratstack.sh/lore/shitrat-canon)

- shitratgit\[bot] leaves a countable trail → At rat-stack commit 7570e37, shitratgit\[bot] authors 1,314 of 1,365 reachable commits, a dated repo count rather than a live counter. → [Read page](https://ratstack.sh/lore/shitratgit-bot)

- Source change history (log.md) → The generated change log as Markdown. → [Read page](https://ratstack.sh/log.md)

- Structure an Effect codebase by domain → Start with folders for application work, services and Layers in the same file, and startup code that supplies implementations. → [Read page](https://ratstack.sh/lore/structure-effect-by-domain)

- Tests prove behavior through supplied services → Supply services through Layers, choose properties or models for domain rules, and reject tests that cannot detect broken behavior. → [Read page](https://ratstack.sh/lore/tests-that-earn-their-place)

- The rat-stack bestiary eats excuses → A field guide to eight documented rat-stack creatures, with real habitats, enforceable behaviour, and strictly imaginary temperaments. → [Read page](https://ratstack.sh/lore/shitrat-bestiary)

- uncomplect → Find responsibilities that a rat-stack design combines, separate them into capabilities, cartridges, machines, features, and clients, and enforce that separation through types and checks. Use when asked to simplify, review, or replace a design, "what would Rich Hickey do", "optimize for deletion", or "define this error out of existence". → [Read page](https://ratstack.sh/skills/uncomplect)

- use-a-prompt → Discover and read published rat-stack prompts before starting a task with one. → [Read page](https://ratstack.sh/skills/use-a-prompt)

- Worker init runs twice → Alchemy Worker initialization runs in deploy and runtime contexts, so resource declarations need a boundary. → [Read page](https://ratstack.sh/lore/init-runs-twice)

- write-a-wiki-page → Write or revise public wiki pages with short prose, cited claims, meaningful visuals, and pinned code snippets. → [Read page](https://ratstack.sh/skills/write-a-wiki-page)

## Unlinked mentions

- [add-a-store](https://ratstack.sh/skills/add-a-store) → The fence is the compiler checks, lint rules, and hooks that reject prohibited code and shortcuts.¶

- [Agent rules for rat-stack (AGENTS.md)](https://ratstack.sh/AGENTS.md) → Startup fence: scripts/startup-budget.ts measures Alchemy’s actual upload.

- [Build and run rat-stack (README.md)](https://ratstack.sh/README.md) → Cutting it loses source-checked excerpts, snapshot generation, and documentation-fence checks.

- [Code snippets quote a pinned source](https://ratstack.sh/lore/code-snippets) → It differs from rat-stack’s enforcement fence.¶

- [durability](https://ratstack.sh/skills/durability) → Fence: packages/core/test/join-answer-at-commit.model.test.ts, packages/core/test/intake-sweep.model.test.ts, packages/core/test/join-intake-spec.test.ts¶

- [Durability](https://ratstack.sh/systems/durability) → Fence: packages/database/test/connection-lease.test.ts, a model over queries, bursts, and provider waits.¶

- [Effect + Alchemy peer patterns](https://ratstack.sh/resources/same-version-repos) → A second Stately service would bypass that fence.

- [Effect 4 study: September 2026](https://ratstack.sh/resources/effect-4-reference-projects) → Language service in the fence.

- [learn](https://ratstack.sh/skills/learn) → Show the card’s snippet as a TypeScript fence and its diagram as a text fence.

- [Purpose and boundaries of rat-stack (VISION.md)](https://ratstack.sh/VISION.md) → The fence keeps core free of HTTP-client and vendor implementations.

- [query-design](https://ratstack.sh/skills/query-design) → Plant a missing manifest entry and observe the fence fail.

- [Ratstack Tube](https://ratstack.sh/systems/tube) → They check that one planted fault in a generated list yields one fence message naming its entry and field.

- [The rat-stack bestiary eats excuses](https://ratstack.sh/lore/shitrat-bestiary) → A doc-fence is a published TypeScript code block that the content build writes out and pnpm check typechecks.

- [uncomplect](https://ratstack.sh/skills/uncomplect) → No fence yet proving that interfaces behave alike; candidate: a property test that compares one capability’s results across interfaces.¶

- [write-a-wiki-page](https://ratstack.sh/skills/write-a-wiki-page) → This fence quotes the shipped SHA check:¶
