Claude Code is a CLI agent that runs in your terminal — it reads your repository, edits files, and runs commands (asking for confirmation before destructive actions), handling everyday development tasks from natural-language instructions. This guide covers the common patterns Claude's official docs present, with prompt examples. (As of June 2026. Features and flags may change, so check the official docs for the latest.)
Explore code — get up to speed fast
When you join a new project or need to locate a feature, ask Claude to explain the structure or find the related code. It only reads, so there's no risk of changes.
Debug and refactor
For bugs, paste the error and ask Claude to trace the cause and fix it. For refactoring, it's useful for moving legacy code to more modern patterns. Both the docs and practitioners recommend incremental refactoring — fix one file, run tests to verify, then move on, rather than one sweeping multi-file pass.
Write tests
Claude examines your existing test files to match the style, frameworks, and assertion patterns already in use. Be specific about what behavior to verify; asking it to "find edge cases I might have missed" can surface tests for error conditions, boundary values, and unexpected inputs.
PRs and docs
When changes are ready, ask directly ("create a pr for my changes") or go step by step. With the gh CLI, creating a PR via gh pr create automatically links the session to that PR, and you can return later with claude --from-pr <number> or by pasting the PR URL into the /resume search. For docs, Claude can scan modules, find functions missing comments, and generate documentation in standard formats.
# Explore code
Explain the overall structure of this project
Find the code related to the payment feature
# Debug / refactor
Trace and fix the cause of this error: [paste error]
Refactor @src/legacy/parser.js to a more modern pattern
# Tests / PR
Write tests for @src/utils/format.ts matching the existing style, including edge cases
create a pr for my changes
Patterns that work better
- Explore first, then edit: using read-only exploration (Plan Mode) to build context and review a plan before implementing prevents code from accumulating in the wrong direction.
@filereferences: include specific file contents in context before processing (e.g.@src/utils/format.ts).- Resume and parallel work: split a task across sessions, or run parallel sessions with git worktrees to avoid concurrent-edit collisions.
- Scripts and CI: pipe Claude into scripts with a targeted prompt via
-pfor CI code review and batch processing. - Context management: run
/compactafter finishing each major task, and start fresh sessions for unrelated work.
Summary
Key points: (1) explore, debug, refactor, test, PR, and docs are the common use cases; (2) a "read and plan before editing" flow is safer; (3) tools like @file, the gh integration, the -p pipe, and /compact boost efficiency. The prompt recipes for each pattern are in the official Claude Code workflows docs.
This article is based on the use-case patterns in Claude Code's official docs (code.claude.com, support.claude.com). Claude Code ships frequently, so verify version-specific commands and flags in the official docs. Always review generated code and PRs before submitting. (Official source: docs.claude.com)