Prompt.Lab

Claude Code / Prompt library

25 Claude Code prompts that make the work inspectable.

Copy practical templates for understanding a repository, debugging from evidence, building focused features, refactoring safely, and reviewing what will ship.

Prompt.Lab Editorial16 min readOfficial sources reviewed

Claude Code can inspect files, make edits, and run commands. The prompt therefore needs more than a feature description: it should define the evidence to inspect, the boundary of the change, and the check that proves the result.

These templates follow Anthropic's documented workflow principles: explore before coding, be specific about context, give Claude a verification mechanism, and keep unrelated work out of the diff. Replace every bracketed placeholder; a template is a starting structure, not a finished request.

Use the smallest relevant repository and branch.

Remove secrets and unnecessary personal data.

Ask for file-level evidence before accepting a diagnosis.

State what must not change as clearly as what should change.

Review commands, diffs, and external actions before approval.

25 Claude Code prompts

Understand the codebase

Use these before editing. Replace every bracketed field with real project context.

01

Map the architecture

Explore this repository without changing files. Create a concise architecture map for [FEATURE OR DOMAIN]. Identify entry points, main modules, data flow, persistence, external services, tests, and configuration. Support every conclusion with file paths. Mark anything uncertain.
02

Trace one user flow

Trace [USER ACTION] from the first UI or API entry point to the final stored or displayed result. Show the important functions in order, validation and authorization boundaries, error paths, and the tests that cover them. Do not edit files.
03

Explain a difficult module

Explain [FILE OR MODULE] to a new maintainer. Cover its responsibility, public interface, dependencies, state changes, invariants, failure modes, and callers. Use code references rather than generic descriptions. End with three safe extension points.
04

Find the change surface

I need to add [BEHAVIOR]. Investigate only. Identify the smallest set of files likely to change, the existing pattern to follow, the tests that should prove the behavior, and risks to compatibility. Do not propose a rewrite.
05

Audit assumptions

Review the current implementation of [FEATURE] and list assumptions it makes about input, authentication, timing, data shape, network availability, and configuration. Separate assumptions enforced by code from assumptions that are merely hoped for.

Debug from evidence

A good debugging prompt asks for reproduction and root cause before a patch.

06

Reproduce before fixing

Investigate this bug: [SYMPTOM]. First find or create the smallest reliable reproduction. Record expected versus actual behavior, relevant logs, and the failing path. Diagnose the root cause before editing. Then propose the smallest fix and a regression test.
07

Debug an intermittent failure

Analyze the intermittent failure below. Build a hypothesis table with evidence for and against timing, race conditions, stale state, retries, shared resources, and environment differences. Add targeted instrumentation or a deterministic test before changing production logic. [LOGS / STEPS]
08

Find a performance regression

The operation [OPERATION] changed from [BEFORE] to [AFTER]. Locate measurable bottlenecks using existing profiling or timing tools. Distinguish CPU, I/O, database, network, and rendering costs. Recommend the smallest optimization, its trade-off, and a repeatable benchmark.
09

Diagnose an API integration

Debug the integration between [SYSTEM A] and [SYSTEM B]. Trace request construction, authentication, serialization, status handling, retries, idempotency, and error reporting. Redact secrets. Prove the failing boundary before modifying code.
10

Explain the root cause

Using the reproduction and repository evidence, write a root-cause analysis for [BUG]. Include trigger, faulty assumption, failure chain, user impact, why existing tests missed it, focused fix, regression test, and any follow-up prevention. Do not blame individuals.

Build a focused feature

State the observable result, boundaries, and verification before implementation.

11

Implement a vertical slice

Implement the smallest complete slice of [FEATURE]. Acceptance criteria: [CRITERIA]. Reuse existing architecture and UI patterns. Do not change [OUT OF SCOPE]. Add focused tests, handle loading/empty/error states where relevant, run the project checks, and summarize the final diff.
12

Add an API endpoint

Add [METHOD] [PATH] for [PURPOSE]. Follow existing routing and response conventions. Validate input, enforce authorization, avoid leaking internal errors, preserve secrets server-side, and make repeated requests safe where required. Add success, invalid-input, unauthorized, and failure tests.
13

