workflows
Use Task Agent for Complex Multi-File Searches
When exploring unfamiliar codebases, use the Task tool with subagent_type=Explore instead of running Glob/Grep directly. This specialized agent handles complex searches more efficiently.
// Instead of multiple Glob/Grep commands:
// Use: "Where are API errors handled?"
// Claude will use Task(Explore) automatically
setup
Configure Custom Hooks for Your Workflow
Set up user-prompt-submit-hook to automatically lint, format, or test code before Claude commits. This ensures code quality on every change.
// In settings.json:
{
"hooks": {
"user-prompt-submit": "npm run lint && npm run format"
}
}
productivity
Parallel Tool Calls Save Time
When requesting multiple independent operations, Claude can execute them in parallel. Ask for multiple things at once instead of sequentially.
// Good: "Read utils.ts and config.ts in parallel"
// Bad: "Read utils.ts" then "Read config.ts"
workflows
Use TodoWrite for Complex Tasks
Claude uses TodoWrite to track multi-step tasks. You can see progress in real-time as tasks move from pending → in_progress → completed.
advanced
Enable Code Review Agent Proactively
The code-reviewer agent runs automatically after significant code changes. It catches bugs, security issues, and suggests improvements.
// Claude automatically invokes:
// Task(code-reviewer) after Write/Edit operations
debugging
Debug with Strategic Logging
Instead of adding console.logs everywhere, ask Claude to "add strategic debug logging" - it places logs at key decision points.
mcp
Install MCP Servers for Extended Capabilities
Model Context Protocol servers add new tools to Claude Code. Install filesystem, database, or API MCP servers for specialized tasks.
// Install filesystem MCP:
npm install @modelcontextprotocol/server-filesystem
// Configure in claude_desktop_config.json
workflows
Use Glob for File Pattern Matching
Find files by pattern with Glob tool. Much faster than bash find commands and returns results sorted by modification time.
// Find all TypeScript files in src:
Glob: "src/**/*.ts"
// Find all test files:
Glob: "**/*.test.tsx"
workflows
Grep with Context Lines
Use -A, -B, -C flags with Grep to show lines before/after matches. Essential for understanding code context.
// Show 3 lines before and after:
Grep: pattern="handleError" -C=3 output_mode="content"
workflows
Git Commit Messages Follow Convention
Claude automatically formats commit messages with emoji attribution and co-author tags. Messages focus on "why" over "what".
# Example commit message:
Add user authentication with JWT tokens
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
workflows
Read Files Before Editing
Always read a file before editing. Claude must see current content to make accurate changes. This prevents merge conflicts.
advanced
Use Heredoc for Multi-line Strings in Bash
When running git commands with long messages, use heredoc syntax for proper formatting and quotes.
git commit -m "$(cat <<'EOF'
Your commit message here.
🤖 Generated with Claude Code
EOF
)"
workflows
Chain Bash Commands with && for Dependencies
Use && to chain dependent commands. If one fails, the rest won't run. Use ; only when you don't care about failures.
# Good (stops on failure):
npm install && npm run build && npm test
# Bad (runs all regardless):
npm install; npm run build; npm test
productivity
WebFetch for Documentation
Use WebFetch to grab latest docs from official sites. Claude can read and summarize documentation pages instantly.
// Fetch Next.js docs:
WebFetch: url="https://nextjs.org/docs" prompt="Explain App Router"
debugging
Debugging Agent for Root Cause Analysis
The debugger agent specializes in finding root causes. It analyzes errors, checks recent changes, and suggests fixes.
workflows
Ask Questions with AskUserQuestion
When Claude needs clarification, it uses AskUserQuestion with multiple choice options. You can always select "Other" for custom input.
productivity
Use Specialized Tools Over Bash
Prefer Read over cat, Edit over sed, Write over echo. Specialized tools have better permissions and error handling.
// Good: Read file_path="/path/to/file"
// Bad: Bash: "cat /path/to/file"
workflows
Plan Mode for Implementation Tasks
Use ExitPlanMode after planning implementation steps. This ensures clear roadmap before coding begins.
advanced
Notebook Editing for Jupyter
Claude can edit Jupyter notebooks with NotebookEdit. Modify cells by ID or index, insert new cells, or delete existing ones.
NotebookEdit: {
notebook_path: "/path/to/notebook.ipynb",
cell_id: "abc123",
new_source: "print('Hello')"
}
advanced
Background Bash for Long-Running Tasks
Run long commands in background with run_in_background: true. Use BashOutput to check progress later.
// Start background process:
Bash: command="npm run build" run_in_background=true
// Check output later:
BashOutput: bash_id="shell-123"
debugging
Quote File Paths with Spaces
Always wrap file paths containing spaces in double quotes for Bash commands. This prevents path parsing errors.
// Good:
cd "My Documents/Projects"
// Bad:
cd My Documents/Projects
workflows
Multiline Grep for Cross-Line Patterns
Enable multiline mode in Grep to search patterns that span multiple lines. Essential for finding multi-line code blocks.
Grep: {
pattern: "interface\\{[\\s\\S]*?field",
multiline: true
}
workflows
Create Pull Requests with gh CLI
Claude uses gh pr create for pull requests. It analyzes all commits (not just latest) and generates comprehensive summaries.
gh pr create --title "Feature" --body "$(cat <<'EOF'
## Summary
- Added feature X
- Fixed bug Y
🤖 Generated with Claude Code
EOF
)"
productivity
Task Agent Types for Different Jobs
Choose the right agent: general-purpose for complex tasks, Explore for codebase navigation, coding-advisor for questions, debugger for bugs.
debugging
Avoid Interactive Git Commands
Never use git commands with -i flag (like git rebase -i or git add -i). Interactive commands are not supported.
workflows
Limit Grep Output with head_limit
Use head_limit parameter to show only first N results. Works across all output modes: content, files_with_matches, count.
Grep: {
pattern: "import",
output_mode: "files_with_matches",
head_limit: 10
}
productivity
WebSearch for Current Information
Use WebSearch to find latest news, documentation updates, or current trends. Only available in the US.
advanced
Skills for Specialized Tasks
Use Skill tool to invoke specialized capabilities like PDF processing or Excel manipulation. Skills provide domain expertise.
// Invoke PDF skill:
Skill: command="pdf"
// Invoke Excel skill:
Skill: command="xlsx"
setup
SlashCommand for Custom Workflows
Create custom slash commands in .claude/commands/ directory. Define frequently used workflows as reusable commands.
// .claude/commands/test.md
Run all tests with coverage and generate report
```bash
npm run test:coverage
```
workflows
Never Skip Git Hooks
Claude never uses --no-verify or --no-gpg-sign unless explicitly requested. Git hooks ensure code quality and security.