Advanced Tips & Tricks for Claude Code
After mastering the basics, here are advanced techniques that will make you significantly more productive with Claude Code.
1. Piping Input to Claude Code
Pipe command output directly to Claude Code for analysis:
# Analyze test failures
pytest tests/ 2>&1 | claude "Analyze these test failures and suggest fixes"
# Review a diff
git diff main | claude "Review this diff for potential issues"
# Analyze logs
tail -100 /var/log/app.log | claude "What errors are in these logs?"2. Headless Mode for Automation
Use the -p flag for non-interactive mode, perfect for CI/CD and scripts:
# Generate a code review
claude -p "Review the code in src/ for security vulnerabilities" > review.md
# Generate documentation
claude -p "Generate API documentation for all endpoints in routes/" > api-docs.md
# Use in a shell script
#!/bin/bash
RESULT=$(claude -p "Is there a TODO in main.py? Reply yes or no")
if [ "$RESULT" = "yes" ]; then
echo "Found TODOs!"
fi3. Resuming Conversations
Continue where you left off:
# Resume the most recent conversation
claude --resume
# Continue a specific session
claude --resume session-id4. Multi-File Editing Patterns
Claude Code excels at coordinated changes across files:
> Add a "lastLogin" field to the User model, update the migration,
update the API serializer, and add it to the admin dashboard viewClaude Code will edit all four files in a single coordinated operation.
5. Using Claude Code with Docker
# Let Claude manage Docker containers
> Build and run the Docker container, then check if the app is healthy
# Debug container issues
> The Docker container keeps crashing on startup. Check the logs and fix the issue6. Efficient Context Management
Help Claude Code work efficiently with large codebases:
- Use
/compact— When conversations get long, compact the context to free up space - Be specific about files — “Edit src/auth/login.py” is better than “Edit the login code”
- Create a good CLAUDE.md — This reduces the need for Claude to search for basic project info
7. Permission Auto-Approval
Speed up workflows by pre-approving safe commands:
# In .claude/settings.json
{
"permissions": {
"allow": [
"Bash(npm test)",
"Bash(npm run build)",
"Bash(git status)",
"Bash(git diff *)",
"Read",
"Glob",
"Grep"
]
}
}8. Claude Code in CI/CD
Integrate Claude Code into your development pipeline:
# GitHub Actions example
name: Code Review
on: pull_request
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm install -g @anthropic-ai/claude-code
- run: |
claude -p "Review the changes in this PR for bugs, \
security issues, and code quality" > review.md
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}9. Custom Slash Commands
Create reusable prompts as custom slash commands in your project’s .claude/commands/ directory:
# .claude/commands/review-component.md
Review the React component at $ARGUMENTS for:
1. Accessibility issues
2. Performance problems
3. Missing error handling
4. Proper TypeScript typesThen use it:
> /project:review-component src/components/UserProfile.tsx10. Keyboard Shortcuts
| Shortcut | Action |
|---|---|
Ctrl+C |
Cancel current operation |
Ctrl+D |
Exit Claude Code |
Up Arrow |
Cycle through previous prompts |
Escape |
Cancel current input |
Conclusion
You’ve now completed the full Claude Code tutorial series! From installation to advanced automation, you have all the tools you need to be highly productive with Claude Code. Happy coding!
Full Tutorial Series
- Introduction to Claude Code – Installation & Setup
- Your First Conversation with Claude Code
- Code Generation with Claude Code
- Debugging with Claude Code
- Refactoring Code with Claude Code
- Working with Git using Claude Code
- Writing Tests with Claude Code
- Project Configuration – CLAUDE.md & Memory
- Using MCP Servers with Claude Code
- Advanced Tips & Tricks for Claude Code
Previous: Using MCP Servers with Claude Code