Skip to content

Claude Code Practical Workflows

This guide compiles the most effective prompt patterns, workflows, and community best practices for day-to-day use of Claude Code. It applies to exploring codebases, debugging, refactoring, CI/CD automation, and scenarios ranging from single-session tasks to multi-session collaboration.

Supplementary reading: Claude Code Best Practices → Community Tips — 127+ settings tuning, 40+ prompt techniques, and Hooks Mastery patterns from the community.

Core Philosophy

Claude Code is not a chatbot—it's an agentic coding environment. It can read files, run commands, make changes, and solve problems autonomously. This agency means:

  • Describe what you want, not how: Let Claude figure out how to build it
  • Context is your most valuable resource: When the context window fills, performance degrades
  • Give Claude ways to verify itself: Let it run tests, lint, builds, and check results itself

Part 1: Daily Development Workflows

1. Understanding a New Codebase

Drill down progressively: Start with broad questions, then narrow to specific areas.

Give me an overview of this codebase
Explain the main architectural patterns used here
What are the key data models?
How is authentication handled?

Find relevant code:

Find files that handle user authentication
How do these files work together?
Trace the login flow from frontend to database

Tips:

  • Use the domain language from your project
  • Ask Claude to explain coding conventions and patterns used in the project
  • Install code intelligence plugins for your language to get precise symbol navigation

2. Fixing Bugs Efficiently

I see this error when running npm test: [paste error/screenshot]
Suggest several ways to fix the @ts-ignore in user.ts
Update user.ts per your suggestion, adding null checks

Key principles:

  • Tell Claude the command to reproduce the issue and get a stack trace
  • Mention any steps to reproduce the error
  • Let Claude know if the error is intermittent or consistent
  • Don't just fix symptoms: Ask Claude to find and fix the root cause
The build is failing with this error: [paste error].
Fix it and verify the build succeeds. Address the root cause, don't suppress errors.

3. Refactoring Code

Find deprecated API usage in the codebase
Suggest how to refactor utils.js to use modern JavaScript features
Refactor utils.js to use ES2024 features while maintaining the same behavior
Run tests on the refactored code

Tip: Refactor in small, testable increments. Run tests after each refactor.

4. Writing Tests

Find functions in NotificationsService.swift that aren't covered by tests
Add tests for the notification service
Add test cases for edge cases of the notification service
Run the new tests and fix any failures

Claude will examine existing test files and match the existing style, framework, and assertion patterns. Ask Claude to identify edge cases you might have missed.

5. Creating PRs

Summarize the changes I made to the authentication module
Create a PR
Enhance the PR description with more context about security improvements

When creating a PR with gh pr create, the session automatically links to that PR. Return later with claude --from-pr 123.

6. Working with Documentation

Find functions in the auth module that lack JSDoc comments
Add JSDoc comments to undocumented functions in auth.js
Improve the generated documentation with more context and examples
Check if docs meet our project standards

Tip: Specify documentation style (JSDoc, docstrings, etc.), request examples, and focus on public APIs, interfaces, and complex logic.

7. Working in Non-Code Folders

Claude Code can work in any directory. Run it in your note library, documentation folders, or any collection of markdown files to search, edit, and reorganize content just like code. The .claude/ directory and CLAUDE.md exist alongside configuration directories for other tools without conflicts.

8. Using Image Analysis

Drag and drop images into the Claude Code window, or copy-paste (Cmd+V works in iTerm2 on Mac), or provide an image path:

Analyze this image: /path/to/screenshot.png
Describe the UI elements in this screenshot
What's wrong with this database schema diagram?
Generate CSS based on this design mockup

