How to Work and Compound with AI: A Practical Setup Guide

⬅️ Back to Projects

Eugene Yan at Anthropic wrote the best guide I’ve read on working with AI coding agents. Not a list of tips. A system. The core idea: every session should make the next one better. Context compounds. Corrections accumulate. Your config learns.

This is my walkthrough of his approach, rewritten as a setup you can follow from scratch.

Step 1: Organize Where Things Live

AI agents find things through directory traversal and grep. If your files are scattered, the agent can’t find them.

Two root directories:

  • ~/src/: all code repos
  • ~/vault/: all knowledge work, split into projects/, notes/, kb/

That’s it. Clean enough that a glob pattern can find anything.

Step 2: Set Your Global Behavioral Config

The agent reads ~/.claude/CLAUDE.md at the start of every session. This is your first config file.

Include preferences that don’t change between projects. How direct you want the agent to be. How it should handle mistakes. What it should teach you. Eugene’s example includes a behavior block and a teaching block:

<behavior>
- Be direct and push back when you disagree.
- When unsure, say so rather than guessing.
- When something fails, investigate root cause before retrying.
- Keep diffs scoped to the task: no drive-by refactors.
</behavior>

<teaching>
When a key term surfaces that I likely haven't internalized,
explain it in 1-2 sentences and then move on.
</teaching>

This lives in ~/.claude/CLAUDE.md and applies everywhere.

Step 3: Layer Config by Directory

Claude loads CLAUDE.md files by walking up the directory tree. Put repo-level conventions (linting, naming, PR formats) in the repo root. Put project-specific context (directory layout, domain knowledge) deeper in the project tree. When you start a session in a subdirectory, Claude picks up every CLAUDE.md along the path.

Step 4: Add Per-Project INDEX.md

Biggest time saver in the whole system. Each project gets an INDEX.md that lists relevant docs, Slack channels, and URLs with annotations.

## Design Docs
- design/architecture.md — system architecture, read before making structural changes
- design/data-model.md — database schema and migration strategy

## Channels
- #proj-api — API design discussions, check for ongoing debates

A bare URL list forces the agent to open everything to figure out relevance. Annotations do that work once and store the result.

Step 5: Create Skills for Repeated Tasks

A skill is a markdown file the agent loads on demand. It describes a workflow. If you do something weekly, make it a skill. Eugene bootstraps skills by doing the task once, then asking the agent to extract the process into a skill file.

Keep skills small. Focus on the workflow and routing. Store templates and scripts separately so the skill stays readable.

Step 6: Keep CLAUDE.md Short with Lazy-Loaded Guides

A CLAUDE.md that loads everything every session wastes context. Split instructions into guides that load on demand:

<guides>
- Writing docs: ~/.claude/guides/writing.md
- Building evals: ~/.claude/guides/evals.md
- Dashboards: ~/.claude/guides/dashboards.md
</guides>

Don’t import them. Just list them with a note to read when relevant.

Step 7: Shift Verification Left

Set up post-edit hooks that run formatters automatically. ruff format, ruff check --fix after every edit. This catches style issues without costing tokens.

For deeper verification, give the agent feedback loops. If the output produces a metric, let the agent run the eval. If it renders in a browser, let the agent inspect it. If the code runs, let the agent read the output or error and iterate.

Step 8: Mine Transcripts for Config Updates

This is where compounding happens. Periodically have the agent scan past session transcripts for patterns. Phrases like “can you also” or “still wrong” signal gaps in your config. Each correction made during a session becomes input for updating CLAUDE.md or skills.

Eugene scanned 2,500 of his past turns and found a significant percentage contained these correction patterns. That’s thousands of missing config entries, surfaced automatically.

Step 9: Run Parallel Sessions

Once you have the config in place, delegate bigger tasks. Eugene runs three to six sessions simultaneously. The bottleneck shifts from doing the work to writing good specs and reviewing outputs.

Use git worktrees for shared repos. Set up session monitoring: a sound hook when a session finishes, tmux titles with status indicators, the Claude Code status line for context usage.

Step 10: Close the Loop

Work in shared repos and docs. What you share today becomes context tomorrow. Automate worklog posts with links to artifacts. Refactor configs periodically to remove conflicts.

That’s the full setup. Takes a few hours to get the skeleton in place. The compounding happens over weeks as corrections accumulate.

Links

Crepi il lupo! 🐺