"design Claude Code from scratch"
apparently this was asked in an Anthropic interview round. came across it somewhere on the internet and honestly it's a much more interesting AI systems problem than most classic distributed systems questions
- understand the repository
- build an AST + dependency graph
- extract symbols, imports and cross-file relationships instead of relying on raw text
- retrieve only relevant context
- use embeddings + graph traversal to fetch the right files
- sending an entire codebase to the model doesn't scale
- plan before writing code
- identify which files need changes
- break the task into small executable steps before generating edits
- edit incrementally
- generate minimal diffs instead of rewriting files
- preserve existing architecture, naming conventions and formatting
- validate every change
- run linting, type checks and tests after each edit
- failed validation should trigger another reasoning pass
- use tools, not just the model
- search, terminal, git and diagnostics become tools the agent can call whenever needed
- remember context across the session
- keep track of previous edits and architectural decisions
- avoid repeatedly solving the same problem
- explain every edit
- show why each file changed
- surface tool outputs and validation results so developers can trust the agent
Probably not how Claude Code is actually built, but this is how I'd structure the system based on what I've learned about AI coding agents.