TL;DR
This cheatsheet gathers professional patterns, debugging techniques, and advanced team workflows for Claude Code. Keep this practical reference sheet as a quick reference to apply the best practices daily on your existing and legacy projects.
This cheatsheet gathers professional patterns, debugging techniques, and advanced team workflows for Claude Code. Keep this practical reference sheet as a quick reference to apply the best practices daily on your existing and legacy projects.
Advanced best practices for Claude Code constitute a set of patterns, commands, and workflows that allow developers to fully leverage Anthropic's coding agent. Claude Code (version 2.1.x) has established itself as the reference tool for AI-assisted development in the terminal. A large and growing community of developers uses Claude Code daily in their professional workflows.
SFEIR Institute trainings
Claude Code Training
1 day · Fundamentals
AI-Augmented Developer
2 days · Intermediate
What are the most used advanced commands on a daily basis?
Before diving into specialized patterns, here are the commands you will use most often. Each entry works autonomously in your terminal. For a complete overview of basic commands, check the essential slash commands cheatsheet.
| Command | Description | Example | ||
|---|---|---|---|---|
claude "prompt" | Launch Claude with a direct prompt | claude "Explain this file" | ||
claude -p "prompt" | Non-interactive mode (CI scripts) | claude -p "List the TODOs" | ||
claude --resume | Resume a specific session (or pick from a list) | claude --resume | ||
claude --continue | Resume the most recent conversation | claude -c | ||
/compact | Compress context without losing it | /compact in session | ||
/init | Create a project CLAUDE.md file | /init at the root | ||
| `cat file \ | claude "prompt"` | Pass a file via stdin | `cat bug.log \ | claude "Analyze this log"` |
claude --tools | Restrict available tools | claude --tools "Edit,Read" | ||
/model | Change the model in session | /model in interactive session |
In practice, the large majority of advanced interactions rely on these 9 commands combined with specific flags.
Key takeaway: Master these 9 commands before exploring advanced patterns. They cover the majority of professional use cases.
How to structure a professional workflow with Claude Code?
A professional workflow relies on three pillars: context preparation, iterative execution, and validation. Configure your CLAUDE.md file at the project root to anchor team conventions. Check the advanced best practices tutorial for concrete configuration examples.
The "Plan -> Execute -> Validate" pattern
# Step 1: Ask for a plan
claude "Plan the refactoring of the auth module without modifying the public API"
# Step 2: Execute with constraints
claude "Implement the plan. Only modify src/auth/"
# Step 3: Validate
claude "Run the tests and verify nothing has regressed"
The "Context Loading" pattern
Load the relevant context before each complex task. Concretely, a well-prepared context noticeably reduces the number of necessary iterations.
| Pattern | When to use | Typical command | |
|---|---|---|---|
| Stdin piping | Single file to analyze | `cat src/api.ts \ | claude "Refactor"` |
/init + CLAUDE.md | Recurring project | /init then edit CLAUDE.md | |
--resume | Multi-step task | claude --resume | |
| Multi-turn | Progressive exploration | Interactive conversation | |
/compact | Context saturating | /compact in session |
To optimize your context window management, refer to the context management cheatsheet which details compression strategies.
Key takeaway: Systematically apply the Plan -> Execute -> Validate pattern to avoid regressions and keep control over modifications.
How to debug effectively with Claude Code?
Debugging with Claude Code relies on a methodical approach: isolate, reproduce, fix, verify. Claude Code often resolves common bugs on the first iteration when sufficient context is provided.
Essential debugging commands
| Command | Usage | Concrete example | |
|---|---|---|---|
| `cat error.log \ | claude "Diagnose"` | Analyze an error log | Identify a stack trace |
claude "Why does this test fail?" | Targeted diagnosis | From the test directory | |
claude "Add debug logs to fn()" | Temporary instrumentation | Trace an execution flow | |
claude "Fix the bug and run the tests" | Fix + validation in one prompt | Fix with verification | |
/compact (in session) | Reset/compress polluted context | When Claude loops |
The augmented "Rubber Duck" pattern
Describe the expected vs. observed behavior in your prompt. This technique noticeably reduces resolution time.
claude "The /api/users endpoint returns 500.
Expected behavior: list of users in JSON.
Observed behavior: TypeError: Cannot read property 'map' of undefined.
The file is src/routes/users.ts"
Always verify proposed fixes by running tests. If Claude Code loops on an error, use /compact to reset the context, then rephrase your request with more details. To avoid classic debugging pitfalls, the common mistakes article lists the anti-patterns to know.
Keyboard shortcuts for debugging
| Shortcut | Action | Context |
|---|---|---|
Ctrl+C | Interrupt the current generation | When Claude goes the wrong direction |
Ctrl+D | Exit the session | End of debug session |
Up arrow | Recall the last prompt | Iterate on a fix |
Escape | Cancel the current edit | Correct a prompt |
Key takeaway: Always provide both the expected AND observed behavior in your debug prompts. This is the factor that most improves the resolution rate.
How to work on existing projects and legacy code?
Integrating Claude Code on an existing project requires a progressive approach. Start with an exploration phase before any modification. In practice, a short investment in context preparation prevents lengthy corrections later.
Phase 1: Exploration and understanding
# Understand the architecture
claude "Analyze the structure of this project and identify the patterns used"
# Map the dependencies
claude "List the main dependencies and their versions"
# Identify technical debt
claude "Which files have the highest cyclomatic complexity?"
Phase 2: CLAUDE.md configuration
Create a CLAUDE.md file adapted to the legacy project. This file guides Claude Code in respecting existing conventions.
# CLAUDE.md - Legacy Project
## Conventions
- Style: camelCase for variables, PascalCase for classes
- Tests: Jest, minimum coverage 80%
- Do NOT modify files in /vendor and /legacy-core
## Architecture
- Express.js monolith with progressive migration to NestJS
- PostgreSQL 15 database, Sequelize ORM
For projects using Git, the Git integration cheatsheet shows you how to combine Claude Code with your branching and code review workflows.
Phase 3: Safe modifications
| Strategy | Description | Command |
|---|---|---|
| Targeted refactoring | Modify one single module at a time | claude "Refactor only src/utils.ts" |
| Tests first | Write tests before refactoring | claude "Write tests for auth.ts, then refactor" |
| Limited scope | Restrict available tools (use --add-dir / deny rules to limit file access) | claude --tools "Edit,Read" |
| Incremental review | Verify each change | git diff after each step |
many consider legacy code refactoring their most time-consuming task. Claude Code can substantially reduce this time, especially on large codebases.
Key takeaway: Never launch Claude Code on a legacy project without CLAUDE.md. This file is your safety net against unwanted modifications.
How to work as a team with Claude Code?
Teamwork with Claude Code requires shared conventions and rigorous permission management. Establish a versioned CLAUDE.md file in Git so each team member benefits from the same context. For fine-grained permission management in shared environments, check the permissions and security cheatsheet.
Team configuration
.claude/settings.json, versioned in Git:
{
"permissions": {
"allow": ["Read", "Glob", "Grep"],
"deny": ["Bash(rm *)", "Bash(git push --force)"]
},
"model": "claude-sonnet-4-6"
}
Collaboration patterns
| Pattern | Description | Benefit |
|---|---|---|
| Shared CLAUDE.md | Versioned team conventions | Output consistency |
| Centralized settings.json | Uniform permissions | Enhanced security |
| Pre-commit hooks | Automatic validation | Constant quality |
| Prompt templates | Standardized prompts per task | Reproducibility |
| Cross-review | One dev reviews Claude outputs | Error detection |
Conflict and branch management
Run Claude Code on isolated feature branches to avoid conflicts. Concretely, a team using Claude Code on separate feature branches reduces merge conflicts.
# Recommended team workflow
git checkout -b feature/refactor-auth
claude "Refactor the authentication module according to the JIRA-1234 ticket specs"
git add -p # Selective review of changes
git commit -m "refactor(auth): simplify token validation"
To master the basics before collaborating, the first conversations cheatsheet covers the fundamentals of interacting with Claude Code.
Key takeaway: Always version the CLAUDE.md and settings.json in Git. This is the key to homogeneous Claude Code usage across the team.
What are the advanced shortcuts and flags to know?
Beyond basic commands, Claude Code offers flags and options that accelerate professional workflows. The installation and first launch cheatsheet covers the initial setup of these options.
Advanced CLI flags
| Flag | Description | Example |
|---|---|---|
--print / -p | Non-interactive mode, prints and exits | claude -p "Count the lines" |
--output-format json | Structured JSON output | claude -p --output-format json "..." |
--max-turns N | Limit the number of agentic exchanges | claude -p --max-turns 5 "..." |
--model | Choose the model (opus, sonnet) | claude --model opus "Analyze..." |
--tools | Restrict authorized built-in tools | claude --tools "Edit,Read" |
--allowedTools | Pre-approve specific permission rules (run without prompting) | claude --allowedTools "Bash(git log *)" "Read" |
--verbose | Display execution details | claude --verbose |
--debug | Debug logs by category | claude --debug "api,mcp" |
--effort | Effort level (low, medium, high, xhigh, max, plus ultracode); also set in session with /effort | claude --effort xhigh |
--resume | Resume a specific session by ID/name or open the picker | claude --resume |
In-session slash commands
| Command | Action | Use case |
|---|---|---|
/compact | Compress the context | Long session, saturated context |
/init | Generate CLAUDE.md | New project |
/config | Open settings | Adjust the model |
/cost | Display consumption | Budget tracking |
/clear | Reset the conversation | New topic |
/help | Display help | Discover options |
/debug | Display debug info | In-session diagnostic |
/context | Visualize current context | Understand what Claude sees |
/diff | Display modifications | Review changes |
In practice, using the --max-turns flag with a value between 3 and 10 lets you control costs while giving Claude Code enough autonomy to solve complex problems. Session cost depends on context size and the number of turns; monitor it with /cost or /usage.
Key takeaway: Combine CLI flags (--max-turns, --allowedTools) to maintain full control over Claude Code's behavior in production.
How to evaluate and improve your practices with Claude Code?
Evaluating your practices involves concrete metrics and continuous improvement. The complete advanced best practices guide deepens each pattern presented in this cheatsheet.
Track A self-assessment grid
| Skill | Beginner level | Intermediate level | Advanced level |
|---|---|---|---|
| Prompting | Vague prompts, random results | Structured prompts with context | Prompt engineering with constraints and examples |
| Debugging | Copy-pasting raw errors | Expected/observed context provided | Automated debug pipeline |
| Legacy | Launching Claude without preparation | Basic CLAUDE.md | Detailed CLAUDE.md + limited scope |
| Team | Individual use only | Shared settings.json | Integrated CI/CD workflow |
| Context | /compact never used | Occasional compression | Context management strategy |
Progression checklist
- Verify that your CLAUDE.md contains at least code conventions, architecture, and protected files
- Use the Plan -> Execute -> Validate pattern on every task over 30 minutes
- Measure your first-prompt resolution rate and aim to improve it over time
- Apply tool restrictions (
--tools) on sensitive projects - Practice structured debugging with the expected/observed format
- Share your CLAUDE.md and settings.json via Git
- Monitor your costs with
/costafter each session
developers who follow structured training tend to be significantly more productive than those who learn on their own. The advanced best practices FAQ answers the most common questions about optimizing these workflows.
Key takeaway: Regularly evaluate your practices with this grid. The goal is to reach the advanced level on all 5 skills as quickly as your practice allows.
How to go further with structured training?
To transform this knowledge into lasting skills, SFEIR Institute offers training programs dedicated to AI-assisted development. These programs combine theory and practice on real projects.
The Claude Code one-day training lets you master all the patterns presented in this cheatsheet, with hands-on labs on concrete debugging and refactoring cases. If you want to go further, the AI-Augmented Developer 2-day training covers the complete integration of AI tools into your daily workflow, including Claude Code, Copilot, and advanced prompt engineering techniques.
For developers already comfortable with the basics, the AI-Augmented Developer - Advanced one-day training deepens CI/CD automation patterns, large-scale legacy code work, and team strategies with AI tools.
Key takeaway: Invest in structured training to accelerate your skill development. SFEIR Institute hands-on labs cover the real-world cases you will encounter in production.
Recent articles about Claude

Claude Managed Agents: Anthropic's Platform for Production Agent Deployment
Anthropic launches Managed Agents: a cloud platform for deploying AI agents in production. Secure sandbox, checkpointing, multi-agent, autonomous sessions lasting hours. Notion, Rakuten, Asana and Sentry already use it.

Claude Code Dream & Auto Dream: Automatic Memory Consolidation
After 20 sessions, Auto Memory notes become a mess. Auto Dream solves this by automatically consolidating Claude Code's memory: deduplication, stale entry removal, relative-to-absolute date conversion.

Claude Code Auto Mode: Autonomy Without the Risk
Auto Mode in Claude Code eliminates permission interruptions while keeping a safety net. A classifier analyzes every action before execution and blocks destructive operations. The sweet spot between approving everything and letting everything through.
Claude Code Training
Master Claude Code fundamentals in 1 day with our expert instructors. 60% hands-on practice on real-world cases.
Discover the training