Claude Code Prompt Template

A reusable template for writing structured prompts that get consistent, high-quality results from Claude Code. Copy the skeleton below and fill in each section for your task.

The Template

# [Task Title]

## Context

[Describe the project, codebase, or situation. Include relevant tech stack,
frameworks, and conventions. Reference specific files or directories.]

- Language/framework: [e.g. Python 3.12 / FastAPI]
- Key files: [e.g. `src/api/routes.py`, `tests/test_routes.py`]
- Conventions: [e.g. PEP 8, existing patterns to follow]

## Objective

[One or two sentences describing exactly what you want done.
Be specific about the desired outcome, not the steps.]

## Requirements

1. [Specific requirement with acceptance criteria]
2. [Another requirement]
3. [Constraint or boundary — e.g. "Do not modify the public API"]

## Current Behaviour

[What happens now. Include error messages, logs, or reproduction steps
if this is a bug fix.]

## Expected Behaviour

[What should happen after the change. Be precise.]

## Files Summary

| File | Action |
|------|--------|
| `path/to/file.py` | Modify — [brief description] |
| `path/to/new_file.py` | Create — [brief description] |
| `path/to/tests.py` | Update — [add tests for new behaviour] |

## Verification

1. [How to verify the change works — e.g. run a command, check output]
2. [Additional verification step]
3. [Edge case to test]

## Out of Scope

- [Things you explicitly do NOT want changed]
- [Adjacent improvements to skip for now]

Section Guide

Context

Give Claude Code enough background to make good decisions without asking follow-up questions. Mention:

  • The tech stack and language version

  • Key file paths it will need to read or modify

  • Existing patterns or conventions in the codebase

  • Any relevant CLAUDE.md or project instructions already in place

Objective

Keep this to one or two sentences. A good objective answers: "If this prompt succeeds, what is different?" Avoid describing the implementation steps — let Claude Code figure those out.

Requirements

Number each requirement. Each should be independently verifiable. Include constraints (what not to do) alongside positive requirements. Examples:

  • "Add input validation for the email field using Pydantic"

  • "Do not change the database schema"

  • "Follow the existing error handling pattern in `src/errors.py`"

Files Summary

A table of files to create, modify, or delete. This helps Claude Code plan its work and helps you review the scope. If you don’t know the exact files, describe the areas instead:

  • "Authentication middleware"

  • "API route handlers for `/users`"

Verification

Concrete steps to confirm the change works. Prefer commands:

  • make test

  • curl -X POST localhost:8000/api/users

  • "Page renders without console errors"

Out of Scope

Prevents scope creep. Claude Code sometimes "improves" adjacent code. Calling out what to leave alone keeps the change focused.

Tips for Effective Prompts

Be specific over verbose. A precise two-line requirement beats a vague paragraph. "Add a --dry-run flag to the deploy command that prints what would happen without executing" is better than "make the deploy command safer".

Reference files by path. Claude Code can read files, but pointing it to the right ones saves time and reduces hallucination.

Include the "why". When a requirement might seem unusual, explain the reasoning. "Use subprocess instead of os.system because we need to capture stderr" helps Claude Code make better decisions in edge cases.

Use plan mode for large changes. If the change touches more than 3-4 files, ask Claude Code to plan first: "Implement the following plan:" followed by this template. Review the plan before it writes code.

One task per prompt. Avoid combining unrelated changes. "Add user authentication AND refactor the database layer" will produce worse results than two focused prompts.