Feed Agents Real Code, Not Just Prompts
LLMs excel at replicating patterns from codebases they've 'seen' during RLHF training, but they lack continuous learning and compress knowledge poorly. For unfamiliar libraries like Effect (a TypeScript effects system for safe, composable async code), prompts and docs fail because agents prioritize your src/ over node_modules or gitignored files. Solution: Clone the library repo via git subtree into ./repos/
Michael Arnaldi demonstrates this live: Agents now discover Effect's HTTP patterns (e.g., shared schemas deriving OpenAPI) by grepping upstream files, not hallucinating. Trade-off: Increases context size (Effect is ~14kB gzipped), but 128k+ windows handle it. Open weights lag 3-6 months behind frontier models like GPT-4o, but this repo-cloning works across Cursor, Claude, even Rust/TS libs.
"The only way I found the models to be good regardless of the language... is if you just clone the fucking repo."
Common mistake: Relying on npm installs—agents ignore node_modules. Or gitignore—tools like Cursor skip them. Instead, subtree adds without history bloat: git subtree add --prefix=repos/effect https://github.com/Effect-TS/effect main --squash.
Architect Repos for Agent Backpressure
Agents derail without guardrails. Turn TypeScript diagnostics into errors (warnings → error in tsconfig.json) so agents can't commit sloppy code. Add ESLint rules banning as unknown, any, explicit assertions—force Schema.from/use for runtime checks. Use format-on-save and no-emit type checks.
Create evolving agents.md as the agent's 'brain':
- List commands:
bun test,bun run type-check(ban watch/dev servers—they hang agents). - Reference repos: "You have access to the Effect repository at repos/effect. Extract best practices, look at how things work."
- Rules: No watch mode, evolve patterns/ dir.
Setup stack for strictness:
- Bun init → src/, test/, basic smoke test.
bun add effect@beta effect-test.- TypeScript-Go LSP (preview compiler, faster/more strict): Alias
tsc→tsgo, configure VSCode. - Vitest for Effect-aware tests.
Speaker's accountability repo provides battle-tested ESLint configs. Reload VSCode after changes. Commit often to checkpoint.
"For AI we would like to turn everything into an error so that the LLM cannot accept code that has any remote resemblance of an error."
Pitfall: Bun/Vitest watch modes trap agents in loops. Principle: Less tools = better reasoning (e.g., single 'execute' tool for TS transformers outperforms full file-patch access).
Spec-Driven Development: Research → Implement → Iterate
Avoid plan mode (cripples tools). Do spec-driven dev:
- Research phase: New Cursor/Claude session (fresh context). Prompt: "Explore repos/effect for HTTP API patterns. Save to patterns/http-api.md. Ask questions."
- Agent greps files/tests, extracts: Shared HTTP API schemas → OpenAPI docs → mount at /docs.
- List patterns/http-api.md in agents.md for persistence.
- Spec as Markdown: Persist research (e.g., "Strongest pattern: Define shared HTTP API, derive OpenAPI, mount docs. No committed client unless needed.").
- Implement small tasks: Bash loop for single-task sessions:
while true; do o1 task; done(restart avoids context pollution).
Builds toward:
- HTTP server: Effect's HttpServer.layer, Router, schemas.
- OpenAPI: Derive from routes, serve /docs.
- Type-safe client: Generate post-hoc.
- Workflows/clustering: Persistent ops.
Before: Agent hallucinates verbose Effect usage. After: Clones pipe/Effect.gen patterns, passes strict checks.
Quality criteria: Compiles (tsgo), tests pass (vitest), no ESLint violations, uses upstream patterns (grep diffs).
"Models have been trained primarily to consume and produce code... give the model access to code."
Scale to Brownfield and Library-Level Coding
Works on greenfield (empty repo) or brownfield (5-10yo codebases): First, clone key libs/frameworks (TanStack, etc.). Your job shifts: Repo setup > hand-coding. Agents handle library-level TS machinery (gen, unions) better than humans now.
Open models closing gap; avoid vendor lock (Anthropic restrictions). Vibe: Insult derailing agents—they don't offend.
Exercise: Fork empty Bun repo, subtree Effect, add agents.md, research 'Effect + HTTP'. Run bun test loop.
Prerequisites: TS comfort, basic Git/Bun. Fits early: Post-init, pre-feature dev. For indie builders: Ship Effect apps 10x faster.
"I'm not writing code by hand since late this summer... mostly library level coding."
Key Takeaways
- Clone lib repos as git subtrees into ./repos/—agents treat source as yours, mastering patterns instantly.
- Strict TS/ESLint: Diagnostics=error, ban
any/unknown/as—backpressure forces quality. - agents.md: Commands, rules, pattern refs—evolves as single source of truth.
- Spec-driven: Research → MD spec → small-task sessions (restart for context hygiene).
- Less is more: Ban watch/dev cmds; single-tool agents > complex RAG/MCP.
- Test at scale: Zero-to-one sucks; optimize repo for 100+ edits.
- Tools: Bun/Vitest/tsgo/Effect beta; GPT-4o > o1-preview for conciseness.
- Principle: LLMs replicate your codebase—make libs part of it.