AI agent prompt for working in a codebase
Write a codebase prompt that tells an AI agent how to inspect files, respect architecture, edit safely and verify changes.

Put it into practice
What you will produce
A prompt template with task, scope, constraints, acceptance evidence, verification and handoff fields.
- 01
Separate task facts from placeholders
Create fields for the requested behavior, known repository evidence, allowed files, constraints, acceptance evidence and commands; mark genuinely unknown facts as questions to investigate.
Expected result: A reusable template that asks for evidence instead of inviting invented project details.
- 02
Set the inspect-before-edit sequence
Instruct the agent to read local guidance, trace the relevant code and summarize its plan before editing; require approval or a pause when scope or requirements are unclear.
Expected result: A prompt that makes discovery and scope confirmation explicit stages.
- 03
Add verification and handoff fields
Require a full diff review, relevant project checks, exact outcomes, unrun checks, changed paths and remaining risks in the final report.
Expected result: A handoff format that can be checked against the actual workspace.
- 04
Test against a harmless task
Run the template on a small read-only repository question with one fact intentionally absent; verify the agent cites files and asks or records uncertainty instead of guessing.
Expected result: A prompt tested for evidence discipline, ready to adapt to a code change without replacing permissions or review.
Example structure to adapt
## Task
<one concrete repository question or change>
## Scope
<allowed paths and forbidden side effects>
## Acceptance evidence
<observable result and exact project check>
## Handoff
<changed files, checks run, failures and remaining uncertainty>Adapt the fields to your SDK or repository, then verify the format against the linked official documentation. This is a starting structure, not a claim that it was tested in your environment.
Acceptance checks
- The template distinguishes confirmed repository facts from unknown inputs.
- Inspection, plan and scope clarification precede any requested edit.
- The report format names changed paths, checks run, omissions and risks.
- A missing fact causes a question or explicit uncertainty, not a fabricated answer.
Limits and trade-offs
A prompt cannot replace repository permissions, tests or human review. Keep secrets and untrusted external content out of the prompt context.
Official sources
Build a project prompt
Related guides
CLAUDE.md: A Guide for Every Developer
One markdown file that makes AI coding assistants actually understand your codebase. Here's what to put in it.
There's a reason Claude Code writes great code in some projects and generic boilerplate in others. It's not the model. It's CLAUDE.md . It is one part of my Claude Code workflow: project conventions reduce guesswork, but they do not guarantee a speedup or remove the need to review the change. What it is CLAUDE.md is a plain markdown file that Claude Code reads at the start of every session. Think of it as the onboarding doc you'd give a senior contractor on day one: stack, conventions, rules, context. Without it, Claude infers patterns from what it sees in the codebase. Sometimes it infers correctly. Often it doesn't especially for implicit conventions your team just "knows". A CLAUDE.md makes your rules available without repeating them, but does not guarantee compliance: review the diff and run the checks. What to put in it 1. Stack and versions Simple but important. These…
Read the guidePrompt vs Workflow vs Agent
Everyone is calling everything an agent. Here's what actually separates the three, and why it matters when you're building.
The word "agent" is everywhere. So is "workflow". People use them interchangeably, which means everyone is confused and half the things called agents are just prompts with extra steps. Here's a clean mental model I use. It's not the academic definition it's the practical one. A prompt A prompt is a single call to an LLM. Input goes in, output comes out. That's it. No loops. No decisions. No tools. One round trip. Most "AI features" shipped in 2023 were prompts. They're underrated a well crafted prompt can do a lot. But they're fundamentally one shot and stateless. A workflow A workflow is a sequence of steps some of which may call an LLM executed in a predetermined order. The structure is defined by the developer, not the LLM. Example: a content repurposing workflow. 1. Receive a LinkedIn post (trigger) 2. Call Claude to rewrite as a Twitter thread 3.…
Read the guideClaude Code Plan Mode: A Practical Guide
Claude Code Plan Mode lets you review and steer a task plan before any file is touched. Full guide: shortcut (Shift+Tab), activation, when to use it, and how to execute the plan.
Most people use Claude Code like a chat: describe the task, watch it execute. That works for small changes. For anything touching more than two files, there's a better path. If you are looking for the shortcut, press Shift+Tab to toggle Plan Mode. To turn it off, press Shift+Tab again or use /plan only for the prompt that needs planning. The dedicated Plan Mode troubleshooting guide covers the common terminal and version issues. Plan Mode. What Plan Mode does When you activate Plan Mode, Claude reads your codebase and produces a step by step execution plan but makes no changes. You see exactly what it intends to do before a single file is written. This gives you a checkpoint: approve the plan, redirect it, or catch a wrong assumption before it cascades into 15 wrong edits. How to activate Plan Mode the shortcut Two ways: Keyboard shortcut : press Shift+Tab…
Read the guide