When Claude references an image (e.g., [Image #1]), Cmd+Click (Mac) or Ctrl+Click (Windows/Linux) opens it in your default viewer.


Part 2: Effective Communication Patterns

Prompt Pattern: Before / After

StrategyVagueSpecific
Scope the task"Add tests for foo.py""Write tests for foo.py covering edge cases where users are logged out. Avoid mocks."
Point to sources"Why does ExecutionFactory have a weird API?""Look at ExecutionFactory's git history and summarize how its API evolved"
Reference existing patterns"Add a calendar widget""Look at how existing widgets on the homepage are implemented to understand the pattern. HotDogWidget.php is a good example. Implement following that pattern."
Describe symptoms"Fix login error""Users report login failures after session timeout. Check the authentication flow in src/auth/. Write a failing test that reproduces the issue, then fix it."

Ways to Provide Rich Context

MethodExample
@ reference filesExplain the logic in @src/utils/auth.js — includes full file content
@ reference directoriesWhat's the structure of @src/components? — provides file listing
Paste imagesCopy/paste or drag screenshots into your prompt
Provide URLsFor documentation and API references
Pipe data`cat error.log
Let Claude fetch itself"Use Bash commands to pull context yourself"

Extra benefit of @ file references: Adds CLAUDE.md from the file's directory and parent directories to context. You can reference multiple files in a single message (e.g., @file1.js and @file2.js).

Let Claude Interview You

For complex features, have Claude interview you first, then start implementation:

I want to build [brief description]. Interview me in detail using the AskUserQuestion tool.

Ask about technical implementation, UI/UX, edge cases, concerns, and trade-offs.
Don't ask obvious questions; dig deep into challenges I might not have considered.

Keep interviewing until we've covered everything, then write the complete spec to SPEC.md.

Once done, start a new session to execute the spec—a clean context entirely focused on implementation.


Part 3: Making Claude Self-Verify

Core principle: Don't accept Claude's first output and stop there. Give Claude something that can produce a "pass/fail" signal, and the loop closes automatically.

Verification Strategy Comparison

StrategyBeforeAfter
Provide verification criteria"Implement a function to validate email addresses""Write a validateEmail function. Test cases: user@example.com should be true, invalid should be false, user@.com should be false. After implementation, run tests"
Visual verification for UI changes"Make the dashboard look better""[Paste screenshot] Implement this design. Take a screenshot of the result and compare with original design. List differences and fix them"
Address root cause"Build failing""Build failing with this error: [paste error]. Fix it and verify build succeeds. Address root cause, don't suppress errors"

Choosing Verification Depth

DepthMethodWhen to use
LightweightAsk Claude to run checks and iterate in one promptSingle-shot tasks
MediumSet /goal conditions, Claude works until conditions metTasks spanning multiple rounds
Strong constraintsStop hook runs check script, blocks progress until passUnattended automation
Independent reviewSub-agent with fresh model reviews results, tries to refuteCorrectness checks

Adversarial Review

What problems might exist in your implementation? Act as a security engineer and review it
Use a sub-agent to review this change according to PLAN.md. Check that each requirement is implemented,
listed edge cases have tests, and there are no changes beyond task scope.
Report defects, not style preferences.

The reviewer runs as a sub-agent, and the implementation session receives defects directly, can fix and re-review without copying findings between windows.

Verification Patterns Quick Reference

PatternFlowWhen to use
Writer → ReviewerOne session writes code, another independently reviewsUnbiased code review needed
Tests → Iterate → PassWrite tests first, then implement, loop until passWell-defined requirements
Plan → Implement → VerifyPlan first, then implement, verify with sub-agentComplex architecture changes

Part 4: Session Management

Lifecycle Commands

bash
# Resume most recent session
claude --continue

# Select from list to resume
claude --resume

# Resume from PR
claude --from-pr 123

# In-session resume
/resume

Direction Control

ActionShortcut/CommandEffect
Stop mid-streamEscStop Claude, keep context, can redirect
Rewind menuEsc + Esc or /rewindRestore conversation and code state, or from message summary
Undo changes"Undo that"Have Claude revert its changes
Reset context/clearFree context window between unrelated tasks

When to /clear:

  • Between unrelated tasks
  • After correcting Claude on the same problem twice+ (context polluted by failed approaches)
  • Long sessions accumulated lots of unrelated context

Context Management Strategies

StrategyWhen to use
/clearComplete reset between tasks
/compact <instructions>Compress conversation but preserve key information
/rewind → summaryCompress only part of conversation
/btwQuick question, answer doesn't enter conversation history

Naming Sessions

Give sessions descriptive names (e.g., oauth-migration) for easier finding later. Set compaction preferences in CLAUDE.md:

When compacting, always preserve the full list of modified files and any test commands

Part 5: Automation and Scaling

Non-Interactive Mode (CI / Scripts)

bash
# One-off query
claude -p "Explain what this project does"

# Structured output
claude -p "List all API endpoints" --output-format json

# Streamed output (real-time processing)
claude -p "Analyze this log file" --output-format stream-json --verbose

# Pipe input
git log --oneline -20 | claude -p "summarize these recent commits"

Parallel Sessions

MethodIsolation levelWhen to use
WorktreesFull isolation (different git branches)Feature A and Feature B developed in parallel
Desktop AppVisual management of multiple local sessionsNeed to monitor multiple tasks simultaneously
Web VersionCloud VMWhen away from local machine
Agent TeamsAutomatic coordination of multiple sessionsComplex task automatic dispatch

Writer/Reviewer Pattern

Session A (Writer)Session B (Reviewer)
Implement rate limiter for API endpoint
Review src/middleware/rateLimiter.ts. Look for edge cases, race conditions, and consistency with existing middleware patterns.
Fix issues per review feedback

Fresh context improves code review because Claude isn't biased toward code it just wrote.

Scheduled Tasks

OptionRuns onBest for
RoutinesAnthropic-managed cloud infrastructureTasks that should run even when computer is off. Supports API calls and GitHub event triggers
Desktop scheduled tasksLocal machineTasks needing direct access to local files or uncommitted changes
GitHub ActionsCI pipelineTasks related to repository events (open PRs)
/loopCurrent CLI sessionQuick polling while session is open

When writing prompts for scheduled tasks, explicitly state success criteria and how to handle results—tasks run autonomously and cannot ask clarification questions.


Part 6: Common Failure Modes and How to Avoid Them

Failure ModeSymptomFix
Kitchen sink sessionJump from one task to another, context full of unrelated info/clear between unrelated tasks
Repeated correctionsClaude does it wrong → you correct → still wrong → correct againAfter two failures, /clear and restart with better initial prompt
Overgrown CLAUDE.mdCLAUDE.md too long, Claude ignores important rulesPrune ruthlessly; if Claude does it right without instructions, delete it
Trust-verify gapImplementation looks reasonable but doesn't handle edge casesAlways provide verification (tests, scripts, screenshots)
Infinite exploration"Investigate X" without scope, Claude reads hundreds of filesScope investigations or use subagents

Part 7: CLAUDE.md Best Practices

✅ What to Include

  • Bash commands Claude can't guess
  • Code style rules different from defaults
  • Test commands and preferred test runners
  • Repository etiquette (branch naming, PR conventions)
  • Developer environment quirks (required environment variables)
  • Common pitfalls or non-obvious behaviors

❌ What to Exclude

  • Anything Claude can figure out by reading code
  • Standard language conventions (Claude already knows)
  • Detailed API documentation (link to docs instead)
  • Frequently changing information
  • Long explanations or tutorials
  • Self-evident practices (like "write clean code")

Where CLAUDE.md Files Live

LocationScope
~/.claude/CLAUDE.mdAll Claude sessions (personal global)
./CLAUDE.mdProject root, checked into git, shared with team
./CLAUDE.local.mdPersonal project notes, add to .gitignore
subdirectory/CLAUDE.mdAuto-loaded when working with files in that directory

CLAUDE.md Maintenance Principles

  • Keep it short: every line should answer "Would deleting this cause Claude to make mistakes?"
  • If Claude keeps doing things you don't want, the file may be too long
  • Treat it like code: review, prune regularly, test whether changes actually affect behavior
  • Can import other files via @path/to/import syntax

Part 8: Choosing the Right Extension Mechanism

Claude Code has multiple extension points—which should you use?

Extension pointWhen to useLifecycle
CLAUDE.mdPersistent context: code style, commands, workflow rulesLoaded every conversation
SkillsSpecialized workflows loaded on demandLoaded when Claude auto-recognizes scenario
HooksScripts that must execute deterministically at specific pointsAuto-triggered before/after tool calls
SubagentsInvestigation/review tasks needing independent contextMain agent spawns parallel subagents
PluginsPackaged extensions published by community/teamInstalled, used on demand
MCP ServersConnect external tools and servicesPersistent connection, used during tool calls

Decision rules:

  • Need "rules loaded every conversation" → CLAUDE.md
  • Need "workflows for specific scenarios only" → Skill
  • Need "scripts that must run after file edits" → Hook
  • Need "explore lots of files without polluting main context" → Sub-agent
  • Need "community-packaged capabilities" → Plugin

Part 9: Cross-File Parallel Processing

For large migrations or analysis, distribute work across multiple parallel Claude invocations:

bash
# Pipe output to Claude for processing
git log --oneline -20 | claude -p "summarize these recent commits"

# Structured output for script consumption
claude -p "List all API endpoints" --output-format json | jq '.endpoints[]'

Use --verbose for debugging, disable in production.


Built for frontend engineers · Powered by VitePress