Build a UI workflow

Build the [WORKFLOW] interface using the project's existing component and styling system. Requirements: [STATES AND BEHAVIOR]. Include keyboard access, visible focus, labels, validation, loading, success, empty, and error states. Verify on narrow and wide layouts.
14

Create a safe database migration

Plan and implement the migration for [DATA CHANGE]. Preserve existing data, describe forward and rollback behavior, avoid long blocking operations, update application code compatibly, and add checks proving old and new records work. Stop if the repository does not reveal the deployment order.
15

Write tests from acceptance criteria

Convert these acceptance criteria into focused tests before changing implementation: [CRITERIA]. Map each test to a user-visible behavior or invariant. Avoid testing private implementation details. Run the tests to establish the current baseline, then report what fails.

Refactor without changing behavior

Require a baseline and explicitly protect behavior.

16

Improve clarity

Refactor [MODULE] for clarity without changing observable behavior or public interfaces. First identify the behaviors protected by tests. Make the smallest coherent change, preserve naming conventions, avoid new dependencies, run the full relevant checks, and show evidence that behavior stayed stable.
17

Reduce coupling

Analyze coupling around [COMPONENT]. Identify which dependencies are essential, accidental, or circular. Propose a minimal boundary that reduces coupling without creating a speculative abstraction. Implement only after explaining migration risk and verification.
18

Split a large module

Split [FILE] because it currently mixes [RESPONSIBILITIES]. Preserve its public interface. Propose module boundaries based on real responsibilities and callers, move code in small steps, keep tests passing after each step, and avoid unrelated formatting churn.
19

Optimize safely

Optimize [HOT PATH] while preserving correctness. Establish a repeatable baseline, identify the measured bottleneck, propose alternatives with complexity trade-offs, implement the smallest justified option, and compare before/after results. Do not optimize code that has not been measured.
20

Migrate legacy code

Create an incremental migration from [LEGACY PATTERN] to [TARGET PATTERN]. Inventory callers, define compatibility boundaries, sequence changes so the repository remains buildable, add characterization tests, and identify the exact point where old code can be removed.

Review and ship

Use a separate review pass after implementation.

21

Review the final diff

Review the complete diff as a skeptical maintainer. Check correctness, scope, consistency, hidden behavior changes, error paths, and unnecessary complexity. Map findings to file and line, rank by impact, and distinguish confirmed defects from questions. Do not edit during review.
22

Run a defensive security review

Perform a defensive review of this authorized code change. Check authentication, authorization, input validation, secret handling, data exposure, unsafe defaults, dependency changes, and abuse cases. Do not create exploit payloads. For each finding, cite evidence and recommend a safe mitigation.
23

Review accessibility

Review the changed user interface for semantic structure, keyboard operation, focus order and visibility, labels, announcements, contrast, motion, zoom, and responsive behavior. Cite the relevant component for each finding and suggest the smallest accessible correction.
24

Find test gaps

Compare the changed behavior with the current tests. Identify untested user outcomes, failure paths, boundaries, and regressions—not just uncovered lines. Rank gaps by risk, then add the smallest high-value tests without rewriting the test suite.
25

Prepare the handoff

Prepare a concise engineering handoff for this change. Include purpose, key files changed, important design decisions, verification commands and results, known limitations, deployment or migration steps, and the one thing the next reviewer should inspect most carefully.

How to adapt a template without making it longer

Add only context that changes the implementation: the goal, relevant evidence, constraints, acceptance criteria, and verification command. Remove generic role-play, repeated instructions, and adjectives that cannot be tested.

The reusable formula

Inspect this evidence → achieve this observable result → preserve these boundaries → verify with these checks → report uncertainty and the final diff.

Turn theory into a better result

Your idea is good.
Give it better instructions.

Paste a rough request into Prompt.Lab and get a structured prompt for ChatGPT, Claude, or Gemini.

Try Prompt.Lab free →

Continue exploring

View all →