This comprehensive reference guide consolidates all the essential patterns, commands, and workflows from our entire conversation about Claude Code for maximum productivity and effectiveness.
Table of Contents
- Quick Start Setup
- The Three Essential Directories Pattern
- Core Commands & Modes
- Thinking Modes & Keywords
- Subagents & Parallel Processing
- Custom Slash Commands
- MCP Server Integration
- Apple Development Workflow
- Best Practice Workflows
- Testing & Quality Assurance
- Quick Reference Tables
- Troubleshooting & Tips
Quick Start Setup
Installation & Authentication
# Install Claude Code CLI
npm install -g @anthropic-ai/claude-code
# Launch Claude Code
claude
# Update to latest version
claude updateEssential First Steps
# 1. Create project memory file
touch CLAUDE.md
# 2. Initialize custom commands directory
mkdir -p .claude/commands
# 3. Create context prime command
echo "Read project files and run 'tree -I 'node_modules|.git|build|DerivedData'' to understand structure" > .claude/commands/context-prime.mdThe Three Essential Directories Pattern
Context is King Philosophy
The three directories solve the fundamental problem: your AI coding tool must have the right information at the right time to be effective[1][2][3].
1. ai-docs/ - Your AI Agent's Persistent Memory
Purpose: Think of this as your AI coding tool's persistent knowledge base[3].
What Goes Inside:
- Third-party API documentation
- Integration details and patterns
- Custom conventions specific to your codebase
- Implementation notes and gotchas
- Apple frameworks documentation (SwiftUI, UIKit, etc.)
Example Structure:
ai-docs/
├── apple-frameworks-best-practices.md
├── third-party-apis.md
├── custom-patterns.md
└── troubleshooting-guide.md2. specs/ - Your AI Coding Plans
Purpose: This is the most important folder in your entire codebase. Where you write great plans and scale up your compute[3].
Key Principle: The plan IS the prompt. Great planning equals great prompting[3].
What Goes Inside:
- Feature specifications (PRDs/Product Requirements Documents)
- Architecture plans
- UI/UX implementation specs
- Testing strategies
- Cross-platform integration requirements
Example Structure:
specs/
├── feature-user-authentication.md
├── cross-platform-sync.md
├── ui-component-library.md
└── testing-strategy.md3. .claude/ - Your Reusable Prompts
Purpose: Store reusable, runnable prompts that save time and ensure consistency[2][3].
Essential Structure:
.claude/
└── commands/
├── context-prime.md # Most important command
├── session-start.md
├── deploy-check.md
├── cross-platform-review.md
└── testflight-prep.mdCore Commands & Modes
Interactive Mode Commands
| Command | Description | Example |
|---|---|---|
claude |
Start interactive REPL | claude |
claude "query" |
Start with initial prompt | claude "explain this project" |
/help |
Show available commands | /help |
/clear |
Reset conversation context | /clear |
/cost |
Display token usage | /cost |
/model |
Switch Claude model | /model claude-sonnet-4 |
Special Key Combinations
| Key Combination | Action | Purpose |
|---|---|---|
Shift + Tab |
Enter Plan Mode | Brainstorm and outline before coding[4][5] |
Shift + Tab (twice) |
Plan → Execute | Quick transition from planning to implementation[5] |
Ctrl + R |
Verbose mode | See full context Claude is using[4] |
Escape |
Interrupt Claude | Stop current execution |
Double Escape |
Jump back in history | Navigate conversation history[4] |
Print Mode (SDK Usage)
# Run single prompt and exit
claude -p "Write a function to calculate Fibonacci numbers"
# Process piped content
cat logs.txt | claude -p "analyze these logs"
# Output in JSON format
claude -p "generate hello world" --output-format json
# Resume specific session
claude -r "session-id" "continue this task"Thinking Modes & Keywords
Thinking Budget Keywords[2][6]
| Keyword | Token Budget | Use Case |
|---|---|---|
| (none) | Minimal | Simple tasks |
| think | ~4k tokens | Moderate complexity |
| think hard | ~8k tokens | Complex problems |
| think harder | ~15k tokens | Very complex analysis |
| ultrathink | ~32k tokens | Maximum depth, hardest problems[6] |
Usage Example:
> ultrathink: Design a cross-platform authentication system for iOS, macOS, and watchOS with offline sync capabilitiesWhen to Use Each Level
- think: Standard debugging, feature planning
- think hard: Architecture decisions, complex integrations
- think harder: Performance optimization, security reviews
- ultrathink: System design, complex algorithms, critical debugging[6]
Subagents & Parallel Processing
Core Concept
Subagents enable parallel processing, context management, and specialized task delegation within a single workflow[7][4].
Key Benefits
- Parallel Processing: Multiple aspects investigated simultaneously
- Context Isolation: Each subagent has its own context window
- Specialization: Assign expert roles (security, accessibility, etc.)
- Synthesis: Main agent compiles results into coherent solution
Verification Workflow Stages
| Stage | Subagent Instruction | Example |
|---|---|---|
| Planning | "Use subagents to verify requirements are unambiguous" | Requirements validation |
| Implementation | "After each step, subagents independently verify code matches spec" | Code review |
| Testing | "Spawn agents to check edge cases and test independence" | Test validation |
| QA/Review | "Run security, performance, and accessibility agents in parallel" | Quality assurance |
| Documentation | "Subagents update docs and verify feedback is addressed" | Documentation review |
Practical Example
> Implement user authentication. Spawn 3 subagents:
> 1. Security expert to review vulnerabilities
> 2. UX expert to validate user flow
> 3. Testing expert to verify edge cases
> Consolidate findings before proceeding.Custom Slash Commands
Setup & Structure
# Personal commands (available across all projects)
~/.claude/commands/
# Project-specific commands
.claude/commands/Essential Commands to Create
1. Context Prime (Most Important)
# .claude/commands/context-prime.md
Read the following files to understand this project:
- README.md
- Package.json/Package.swift
- Main architecture files
- Any existing integration notes
Then run `tree -I 'node_modules|.git|build|DerivedData'` to understand project structure.2. Session Management
# .claude/commands/session-start.md
Initialize session and prepare work environment:
1. Check current status with git status
2. Get latest changes with git pull
3. Review previous work
4. Present today's work plan3. Apple Development Specific
# .claude/commands/cross-platform-check.md
Review this feature for compatibility across:
- iOS (iPhone/iPad)
- macOS
- watchOS
- CarPlay (if applicable)
Check for:
- Shared business logic opportunities
- Platform-specific UI adaptations
- Data synchronization requirements
- Testing strategies for each platformCommand Templates with Arguments
# .claude/commands/add-tests.md
Generate comprehensive tests for $ARGUMENTS:
- Unit tests for core functionality
- Edge case testing
- Error handling validation
- Integration test scenariosUsage: /project:add-tests UserAuthentication.swift
MCP Server Integration
What is MCP?
Model Context Protocol (MCP) connects Claude Code to external tools and data sources[8][9].
Setup Commands
# Add MCP stdio server
claude mcp add my-server -e API_KEY=123 -- /path/to/server arg1 arg2
# Add MCP SSE server
claude mcp add --transport sse api-server https://api.example.com/mcp --header "X-API-Key: your-key"
# Add MCP HTTP server
claude mcp add --transport http secure-server https://api.example.com/mcp --header "Authorization: Bearer token"
# List configured servers
claude mcp list
# Remove server
claude mcp remove my-serverScope Options
local: Available only to you in current projectproject: Shared with team via.mcp.jsonfileuser: Available across all your projects
Popular MCP Servers
- GitHub: PR review, issue management
- Sentry: Error tracking and debugging
- DigitalOcean: App deployment and management[9]
- Brave Search: Web search capabilities
- Fetch: HTTP request handling
Apple Development Workflow
Project Structure for Apple Development
your-ios-project/
├── ai-docs/
│ ├── swiftui-patterns.md
│ ├── apple-guidelines.md
│ ├── cross-platform-strategies.md
│ └── testflight-process.md
├── specs/
│ ├── ios-app-architecture.md
│ ├── watchos-companion.md
│ ├── shortcuts-integration.md
│ └── carplay-features.md
└── .claude/
└── commands/
├── context-prime.md
├── cross-platform-review.md
├── testflight-prep.md
└── shortcuts-integration.mdApple-Specific Commands
Shortcuts Integration
# .claude/commands/shortcuts-integration.md
Analyze this feature for Shortcuts app integration:
- Identify functions suitable for Shortcuts exposure
- Create Intent definitions
- Design Siri phrase patterns
- Plan voice interaction flows
- Consider MCP server integration for AI systemsTestFlight Preparation
# .claude/commands/testflight-prep.md
Prepare this build for TestFlight:
- Review app metadata and descriptions
- Check privacy permissions and usage descriptions
- Validate testing instructions
- Ensure crash reporting is configured
- Generate testing scenarios checklistCross-Platform Development
# .claude/commands/cross-platform-architecture.md
Design feature architecture for Apple ecosystem:
- Shared business logic (Core Data, CloudKit)
- Platform-specific UI adaptations
- Data synchronization strategies
- Handoff and Continuity features
- Universal app considerationsiOS Development with Claude Code
# Start new iOS project
cd YourApp
claude
# Initialize project
/project:context-prime
# Enter planning mode
# Shift + Tab
> ultrathink: Design a SwiftUI app with watchOS companion that syncs data via CloudKit
# Execute approved plan
# Shift + Tab (again to exit plan mode)Best Practice Workflows
1. Explore → Plan → Implement → Verify → Integrate
Explore Phase
> Read relevant files first before coding
> Use subagents for preliminary research
> /project:context-prime to establish baseline understandingPlan Phase
> Shift + Tab (enter Plan Mode)
> ultrathink: [complex problem description]
> Create detailed specification in specs/ directory
> Do not code until plan is approvedImplement Phase
> Use auto-accept mode for approved plans
> Reference files explicitly (@path/to/file)
> Iterate in short, focused messagesVerify Phase
> Spawn specialized subagents for validation
> Security review, performance check, accessibility audit
> Cross-platform compatibility verificationIntegrate Phase
> Consolidate insights into CLAUDE.md
> Update documentation
> Use /clear between major tasks2. Test-Driven Development (TDD) Pattern[10]
> Write failing tests first
> Generate minimal implementation
> Refactor and optimize
> Verify with subagents3. Plan Drafting Technique[3]
> Have Claude create the first draft of your plan
> Iterate and refine the plan
> Execute only after approval
> Document learnings for future referenceTesting & Quality Assurance
Testing Strategies with Claude Code
1. Comprehensive Test Generation
> Generate tests for EdgeCaseHandler.swift covering:
> - Normal operation scenarios
> - Edge cases and boundary conditions
> - Error handling and recovery
> - Performance under load
> - Integration with other components2. Test-Driven Development Workflow[10][11]
> Write failing tests based on requirements
> Implement minimal code to pass tests
> Refactor with confidence
> Use subagents to verify test quality3. Quality Assurance Checklist
- Unit tests for core functionality
- Integration tests for component interaction
- UI tests for user workflows
- Performance tests for critical paths
- Security tests for vulnerabilities
- Accessibility tests for compliance
Apple-Specific Testing
# .claude/commands/ios-testing-strategy.md
Create comprehensive testing strategy for iOS:
- XCTest unit tests for business logic
- XCUITest for user interface testing
- Performance testing with XCTMetric
- TestFlight beta testing plan
- App Store review preparationQuick Reference Tables
Essential File Structure
| File/Directory | Purpose | Required |
|---|---|---|
CLAUDE.md |
Project context and conventions | ✅ |
ai-docs/ |
Persistent knowledge base | ✅ |
specs/ |
Plans and specifications | ✅ |
.claude/commands/ |
Reusable prompts | ✅ |
.mcp.json |
MCP server configuration | Optional |
Command Categories
| Category | Commands | Purpose |
|---|---|---|
| Session | /clear, /cost, /help |
Manage conversation |
| Planning | Shift+Tab, ultrathink |
Strategy and design |
| Execution | Auto-accept mode, file references | Implementation |
| Custom | /project:*, /user:* |
Reusable workflows |
Thinking Budget Guide
| Complexity | Keyword | Token Budget | Example Use Case |
|---|---|---|---|
| Simple | (none) | Minimal | Basic CRUD operations |
| Moderate | think |
~4k | Feature implementation |
| Complex | think hard |
~8k | Architecture decisions |
| Very Complex | think harder |
~15k | Performance optimization |
| Maximum | ultrathink |
~32k | System design, critical debugging |
Troubleshooting & Tips
Common Issues & Solutions
1. Context Overflow
- Problem: Running out of context window
- Solution: Use
/clearbetween tasks, break into smaller chunks
2. Slow Performance
- Problem: Claude Code responding slowly
- Solution: Reduce context size, use more focused prompts
3. Inconsistent Results
- Problem: Variable code quality
- Solution: Use plan mode, be more specific in prompts
4. Apple Development Issues
- Problem: Cross-platform compatibility
- Solution: Use cross-platform review commands, test on all target devices
Optimization Tips
1. Token Management
- Use custom commands to reduce repetitive context loading[12]
- Keep CLAUDE.md concise and focused
- Clear context regularly with
/clear
2. Workflow Efficiency
- Start every session with
/project:context-prime - Use Plan Mode for complex features
- Leverage subagents for parallel validation
3. Quality Assurance
- Always verify plans before implementation
- Use specialized subagents for reviews
- Document learnings in
ai-docs/
4. Team Collaboration
- Share
.claude/commands/across team - Standardize CLAUDE.md format
- Use project-scoped MCP servers
Performance Monitoring
# Check token usage
claude --cost
# Monitor session performance
claude --verbose
# Review session history
claude --resume <session-id>Advanced Patterns
1. Multi-Instance Parallel Development[4]
# Use git worktrees for parallel development
git worktree add ../feature-branch feature-branch
cd ../feature-branch
claude2. Headless Automation[2]
# CI/CD integration
claude -p "run tests and generate report" --output-format json
# Batch processing
for file in *.py; do
claude -p "review and optimize $file" < "$file"
done3. Visual Development[4]
> Drag and drop screenshots into terminal
> Claude analyzes visual mockups
> Generates code matching designsThis comprehensive cheat sheet provides everything you need to master Claude Code for professional development workflows, with special emphasis on Apple ecosystem development patterns. Keep this reference handy and customize the patterns to fit your specific needs and projects[1][13][14][7][4][2][15][16][8][9][17][5][18][12][6][3][19][10][20][11].
Sources
[1] CLI reference - Anthropic API https://docs.anthropic.com/en/docs/claude-code/cli-reference
[2] Claude Code: Best practices for agentic coding - Anthropic https://www.anthropic.com/engineering/claude-code-best-practices
[3] Agentic Claude Code: 3 Codebase Folders for TOP 1% AI Coding https://www.youtube.com/watch?v=hGg3nWp7afg
[4] How I use Claude Code | Christian B. B. Houmann https://bagerbach.com/blog/how-i-use-claude-code/
[5] Yup, Claude Code Plan Mode is here: The Senior Engineer's Workflow https://www.youtube.com/watch?v=7LWl3EbcFTc
[6] The Secret Prompt To Unlock Claude Code GOD MODE - YouTube https://www.youtube.com/watch?v=ntc5O2x1IFE
[7] Anthropic Releases Best Practices Guide for Claude Code ... - AIbase https://www.aibase.com/news/www.aibase.com/news/17387
[8] Model Context Protocol (MCP) - Anthropic API https://docs.anthropic.com/en/docs/claude-code/mcp
[9] Setting Up the DigitalOcean MCP Server in Claude Code https://www.digitalocean.com/community/tutorials/claude-code-mcp-server
[10] Claude Code & Test-Driven Development: A Comprehensive Guide https://talent500.com/blog/claude-code-test-driven-development-guide/
[11] Mastering Claude Code: Essential Tips for Maximum Productivity https://www.tembo.io/blog/mastering-claude-code-tips
[12] Boost Your Development Efficiency with Claude Code Custom ... https://gizin.co.jp/en/tips/claude-code-custom-commands
[13] Claude Code overview - Anthropic API https://docs.anthropic.com/en/docs/claude-code/overview
[14] Claude Code SDK - Anthropic API https://docs.anthropic.com/en/docs/claude-code/sdk
[15] Common workflows - Anthropic API https://docs.anthropic.com/en/docs/claude-code/common-workflows
[16] Claude Code: A Complete Setup Guide and Honest Evaluation https://www.helicone.ai/blog/evaluating-claude-code
[17] Claude Code MCP Server MCP server for AI agents - Playbooks https://playbooks.com/mcp/claude-code
[18] Claude Code + MCP Setup: Late Night Tutorial ... - YouTube https://www.youtube.com/watch?v=oM2dXJnD80c
[19] How to Build an iOS App With Claude AI: A Step-by-Step Guide https://slashdev.io/-how-to-build-an-ios-app-with-claude-ai-a-step-by-step-guide
[20] How To Use Claude Code [Make Your First iOS App ... - YouTube https://www.youtube.com/watch?v=FLFfVxUUmLE
[21] Set up Claude Code - Anthropic API https://docs.anthropic.com/en/docs/claude-code/setup
[22] GitHub - anthropics/claude-code https://github.com/anthropics/claude-code
[23] How to get MCP servers running on Claude Code - Reddit https://www.reddit.com/r/ClaudeAI/comments/1iztm9b/how_to_get_mcp_servers_running_on_claude_code/
[24] Configuring MCP Tools in Claude Code - The Better Way https://scottspence.com/posts/configuring-mcp-tools-in-claude-code
[25] A Prompt for Smoother Claude Code Onboarding - Apidog https://apidog.com/blog/claude-code-onboarding-prompt
[26] The Claude Code Complete Guide: Learn Vibe-Coding & Agentic AI https://natesnewsletter.substack.com/p/the-claude-code-complete-guide-learn
[27] Best way to use Claude Projects for coding. One big file with ... - Reddit https://www.reddit.com/r/ClaudeAI/comments/1efy6yf/best_way_to_use_claude_projects_for_coding_one/