Claude Code Mastery: The Complete Guide
From zero to AI-powered professional in any domain. A comprehensive guide to Claude Code architecture, agents, skills, hooks, and spec-driven development.
Claude Code isn’t a coding tool. It’s a cognitive amplifier that works across every domain.
That’s the insight most people miss. They see “Code” in the name and assume it’s for developers. But Claude Code excels at any complex, multi-step task: marketing campaigns, financial analysis, sales proposals, documentation, business strategy, and yes - software development.
Part 1: Mindset Shift
Claude Code Is NOT Just for Coding
The biggest mistake: Thinking Claude Code is only for developers.
Reality: Claude Code is an AI-powered command center for:
- Marketing campaigns and copywriting
- Financial analysis and forecasting
- Sales proposals and quoting
- Data analysis and visualization
- Documentation and technical writing
- Business strategy and market research
- Content creation and SEO
- Legal document review
- Project management
- And yes, software development
Key Insight: Claude Code excels at ANY complex, multi-step task that benefits from:
- Persistent memory (remembers your project context)
- File access (reads, writes, organizes documents)
- Tool integration (connects to external services)
- Specialized expertise (domain-specific agents)
- Quality gates (automated verification)
Part 2: The Architecture
Claude Code has six components that work in layers. Understanding this architecture is the key to getting 10x results instead of 2x.
The Mental Model: Think in Layers
| Layer | Purpose | Analogy | When It’s Used |
|---|---|---|---|
| CLAUDE.md | Universal context | Company handbook | Every single interaction |
| Commands | Workflow triggers | Department procedures | When you invoke /command |
| Agents | Specialized workers | Expert consultants | When expertise is needed |
| Skills | Detailed knowledge | Training manuals | When agent needs specifics |
| Hooks | Automatic enforcement | Building fire codes | Every relevant action |
| Plugins/MCP | External connections | Phone/Internet | When external data needed |
Key Principle: Minimum Context, Maximum Performance
“The contents of your context window are the ONLY lever you have to affect output quality.”
Why this matters:
- Claude has a limited attention window (context)
- Filling it with irrelevant information = worse results
- Each component loads ONLY when needed
- This maximizes meaningful information density
The Progressive Disclosure Pattern:
- CLAUDE.md provides routing instructions (tiny)
- Commands load only for their workflow (small)
- Agents load their specific expertise (medium)
- Skills load detailed knowledge on-demand (as needed)
- Hooks run instantly, don’t consume context (zero)
Part 3: Each Component in Depth
1. CLAUDE.md - The Universal Foundation
A markdown file that loads into EVERY Claude Code session. It’s your project’s DNA.
Where It Lives:
~/.claude/CLAUDE.md # Global (all projects)
./CLAUDE.md # Project root (team shared)
./.claude/CLAUDE.md # Project config directory
./CLAUDE.local.md # Personal overrides (gitignored)
./subfolder/CLAUDE.md # Subfolder-specific context
What Goes In It (WHAT, WHY, HOW):
# Project Name
## WHAT: Technical Overview
- Tech stack and frameworks
- Project structure and architecture
- Key files and their purposes
## WHY: Project Purpose
- What this project does
- Business context
- Domain concepts
## HOW: Practical Guidance
- Build commands
- Testing procedures
- Workflow expectations
- Important warnings
Critical Best Practices:
DO:
- Keep under 300 lines (60 lines is ideal)
- Include only universally applicable instructions
- Use file:line references, not code snippets
- Point to detailed docs (progressive disclosure)
- Add emphasis keywords (“IMPORTANT”, “YOU MUST”, “NEVER”)
- Iterate and test which instructions work
DON’T:
- Auto-generate with /init (craft deliberately)
- Include code style rules (use linters via hooks instead)
- Add task-specific instructions
- Paste code examples (they become stale)
- Exceed ~200 instructions total
Why Less Is More:
Research shows LLMs can reliably follow 150-200 instructions. Claude Code’s system prompt already contains ~50. Your CLAUDE.md uses the remaining budget.
“Every line in CLAUDE.md affects every session. It’s the highest leverage point - for better or worse.”
2. Commands - Workflow Entry Points
User-triggered prompt templates that standardize complex workflows.
Where They Live:
.claude/commands/ # Project commands (team-shared)
~/.claude/commands/ # Personal commands (all projects)
Structure:
# .claude/commands/analyze-pl.md
Analyze the provided P&L statement with focus on:
1. Revenue trends and growth patterns
2. Cost structure and margin analysis
3. Seasonality detection
4. Cash flow estimation
5. Profit lever identification
Use the following skills:
- financial-statement-analysis
- seasonality-detection
- profit-lever-identification
Output a comprehensive report with visualizations.
How To Use:
/project:analyze-pl # Run project command
/user:my-personal-command # Run personal command
Real-World Command Examples:
| Command | Purpose | Domain |
|---|---|---|
/analyze-pl | P&L analysis with profit recommendations | Finance |
/forecast-cash | 12-month cash flow projection | Finance |
/review-code | Multi-stage code review | Development |
/generate-docs | Auto-generate documentation | Technical |
/seo-audit | Comprehensive SEO analysis | Marketing |
/lead-system | Build lead generation funnel | Marketing |
/create-blog | Write SEO-optimized blog post | Content |
3. Agents - Specialized Experts
Domain-specific AI personas with focused capabilities, tools, and permissions.
Where They Live:
.claude/agents/ # Project agents
~/.claude/agents/ # Personal agents
Structure:
# .claude/agents/legendary-copywriter.md
---
name: legendary-copywriter
description: Master copywriter channeling Kennedy, Halbert, Hormozi, Brunson techniques
tools: Read, Write, Edit, Bash, WebSearch, WebFetch
model: sonnet
skills: hormozi-offer-analysis, sugarman-copywriting-framework
---
You are a master copywriter trained in the techniques of:
- Dan Kennedy (direct response, urgency, offers)
- Gary Halbert (storytelling, emotion, headlines)
- Alex Hormozi (value equation, Grand Slam Offers)
- Russell Brunson (funnels, hooks, stories)
- Joe Sugarman (psychological triggers, slippery slide)
Create copy that:
- Opens loops and builds curiosity
- Addresses specific pain points
- Presents irresistible offers
- Uses social proof strategically
- Drives specific action
Provide multiple variations with A/B test recommendations.
Agent Configuration Options:
| Field | Purpose | Example |
|---|---|---|
name | Identifier (lowercase, hyphens) | data-analyst |
description | When to use this agent | Use for financial analysis |
tools | Allowed tools | Read, Write, Bash |
model | Which model to use | sonnet, opus, haiku |
skills | Auto-load these skills | skill1, skill2 |
permissionMode | Tool permissions | default, plan, bypassPermissions |
Agent Categories:
| Category | Agents | Use Cases |
|---|---|---|
| Writing & Content | legendary-copywriter, josh-writer, content-marketer, seo-specialist | Copy, blogs, content strategy |
| Business | financial-analyst, business-analyst, market-researcher, sales-engineer | Finance, strategy, sales |
| AI/LLM | llm-architect, prompt-engineer, ml-engineer | AI systems, prompts, ML |
| Frontend | frontend-developer, react-specialist, nextjs-developer | UI development |
| Backend | backend-developer, api-designer, microservices-architect | API, services |
| Data | data-analyst, data-engineer, data-scientist | Analytics, pipelines |
| Testing | test-strategy-planner, coverage-analyzer, qa-expert | Quality assurance |
| Security | security-engineer, penetration-tester, security-auditor | Security review |
| Infrastructure | cloud-architect, kubernetes-specialist, terraform-engineer | DevOps, cloud |
4. Skills - Expert Knowledge Modules
Self-contained knowledge packages that agents load on-demand. They contain:
- Detailed procedures and workflows
- Code examples and templates
- Domain-specific expertise
- Scripts and utilities
Where They Live:
.claude/skills/
├── skill-name/
│ ├── SKILL.md # Core skill definition
│ ├── scripts/ # Executable scripts
│ ├── examples/ # Usage examples
│ ├── plugins/ # Plugin integrations
│ └── references/ # Supporting docs
Structure:
# .claude/skills/hormozi-offer-analysis/SKILL.md
---
name: hormozi-offer-analysis
description: Analyze and optimize offers using Alex Hormozi's Value Equation
---
# Hormozi Offer Analysis
## The Value Equation
Value = (Dream Outcome × Perceived Likelihood) / (Time Delay × Effort & Sacrifice)
## Analysis Process
1. **Dream Outcome**: What transformation does the customer want?
2. **Perceived Likelihood**: How confident are they it will work?
3. **Time Delay**: How quickly will they see results?
4. **Effort & Sacrifice**: What must they give up?
Progressive Disclosure in Action:
Instead of loading 10,000 tokens of marketing knowledge:
- Agent sees skill description (~100 tokens)
- Decides skill is relevant based on task
- Loads SKILL.md (~1,000 tokens)
- References supporting files only if needed
- Runs scripts without loading their code
Result: Maximum expertise, minimum context consumption
Skill Folder Components: Adding Determinism
scripts/ - Deterministic Execution
Scripts provide guaranteed, repeatable behavior that Claude executes without generating code.
| Approach | Reliability | Token Cost | Speed |
|---|---|---|---|
| ”Write code to extract PDF text” | ~80% | High (generates code) | Slow |
”Run scripts/extract_text.py” | 100% | Zero (just executes) | Fast |
Key benefits:
- No generation variability - Same script, same result every time
- No context consumption - Scripts execute without loading into context
- Pre-tested - You’ve verified the script works
- Complex logic encapsulated - 500 lines of tricky code becomes one command
examples/ - Concrete Patterns
Examples show Claude exactly what good looks like. They provide:
- Input/output pairs - “Given this, produce that”
- Edge case handling - How to handle tricky situations
- Format templates - Exact structure to follow
Why examples matter:
- Claude is an in-context learner - Examples are more powerful than descriptions
- Removes ambiguity - “like this” beats “something like this”
- Testable - You can verify Claude’s output matches expected format
The Determinism Hierarchy:
| Component | What It Provides | Reliability | Context Cost |
|---|---|---|---|
| SKILL.md | Instructions | Variable (LLM interprets) | ~1,000 tokens |
| scripts/ | Execution | 100% deterministic | Zero |
| examples/ | Patterns | High (concrete reference) | ~500 tokens when loaded |
| plugins/ | Configuration | 100% deterministic | Zero |
| references/ | Deep knowledge | Variable (LLM interprets) | On-demand |
The pattern: Use scripts for critical operations, examples for output format, and SKILL.md for orchestration.
5. Hooks - Automated Guarantees
Shell commands that execute automatically at specific lifecycle points. They’re deterministic - they always run, can’t be forgotten, and complete in milliseconds.
Why Hooks Beat Instructions:
| Approach | Reliability | Speed | Context Cost |
|---|---|---|---|
| ”Please format your code” | ~70% | Slow | Uses tokens |
| Hook: prettier —write | 100% | Fast | Zero tokens |
“Hooks turn suggestions into guarantees.”
Hook Types:
| Hook | When It Runs | Use Cases |
|---|---|---|
| PreToolUse | Before tool executes | Block dangerous operations |
| PostToolUse | After tool completes | Auto-format, validate |
| PrePrompt | When user submits prompt | Load context, log activity |
| PostResponse | When Claude finishes | Verify output, notify |
| Stop | When Claude completes task | Run test suite, final checks |
Configuration:
// .claude/settings.json
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "prettier --write $CLAUDE_FILE_PATHS"
}
]
}
],
"Stop": [
{
"matcher": "*",
"hooks": [
{
"type": "command",
"command": "npm run typecheck && npm run lint"
}
]
}
]
}
}
Real-World Hook Examples:
Auto-Format Code:
# PostToolUse for Edit|Write
prettier --write $CLAUDE_FILE_PATHS
Block Sensitive Files:
# PreToolUse for Edit|Write (exit 2 = block)
if [[ "$file_path" == ".env" ]]; then exit 2; fi
Quality Gate on Completion:
# Stop hook
npm run typecheck && npm run lint && npm test
6. Plugins & MCP - External Connections
Plugins extend Claude Code with custom capabilities:
.claude/plugins/
├── lsp/ # Language Server Protocol
│ ├── typescript-lsp/
│ ├── python-lsp/
│ └── rust-analyzer/
├── marketplace/ # Official plugin marketplace
└── custom/ # Your custom plugins
MCP (Model Context Protocol) connects Claude to external tools and services:
# Add MCP server
claude mcp add github --scope user
claude mcp add obsidian --scope project
# List configured servers
claude mcp list
Popular MCP Servers:
- GitHub - PR management, issues, code review
- Obsidian - Knowledge base access
- Perplexity - Web research
- Puppeteer - Browser automation
- Sequential Thinking - Complex reasoning
Part 4: Spec-Driven Development
The Most Important Workflow
“One fix in a spec saves you 100,000 bad lines of code.”
The Error Cascade Model:
Implication: Catch errors EARLY. Review specs more than code.
Human Leverage Points:
| Review Point | Leverage | Why |
|---|---|---|
| Research review | 10x+ | Prevents architectural misunderstandings |
| Plan review | 5-10x | Catches strategy errors before coding |
| Code review | 1x | Verifies correctness (too late to pivot) |
The Three-Phase Workflow
Phase 1: Planning (spec-product-manager)
- Creates requirements.md (EARS format, user stories, acceptance criteria)
- Creates design.md (architecture, components, data models)
- Creates tasks.md (granular, executable tasks)
- User approval required at each phase
Phase 2: Implementation (spec-execution-agent)
- For each task in tasks.md:
- Validate against requirements/design
- Delegate to specialized agents
- Execute (writes, edits, tests)
- Apply quality checks
- Get user approval
- Move to next task
- One task at a time with approval gates
Phase 3: Quality Assurance (test-strategy-planner, code-reviewer)
- Quality Gates (Defaults):
- Coverage: ≥80% line, ≥75% branch
- Security: 0 critical/high vulnerabilities
- Tests: All passing
- Complexity: ≤10 per function
- Outputs: test-strategy.md, coverage-analysis.md, quality-report.md
Spec File Structure:
.claude/specs/{feature_name}/
├── requirements.md # WHAT we're building
├── design.md # HOW we're building it
├── tasks.md # STEPS to build it
├── test-strategy.md # HOW we verify it
├── coverage-analysis.md # TEST coverage report
└── quality-report.md # FINAL quality status
Why Specs Matter: Real Numbers
| Without Specs | With Specs |
|---|---|
| Code-first, fix later | Spec-first, code once |
| 5-10 iterations common | 1-2 iterations typical |
| Misaligned features | Aligned to requirements |
| ”It works” (maybe) | Verified against criteria |
| Technical debt grows | Debt prevented |
Part 5: Domain-Specific Workflows
Marketing & Copywriting
Available Resources:
- Agents: legendary-copywriter, josh-writer, content-marketer, seo-specialist, lead-generation-specialist
- Skills: hormozi-offer-analysis, sugarman-copywriting-framework, legendary-copywriters-quick-reference
- Commands: /blog, /newsletter, /social, /lead-system, /seo-audit
Example Workflow: Creating Ad Copy
- “Create Google Ads for [product]”
- legendary-copywriter activates
- Loads: hormozi-offer-analysis skill
- Loads: sugarman-copywriting-framework skill
- Agent analyzes product/offer
- Creates multiple variations using Kennedy’s urgency, Hormozi’s value equation, Sugarman’s triggers
- Outputs: 5-10 headline variations, body copy, CTA variations, A/B test recommendations
Financial Analysis
Available Resources:
- Agents: financial-analyst, data-analyst, business-analyst
- Skills: financial-statement-analysis, cash-flow-forecasting, profit-lever-identification, seasonality-detection
- Commands: /analyze-pl, /forecast-cash
Example Workflow: P&L Analysis
/analyze-pl- financial-analyst activates
- Loads analysis skills
- Analysis includes: Revenue trends, cost structure, margin analysis, seasonal patterns, working capital estimation
- Outputs: Executive summary, detailed findings with charts, 12-month forecast, actionable profit improvement plan
Software Development
Available Resources:
- Agents: frontend-developer, backend-developer, react-specialist, api-designer
- Skills: test-pyramid-designer, coverage-gap-finder, langchain-patterns
- Commands: /review-code, /test, /coverage, /quality
Example Workflow: Building a Feature
Phase 1: Planning (spec-product-manager)
- Creates requirements.md (EARS format)
- Creates design.md (architecture)
- Creates tasks.md (implementation steps)
- User approves
Phase 2: Implementation (spec-execution-agent)
- Task 1.1: Create data models → Delegates to backend-developer → User approves
- Task 1.2: Create API endpoints → Delegates to api-designer → User approves
- Continues through all tasks…
Phase 3: Quality (test-strategy-planner + coverage-analyzer)
- Generates test-strategy.md
- Runs coverage analysis
- Enforces quality gates
- Produces quality-report.md
Part 6: Best Practices
10 Rules for Claude Code Mastery
1. Be Specific, Not Vague
Bad: “Add tests”
Good: “Write unit tests for user authentication covering successful login, failed login with invalid password, and account lockout after 5 failures. Use Jest, avoid mocks, test against real database.”
2. Plan Before Coding
Always use explore → plan → code → commit:
- “Read the auth module, don’t write code yet”
- “Think hard about the best approach, create a plan”
- “Implement the plan we discussed”
- “Create appropriate commits”
3. Use Extended Thinking for Complex Tasks
think- Basic analysisthink hard- Moderate complexitythink harder- Significant complexityultrathink- Maximum thoroughness
4. Clear Context Frequently
Use /clear between unrelated tasks. Better to clear too often than too rarely.
5. Let Hooks Handle Style
Don’t waste instructions on formatting. Configure hooks instead.
6. Use Subagents for Verification
- Claude #1: Writes implementation
- /clear (or new session)
- Claude #2: Reviews with fresh perspective
- Claude #3: Makes fixes based on review
7. Provide Visual Context
For UI work, provide screenshots: design mocks, current state, expected output.
8. Reference Files Explicitly
Use: “Update src/config/database.ts to add connection pooling”
Not: “Update the database config”
9. Course Correct Early
- Press
Escapeto interrupt - Double-tap
Escapeto go back and retry - Ask for plans before implementation
10. Iterate on CLAUDE.md
- Add one guideline at a time
- Test if Claude follows it
- Remove what doesn’t work
- Add emphasis where needed
Common Pitfalls to Avoid
| Pitfall | Solution |
|---|---|
| Bloated CLAUDE.md | Keep under 300 lines |
| Skipping planning | Always explore → plan → code |
| Mixing unrelated tasks | Use /clear between tasks |
| Ignoring context limits | Monitor and clear regularly |
| Over-parallelization | Sequential for critical work |
| Auto-generating CLAUDE.md | Craft deliberately |
| Style rules in CLAUDE.md | Use hooks instead |
| Code snippets in docs | Use file:line references |
Part 7: Quick Start Guide
Day 1: Basic Setup
1. Create Your CLAUDE.md
# [Project/Team Name]
## Overview
[What this project/team does]
## Tech Stack / Tools
- [Key tools and technologies]
## Commands
- [Common commands with descriptions]
## Workflow
- [How work gets done]
- IMPORTANT: [Critical rules]
## Additional Resources
See .claude/docs/ for detailed guides
2. Create Your First Command
# .claude/commands/my-workflow.md
[Describe the workflow steps]
[Reference any agents or skills to use]
[Define expected outputs]
3. Test It
claude
/project:my-workflow
Week 1: Expand Capabilities
- Add specialized agents for your common tasks
- Configure hooks for automatic formatting and quality checks
- Create more commands for standardized workflows
Month 1: Master the System
- Implement spec-driven development
- Build your skill library
- Optimize your context (measure, remove, document)
Part 8: Reference
Essential Commands
| Command | Purpose |
|---|---|
/clear | Reset conversation |
/compact | Compress context, preserve decisions |
/resume | Continue previous session |
/rewind | Undo to previous checkpoint |
/permissions | Manage tool permissions |
/project:name | Run project command |
Keyboard Shortcuts
| Shortcut | Action |
|---|---|
Escape | Interrupt current operation |
Escape Escape | Go back, retry different approach |
Shift+Tab | Toggle auto-accept mode |
# | Let Claude update files automatically |
Tab | File path completion |
CLI Flags
| Flag | Purpose |
|---|---|
-p "prompt" | Headless mode (no REPL) |
-c | Continue most recent session |
-r "session" | Resume specific session |
--model opus | Use Opus model |
--agent name | Use specific agent |
--allowedTools | Pre-allow tools |
--mcp-debug | Debug MCP connections |
The Transformation
Before Claude Code:
- Tasks take hours/days
- Quality varies
- Knowledge silos
- Repetitive work
After Claude Code:
- Tasks take minutes
- Consistent quality
- Knowledge shared
- Automation handles repetition
Key Takeaways
- Claude Code is domain-agnostic - Use it for any complex work
- Structure enables scale - Agents, skills, commands, hooks work together
- Minimum context, maximum performance - Load only what’s needed
- Specs before code - One spec fix saves 10,000 code fixes
- Iterate on everything - CLAUDE.md, prompts, workflows
- Hooks guarantee quality - Deterministic beats hopeful
- Progressive disclosure - Details on-demand, not upfront
- Clear context often - Fresh focus beats stale history
- Be specific - Precision drives results
- Plan first - Exploration prevents rework
The businesses and professionals winning with AI aren’t the ones with the biggest budgets. They’re the ones who understand the architecture, build systematic workflows, and iterate on what works.
Claude Code is the tool. This guide is the playbook. Now go build something.
