Contents
- 01Know What You Are Operating
- 02Orient to an Existing Project
- 03Turn Intent Into a Build Specification
- 04Make Project Context Durable
- 05Bound Permissions and the Sandbox
- 06Make Changes With Git and Worktrees
- 07Debug and Verify the Result
- 08Extend With MCP, Skills, and Hooks
- 09Delegate and Run Work in Parallel
- 10Operate in CI and Ship the Capstone
Orient to an Existing Project
Turn an unfamiliar repository into a usable system map before allowing an agent to implement changes.
By the end
A source-backed map of the project's structure, runtime, data, integrations, instructions, tests, and current change state.
Separate the copies and layers
A software project can exist simultaneously as source files on your computer, commits in a Git host, a local process, a temporary preview, a packaged desktop application, and a public deployment. These are related but not interchangeable. Editing a local file changes only that checkout until a later process builds, shares, or deploys it.
Create an evidence ladder for the question you are answering. Source proof means the intended text or code exists in the named file. Local runtime proof means a process built from that source behaves correctly. Shared preview proof means another person can reach a specific version. Production proof means the public route is serving that version. Ask Claude to label each claim with the highest layer actually observed.
Read the project's own contract
Start with the files written to orient humans and tools: README files, package manifests, dependency locks, build scripts, environment examples, deployment configuration, and project instruction files. They reveal the intended commands and architecture, but they may be stale. Treat documentation as a claim to verify against source and runtime, not as unquestionable truth.
Ask Claude to cite exact paths and distinguish facts from inferences. For example, `package.json` may prove that a script named `build` exists, while only running that script proves it currently succeeds. A deployment file may name a service, while a provider receipt or live response proves which release is active.
Trace one user outcome
Do not try to understand every file equally. Choose one user-visible outcome and trace it through the system. For a web page, follow the route to its component, data source, server logic, integration, and deployment configuration. For a command-line tool, follow its entry command to argument parsing, domain logic, state changes, and output.
This vertical trace gives each technical term a job. The interface collects or displays information. Logic applies rules. State persists what must survive. Integrations cross system boundaries. Identity controls access. Tests encode expectations. Logs and receipts reveal what happened. Claude can search quickly, but you should require it to explain this chain in plain language.
- Entry point: where the user's action or request enters.
- Owner: the file or service primarily responsible for the behavior.
- Dependencies: data, modules, APIs, and credentials the path needs.
- State: information read, created, or changed along the path.
- Proof: the test, log, output, or visible result that confirms the path works.
Inspect current state before changing history
Git tells you which files differ from the current commit, but those changes may belong to another person or another unfinished task. Ask Claude to summarize `git status` and the diff without modifying them. Do not let an orientation task clean, reset, reformat, or commit a dirty checkout merely to make the environment easier to understand.
Then inspect recent history and relevant file history to learn conventions and intent. A nearby component or a previous commit often provides a safer implementation pattern than a generic solution. History is evidence, not an instruction to restore old code blindly; the live requirement may have changed since that commit.
Write a living system map
The output of orientation should be an artifact another person can inspect. Record the repository, important directories, entry points, commands, data stores, external services, environment variables by name, test layers, and deployment path. Mark every statement confirmed, inferred, or unknown. Never copy secret values into this map.
Keep the map narrow enough to remain useful. If it becomes a file-by-file inventory, it will be obsolete before anyone reads it. Focus on responsibility boundaries and the paths a maintainer needs to build, test, deploy, and recover the system. Later chapters will turn the durable parts into project instructions and reusable workflows.
Working reference
Commands and patterns
Establish repository state
pwd git rev-parse --show-toplevel git branch --show-current git status --short
These read-only commands establish location, repository root, branch, and uncommitted work.
Inspect structure and history
find . -maxdepth 2 -type f | sort | head -200 git log --oneline -10 git diff --stat
Use the repository's preferred search tools when known. The goal is a bounded overview, recent change context, and dirty-scope size—not an unfiltered dump of every file.
Ask for read-only plan mode
claude --permission-mode plan
Starts the session in plan mode so Claude can investigate and propose an approach before implementation.
When the happy path breaks
Failure modes
Symptom
Claude returns a polished architecture description with no file references.
Likely cause
The session answered from common software patterns instead of proving how this repository is structured.
Recovery
Require a path, symbol, configuration entry, or command result for each architectural claim and label remaining assumptions explicitly.
Symptom
Orientation consumes the entire session and still does not reveal how one outcome works.
Likely cause
The request asked Claude to understand the whole codebase rather than trace a bounded user path.
Recovery
Choose one route, action, or command and follow it vertically through interface, logic, state, integration, and proof.
Symptom
Existing local changes disappear or become mixed into the new task.
Likely cause
The agent treated a dirty worktree as clutter and used reset, restore, bulk formatting, or an all-files commit.
Recovery
Stop, preserve the checkout, recover from Git or backups if necessary, and establish explicit ownership and file boundaries before proceeding.
Symptom
A local page looks correct, so the work is reported as deployed.
Likely cause
The evidence ladder collapsed source, local runtime, preview, and production into one claim.
Recovery
State exactly which layer was observed and gather a versioned deployment receipt plus independent public-route verification before claiming production.
Hands-on lab
Trace one real outcome through a repository
Choose a route, button, API call, or command you understand as a user and have Claude map its complete path without making edits.
- 01Define the user action and the visible result in one sentence.
- 02Ask Claude to locate the entry point and identify the smallest set of files that own the path.
- 03Trace the request through logic, persistent state, integrations, identity checks, and response handling where applicable.
- 04Locate the closest existing tests and the commands that run them.
- 05Inspect Git status and mark any files in the path that already have uncommitted changes.
- 06Write confirmed, inferred, and unknown sections, then independently verify five cited facts.
Deliverable: A system-path map that another beginner can use to explain where the outcome enters, which responsibilities it crosses, where state lives, and how the result is proven.
Reusable artifact
Project orientation map
A concise record of the facts Claude Code and a human need before changing an unfamiliar system.
Project and purpose: [name + one-sentence outcome] Canonical repository: [URL or owner/name] Canonical local path: [absolute path] Current branch and dirty state: [branch + files to preserve] Primary entry points: [routes, commands, applications] Responsibility map: [interface / logic / state / integrations / identity] Start command: [command + expected address or output] Verification commands: [targeted test / typecheck / lint / build] Configuration names: [environment variable names only] Deployment path: [source -> build -> provider -> public route] Confirmed facts: [claim -> evidence] Inferences: [claim -> why it is plausible] Unknowns and owners: [question -> who or what can answer]
Before you move on
Receipt checklist
- The map identifies a canonical repository, checkout, branch, and existing dirty scope.
- One user outcome is traced from entry point to observable result with exact file references.
- The runtime, test, and deployment paths are recorded as separate layers.
- At least five claims were independently checked against source or command output.
- No source file changed during orientation.
Primary sources
