Prompting and supplying context
Working with an agent is not about finding magic prompt words. In practice four things determine the outcome:
1. Task precision — what you want and what counts as "done".
2. Context — which files to look at, which pattern to follow.
3. Constraints — what not to touch, which library not to use.
4. A verification path — how it should confirm the result (build, test, lint).
The fourth is the most often forgotten and the most valuable: tell the agent to "run ./gradlew :app:testDebugUnitTest and fix until it is green" and it finds its own mistakes.
| Anti-pattern | Why it is a problem | Instead |
|---|---|---|
| "Improve the code" | "Good" is not measurable — the agent makes arbitrary changes | "Replace the nested ifs in this function with early returns" |
| Dumping the whole repo into context | Signal is diluted, cost rises | Naming 2-3 relevant files |
| Five tasks in one prompt | Half stays unfinished, review becomes hard | One task → verify → next |
| Fixing a wrong result by hand | The cause remains — it repeats next time | Recording the cause in CLAUDE.md or a skill |
Before large changes use plan mode. The agent presents a plan first, you agree, then implementation starts. That is far cheaper than changing 20 files in the wrong direction.
📚 Sources and documentation
- Claude Code best practicesofficialcode.claude.com
Official guidance on framing tasks, plan mode and workflow.
- Common workflowsofficialcode.claude.com