agents101 · Best Practices

Start from Scratch, Get Going Fast

Install, configure, and understand core concepts — your Claude Code onboarding in one page

Installation & Authentication

macOS
brew install --cask claude-code
Windows
# First install Node.js LTS (nodejs.org) 
npm install -g @anthropic-ai/claude-code
Linux(fnm recommended for Node)
curl -fsSL https://fnm.vercel.app/install | bash
fnm install --lts && fnm use --lts
npm install -g @anthropic-ai/claude-code
node --version  # Requires v18+
claude --version

Launch Options

# Start an interactive session in your project
cd your-project && claude

# Start with a question
claude "Explain the project architecture"

# Pipe input
cat error.log | claude "Analyze the error"

Three Auth Methods

MethodUse CaseSteps
Claude.ai AccountPro/Max subscribersRun claude, then OAuth in browser
Team InviteTeam admin inviteAccept invite, key auto-generated
Manual API KeySelf-purchased API credits / third-party proxyPaste key starting with sk-ant-...

Environment Variables

For manual API keys or third-party proxies, fine-tune behavior via environment variables. Add to ~/.zshrc or ~/.bashrc:

# === Auth & Endpoints ===
export ANTHROPIC_AUTH_TOKEN="sk-your-api-key"        # API key
export ANTHROPIC_BASE_URL="https://your-proxy.example.com"  # Custom endpoint (third-party proxy) 

# === Model Selection ===
export ANTHROPIC_MODEL="claude-sonnet-4-6"            # Default model
export ANTHROPIC_SMALL_FAST_MODEL="claude-haiku-4-5"  # Lightweight fast model for quick tasks
export ANTHROPIC_DEFAULT_SONNET_MODEL="claude-sonnet-4-6"
export ANTHROPIC_DEFAULT_OPUS_MODEL="claude-opus-4-7"

# === Performance & Behavior ===
export API_TIMEOUT_MS="3000000"                       # API timeout (ms) 
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1     # Disable non-essential network requests (telemetry etc.) 
export CLAUDE_CODE_AUTO_COMPACT_WINDOW=1000000        # Auto-compaction trigger threshold (tokens) 
VariableDescriptionTypical
ANTHROPIC_AUTH_TOKENAPI keysk-ant-...
ANTHROPIC_BASE_URLCustom API endpointThird-party proxy URL
ANTHROPIC_MODELDefault modelclaude-sonnet-4-6
ANTHROPIC_SMALL_FAST_MODELLightweight fast modelclaude-haiku-4-5
API_TIMEOUT_MSAPI timeout3000000
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFICDisable telemetry & non-essential requests1
CLAUDE_CODE_AUTO_COMPACT_WINDOWAuto-compaction threshold (tokens)1000000

After installing, run /doctor to check your environment: Node.js v18+, auth status, tool availability.

Quick Start Path

After installing, 5 steps from zero to productive:

  • 1 Write CLAUDE.md — Create an instruction file at project root with rules and preferences. Keep it < 200 lines — compliance drops significantly beyond that.

  • 2 Pick Permission Mode — Daily use default, trusted environments acceptEdits, CI/automation bypassPermissions.

  • 3 Learn /compact — Proactively compact when context reaches 50% to maintain smart output quality.

  • 4 Plan with /plan — For complex tasks, state the goal first, let the model plan steps, then confirm before executing.

  • 5 Configure Skills & Hooks — Encapsulate repetitive workflows as Skills, automate lifecycle events with Hooks.

Follow the “Bitter Lesson”: don’t optimize workflows for today’s model — build systems for the stronger models 6 months from now.

10 Power-ups

Interactive courses introduced in v2.1.90 that teach features most people overlook. Run /powerup to start.

Power-ups Menu

Power-ups selection menu

#Power-upWhat You Learn
1Talk to your codebase@ file references, line-number refs
2Steer with modesShift+Tab toggle plan / auto modes
3Undo anything/rewind undo, Esc-Esc interrupt
4Run in the backgroundBackground tasks, /tasks management
5Teach Claude your rulesCLAUDE.md Project rules, /memory management
6Extend with toolsMCP External tool extensions, /mcp
7Automate your workflowSkills Skills system + Hooks automation
8Multiply yourselfSubagents Subagent parallelism, /agents
9Code from anywhere/remote-control remote control, /teleport
10Dial the model/model switch models, /effort adjust reasoning

Each Power-up includes animated demos. Start from #1 and work through them sequentially.

Three Levels to Master Claude Code

LevelAnalogyCharacteristicsOutput Stability
Level 1 PromptingAsking a stranger on the streetAnswers vary each time, quality fluctuatesLow
Level 2 AgentHiring a domain expertFixed role + method, output is stable and controllableMedium-High
Level 3 SkillGiving the expert a training manualPrecise instructions + tool permissions, reusableHigh
  • Level 1 Prompting — Ask questions like a chat. After launching claude, just type your question — good for quick Q&A, brainstorming, doc editing. Downside: same question may get different answers each time.

  • Level 2 Agent — Assign Claude a role and method. Like hiring an expert — same task, same approach, stable and controllable output quality.

  • Level 3 Skill — Equip the Agent with specific capabilities — as precise as a training manual. One Agent can use multiple Skills, and one Skill can be reused by multiple Agents.

Learning tip: Start with Level 1 to get familiar with interactions, then progressively use Agents and Skills to increase automation.

CLI Args Reference

ParamDescriptionExample
--modelSpecify modelclaude --model opus
-pNon-interactive modeecho "hi" | claude -p
--output-formatOutput format text/json/stream-json-p --output-format json
--max-turnsMax conversation turns--max-turns 5
--permission-modePermission mode--permission-mode plan
--resumeResume previous sessionclaude --resume
--continueContinue previous sessionclaude --continue
--effortReasoning effort--effort high

Community Workflows & Plugins

The open-source community has contributed many Claude Code workflows and plugin collections, sorted by GitHub Stars:

ProjectStarsDescriptionACS
Superpowers216kFull-process methodology: brainstorming → TDD → code review → branch0014
Everything Claude Code204kLargest community collection, 300+ skills covering plan/review/security/e2e63121300+
Matt Pocock Skills115kBy TypeScript expert: TDD, diagnostics, architecture improvements, PRD0028
Spec Kit108kGitHub official: spec → clarify → plan → tasks → implement090
gstack106kBy YC president: CEO/Eng/Design multi-role review → ship0061
Get Shit Done64kEnd-to-end delivery: spec → plan → execute → validate → ship33670
OpenSpec52kLightweight spec workflow: propose → apply → verify → archive090
BMAD-METHOD49kProduct-driven development: brief → PRD → architecture → stories → QA6042
oh-my-claudecode36kTeam collaboration flow: team plan → PRD → exec → verify → fix19039
agent-skills27kBy Google engineer: spec → plan → build → test → ship3721
Compound Eng19kCompound engineering: strategy → brainstorm → plan → compound47439
HumanLayer11kResearch→implement flow: research → plan → validate → implement6270

A=Agents · C=Commands · S=Skills. Click project names to visit GitHub.

Skill Repositories

ProjectStarsSkillsDescription
anthropics/skills145k17Official Anthropic collection
mattpocock/skills113k25High-quality TypeScript skills
wshobson/agents36k155Multi-scenario skill collection
scientific-agent-skills27k143For academic research
agent-skills27k21by a Google engineer
awesome-agent-skills24k1,424+Curated collection
claude-skills15k246Full-stack coverage across 9 domains

Agent Repositories

ProjectStarsAgentsDescription
agency-agents107k144Large agent definition library
awesome-subagents21k156Curated subagent collection

Cross-Model Routing

Route Claude Code’s API to other model providers:

ProjectStarsBridgeDescription
claude-code-router34kOpenRouter, DeepSeek, Ollama, Gemini, etc.Choose models per task
CLIProxyAPI32kGemini CLI, Codex, Claude CodeWraps as compatible API
codex-plugin-cc18kCodex / GPT-5Official OpenAI plugin: /codex:review
pal-mcp-server12k50+ modelsMulti-model MCP server

Command → Agent → Skill

Understand Claude Code's three-layer orchestration architecture and core component relationships

Command → Agent → Skill Architecture

Agent Command Skill Architecture

Command → Agent → Skill three-layer architecture

User input / command trigger


┌──────────────┐    Command (entry point) 
│  /command    │    .claude/commands/*.md
└──────┬───────┘
       │ Agent tool

┌──────────────┐    Agent (executor) 
│  Agent       │    .claude/agents/*.md
└──────┬───────┘
       │ Preload/invoke Skill

┌──────────────┐    Skill (knowledge) 
│  Skill       │    .claude/skills/*/SKILL.md
└──────────────┘
  • Command — User entry point. Orchestrates Agent call order. 82 built-in custom

  • Agent — Independent context executor. Can run in parallel. 5 built-in custom

  • Skill — Reusable instruction pack. Loaded or invoked. 10 built-in custom

Comparison

DimensionCommandAgentSkill
RoleEntry / OrchestratorExecutorKnowledge Provider
ContextShared main sessionIndependent windowInjected into caller
TriggerUser /cmdAgent toolPreloaded/Skill tool
ParallelismSequentialParallel capableN/A
Dynamic context injection✅ “!`command```✅ “!`command```
Best forWorkflow orchestrationFocused tasksReusable instructions

Decision guide: Need to orchestrate multi-step flows chaining multiple Agents → Command. Need independent context, parallel execution, tool isolation → Agent. Need reusable instruction packs loaded across scenarios → Skill.

Agent Command Skill Comparison

Relationships and use cases

Why Harness Matters

Output quality formula: quality = f(effective_context, model_capability, iteration_loops) Harness directly impacts “effective context” and “iteration loops”.

Harness: 10 Core Capabilities

“Skills, Commands, Subagents all become prompts in the end, so strong prompts are enough?” — Technically true, practically false. Here’s what Harness does at layers prompts can’t reach:

#CapabilityWhat It DoesWhy Prompts Can’t Replace It
1Context IsolationSubagents run in independent context windowsOne prompt fills one window; N parallel subagents = N× effective context
2Tool Restriction Enforcementallowed/disallowed-tools intercept before model callsPrompt instructions are advisory; Deny rules are unbypassable
3Lazy-loaded Rules & Memorypaths: frontmatter and sub-directory CLAUDE.md load on demandPrompts are static; can’t dynamically load based on runtime file paths
4Deterministic Hook ExecutionShell commands fire on lifecycle events, can intercept tool callsPrompts can’t intercept their own tool calls; Hooks execute regardless of model intent
5Model Routingmodel: haiku/opus routes to different model endpointsNo token in a prompt can change which model responds
6Parallel SchedulingMultiple subagents execute concurrentlyPrompts are sequential; Harness schedules parallel processes and collects results
7Cross-session PersistenceMemory system and Settings layers persist across sessionsPrompts vanish when the session ends
8Modular System PromptsCLI conditionally loads 110+ system prompt fragmentsUsers can’t hand-write or replace internal CLI prompt fragments
9Skill Preloadingskills: field injects full content into subagent initial contextOnly the Harness loader can pre-fill another agent’s context
10Permission Classifierauto mode uses background classifier to pre-approve or block tool callsA prompt can’t add a pre-execution safety layer to itself
User Input vs What the Model Actually Sees
User input: "Write a recursive flatten function"     ← (a) ~6 tokens

What the model actually sees:                       ← (b) ~15,000 tokens
  ├── CLAUDE.md (Project specs)
  ├── Matched .claude/rules/*.md (paths trigger)
  ├── Modular system prompt fragments (110+)
  ├── Tool definitions
  ├── Environment context (cwd, git status, platform)
  ├── Previous conversation turns
  ├── Files read via Read/Grep
  └── User's 6-token request

Output quality depends on (b), not (a). Harness builds (b). "Strong prompts" can't replicate (b) because most of it isn't written by the user.

Subagents

5 Built-in Types

TypeModelToolUse Case
general-purposeinheritAll toolsDefault agent, handles general tasks
ExplorehaikuRead-only (Read/Grep/Glob, etc.)Fast code search and navigation
PlaninheritRead-onlyArchitecture research and solution design
statusline-setupsonnetRead + EditConfigure statusline settings
claude-code-guidehaikuGlob/Grep/Read/WebFetch/WebSearchAnswer Claude Code-related questions

Custom Agent Frontmatter (16 Fields)

Expand all 16 fields
FieldDescription
nameAgent identifier
descriptionTrigger condition ("PROACTIVELY" = auto)
toolsAllowed tools (comma-separated)
disallowedToolsDisallowed tools
modelhaiku/sonnet/opus/inherit
permissionModeacceptEdits/plan/bypassPermissions
maxTurnsMax turns
skillsPreloaded skills list
mcpServersMCP servers
hooksLifecycle hooks
memoryuser/project/local
backgroundRun in background
effortReasoning effort
isolation"worktree" Git isolation
colorCLI color

Commands System (82 Built-in)

Claude Code has 82 built-in slash commands, organized into 11 categories. Custom commands go in .claude/commands/*.md.

CategoryCountKey Commands
Auth5/login /logout /setup-bedrock /setup-vertex /upgrade
Config15/config /theme /permissions /sandbox /statusline /tui /voice /focus /color /keybindings /privacy-settings /radio /scroll-speed /stickers /terminal-setup
Context7/context /usage /cost /stats /insights /status /usage-credits
Debug7/doctor /feedback /heapdump /help /powerup /release-notes /tasks
Export2/copy /export
Extensions9/agents /chrome /hooks /ide /mcp /plugin /reload-plugins /reload-skills /skills
Memory1/memory
Model6/model /effort /fast /plan /ultraplan /passes
Project7/add-dir /diff /init /review /security-review /team-onboarding /ultrareview
Remote10/remote-control /teleport /desktop /mobile /schedule /autofix-pr /install-github-app /install-slack-app /remote-env /web-setup
Session13/clear /compact /resume /rewind /branch /goal /background /btw /rename /recap /stop /workflows /exit
View all 82 commands with details

Auth (5)

CommandDescription
/loginLog in to Anthropic account
/logoutLog out
/setup-bedrockConfigure Amazon Bedrock auth (requires CLAUDE_CODE_USE_BEDROCK=1)
/setup-vertexConfigure Google Vertex AI auth (requires CLAUDE_CODE_USE_VERTEX=1)
/upgradeUpgrade to a higher plan

Config (15)

CommandDescription
/configOpen settings UI (alias /settings)
/themeToggle color theme, supports custom and colorblind modes
/permissionsManage tool permission allow/ask/deny rules (alias /allowed-tools)
/sandboxToggle sandbox mode
/statuslineConfigure status line
/tuiToggle terminal render mode (default or fullscreen)
/voiceVoice dictation (hold/tap/off)
/focusToggle focus view, showing only the last prompt and response
/colorSet prompt bar color
/keybindingsOpen keybindings config file
/privacy-settingsPrivacy settings (Pro/Max)
/radioOpen Claude FM lo-fi radio
/scroll-speedAdjust scroll speed
/stickersOrder Claude Code stickers
/terminal-setupConfigure terminal shortcuts (Shift+Enter, etc.)

Context (7)

CommandDescription
/contextVisualize current context usage
/usageSession cost and usage stats (aliases /cost, /stats)
/insightsGenerate session analytics report
/statusCheck version, model, connection status
/usage-creditsConfigure overage credits

Debug (7)

CommandDescription
/doctorDiagnose installation and config issues
/feedbackSubmit feedback or report bugs (aliases /bug, /share)
/heapdumpGenerate heap memory snapshot
/helpShow help
/powerupInteractive courses, 10 Power-ups
/release-notesInteractive version picker to view changelogs
/tasksManage background tasks (alias /bashes)

Export (2)

CommandDescription
/copyCopy last response to clipboard, code block selector when available
/exportExport conversation as plain text

Extensions (9)

CommandDescription
/agentsManage agent configs
/chromeConfigure Claude in Chrome
/hooksView hooks config
/ideManage IDE integrations
/mcpManage MCP servers
/pluginManage plugins
/reload-pluginsReload all plugins
/reload-skillsReload skills directory
/skillsList available skills

Memory (1)

CommandDescription
/memoryEdit CLAUDE.md, toggle auto-memory

Model (6)

CommandDescription
/modelSwitch model, use arrow keys to adjust effort
/effortSet reasoning effort (low/medium/high/xhigh/max/ultracode)
/fastToggle fast mode
/planEnter plan mode
/ultraplanDraft and review plans in browser
/passesShare free usage weeks

Project (7)

CommandDescription
/add-dirAdd working directory
/diffInteractive diff viewer with per-turn browsing
/initInitialize CLAUDE.md (CLAUDE_CODE_NEW_INIT=1 for interactive)
/reviewLocal PR review
/security-reviewSecurity review of staged changes
/team-onboardingGenerate team onboarding guide from usage history
/ultrareviewCloud deep multi-agent PR review

Remote (10)

CommandDescription
/remote-controlAllow remote control from claude.ai (alias /rc)
/teleportPull web session to terminal (alias /tp)
/desktopContinue in desktop app (alias /app)
/mobileDownload mobile app (aliases /ios, /android)
/scheduleCreate scheduled tasks (alias /routines)
/autofix-prMonitor PRs and auto-fix CI failures
/install-github-appInstall GitHub Actions app
/install-slack-appInstall Slack app
/remote-envConfigure default remote env for web sessions
/web-setupConnect GitHub to Claude Code on the web

Session (13)

CommandDescription
/clearNew conversation (aliases /reset, /new)
/compactCompact context (optional focus instruction)
/resumeResume historical session (alias /continue)
/rewindRoll back to previous state (aliases /undo, /checkpoint)
/branchCreate session branch (alias /fork)
/goalSet persistent goal conditions
/backgroundSwitch to background (alias /bg)
/btwAsk a side question without adding to conversation
/renameRename session
/recapGenerate session recap
/stopStop background session
/workflowsView, pause, resume workflows
/exitExit (alias /quit)

Custom commands: Place in .claude/commands/*.md, supports 16 frontmatter fields (name, description, argument-hint, arguments, context, etc.). Use “!`command``` for dynamic context injection.

Orchestration Patterns

Orchestration Workflow

Weather Reporter full orchestration flow animation

User: /weather-orchestrator


┌──────────────────────────┐
│  weather-orchestrator    │  ← Command (entry point) 
│  1. Ask temperature unit C/F   │
│  2. Call weather-agent   │
│  3. Call svg-creator     │
└──────┬───────────────────┘

┌──────────────────────────┐
│  weather-agent           │  ← Agent
│  preload: weather-fetcher │  ← Skill (preloaded) 
└──────┬───────────────────┘

┌──────────────────────────┐
│  weather-svg-creator     │  ← Skill (invoked) 
│  output: weather.svg         │
└──────────────────────────┘

Tasks System

Claude Code’s built-in task tracking system supports creation, querying, updates, and dependency management. Works with Subagents and Skills.

4 Core Tools

ToolFeatureKey Params
TaskCreateCreate tasksubject, description, addBlocks, addBlockedBy
TaskListList all tasks(no params)
TaskGetGet task detailstaskId
TaskUpdateUpdate task statustaskId, status, subject, description, addBlocks, addBlockedBy

Task Lifecycle

pending → in_progress → completed
                 ↘ deleted

Dependencies

  • addBlocks — Marks “specified task cannot start until this task completes”
  • addBlockedBy — Marks “this task must wait for specified task to complete before starting”
  • Forms a DAG (Directed Acyclic Graph), ensuring execution order

Environment Variable: CLAUDE_CODE_TASK_LIST_ID identifies current task list, file persisted in ~/.claude/tasks/.

Skills & Hooks

Reusable instruction packs + lifecycle event automation scripts

Skills System

Key insight: A Skill is a folder (not just a Markdown file). It can contain scripts, data, resources, config templates — anything an Agent can discover, read, and manipulate. SKILL.md is the entry point, but not the whole picture. See Orchestration for a real example.

Skills live in .claude/skills/<name>/SKILL.md with auto-discovery and triggering. At session start, Claude scans all available skill description fields to match the current task.

  • Progressive Info Loading — Tell Claude what files are in the folder via SKILL.md; it reads details only when needed. Avoids loading all info at once and wasting context.

  • Description Is for the Model — The description field isn’t a summary — it’s a trigger condition description. Write clearly “when should this skill be used,” and Claude auto-matches accordingly.

9 Config Patterns

TypeTriggerUse Case
SlashUser types /nameCommon operations
AutoClaude auto-matchesAuto-triggered by description
PathWhen operating on matching filespaths: "*.tsx"
ForkIsolate subagentcontext: fork
ArgsCall with argumentsarguments: filename
DisabledNo auto-triggerdisable-model-invocation: true
HiddenBackground knowledge onlyuser-invocable: false
PermittedActive when enabledallowed-tools
ModelRun with specified modelmodel: haiku

2 Loading Modes

  • Preload Mode (Agent Skills) — Loaded via Agent’s skills: field. Auto-injected at Agent startup.

  • Invoke Mode (Invoked Skills) — Triggered via Skill tool or /skill-name. Claude can also auto-match and invoke.

9 Usage Categories

Distilled from hundreds of internal Anthropic skills (Thariq, 2026.03). A good skill belongs to one category; skills spanning multiple usually need splitting.

#TypeDescriptionTypical Example
1Library & API ReferenceTeach Claude to use specific libraries/CLIs/SDKs correctly, with code snippets and common pitfallsbilling-lib, frontend-design
2Product VerificationDescribe how to test/verify code correctness, often with Playwright, tmuxsignup-flow-driver, checkout-verifier
3Data Fetching & AnalysisConnect to data/monitoring stack with credentials, dashboard IDs, query templatesfunnel-query, grafana
4Business ProcessAutomate repetitive workflows into a single command; persistent logs help the model stay consistentstandup-post, weekly-recap
5Code ScaffoldingGenerate framework scaffolding, handling natural-language needs that pure code can’t covernew-migration, create-app
6Code Quality & ReviewEnforce code standards and reviews; can auto-run via Hooks or GitHub Actionsadversarial-review, code-style
7CI/CD & DeploymentPull, push, deploy code; can reference other skills for data collectionbabysit-pr, deploy-service
8RunbooksReceive symptoms → multi-tool investigation → structured reportservice-debugging, oncall-runner
9Infrastructure OpsOps actions (some destructive), needs guardrailsresource-orphans, cost-investigation
9 Skill Design Tips (Thariq)
  1. Don't state the obvious — Claude already knows a lot; focus on info that changes its default behavior
  2. Build a Gotchas section — highest-signal content, accumulated from common failure points
  3. Use the filesystem for progressive loading — tell Claude what's in the folder; it reads on demand
  4. Avoid forcing a route — give goals and constraints, not steps
  5. Think through Setup — use config.json for config; when unset, let Claude ask via AskUserQuestion
  6. Description Is for the Model — Write "when to trigger" not "what to do"
  7. Use Agent Skills for complex flows — preload into Agent, isolated context
  8. Skills can reference other Skills — but avoid circular dependencies
  9. Iterate continuously — extract Gotchas from failure cases, update skills

16 Frontmatter Fields

Expand full list
FieldTypeDescription
namestringDisplay name and /slash identifier
descriptionstringFeature description (for auto-discovery)
when_to_usestringTrigger phrases and examples
argument-hintstringAutocomplete hint
argumentsstring/listPositional arg $name replacement
disable-model-invocationboolBlock auto-invocation
user-invocableboolfalse = hide from / menu
allowed-toolsstringAuto-approved tools
disallowed-toolsstring/listRemoved tools
modelstringhaiku/sonnet/opus
effortstringlow/medium/high/max
contextstringfork = isolated execution
agentstringsubagent type
hooksobjectLifecycle hooks
pathsstring/listGlob activation scope
shellstringbash/powershell

10 Built-in Skills

#SkillDescription
1code-reviewReview diffs for correctness bugs
2batchCross-file batch operations
3debugDebug failed commands
4loopScheduled loops (max 3 days)
5claude-apiBuild Claude API applications
6fewer-permission-promptsReduce permission prompts
7runLaunch driven apps (≥v2.1.145)
8verifyBuild verification changes (≥v2.1.145)
9run-skill-generatorTeach /run how to start a project
10simplifySimplify code (4 parallel agents)

Hooks System

Lifecycle event-driven automation scripts. Configured in .claude/settings.json or Agent frontmatter.

4 Hook Types

TypeDescriptionUse Case
commandRun shell commands (most common)Notifications, code formatting, lint
promptInject prompt text into contextDynamic rule loading, conditional reminders
agentTrigger subagent execution (multi-turn)Complex automation needing model involvement
httpSend HTTP requests (≥v2.1.63)Notify external systems, Webhooks

Agent Frontmatter limitation: Only 6 Hook events are available in Agents: PreToolUse, PostToolUse, PostToolUseFailure, PermissionRequest, Stop, SubagentStop. The other 21 events are only available in the main session.

27 Lifecycle Events

Grouped by function. All events support async and timeout options.

GroupEventTrigger
Tool CallsPreToolUseBefore tool call (interceptable)
PostToolUseAfter successful tool call
PostToolUseFailureAfter failed tool call
PermissionRequestWhen requesting user permission
SessionSessionStartWhen session starts or resumes
SessionEndWhen session ends
SetupWhen running /setup to initialize project
User InteractionUserPromptSubmitWhen user submits prompt
NotificationNotification event
StopWhen Claude stops generating
SubagentsSubagentStartWhen subagent starts
SubagentStopWhen subagent completes
ContextPreCompactBefore context compaction
PostCompactAfter context compaction
Agent TeamsTeammateIdleWhen teammate agent is idle (experimental)
TaskCreatedWhen task is created (experimental)
TaskCompletedWhen background task completes (experimental)
EnvironmentConfigChangeWhen config file changes
WorktreeCreateWhen Worktree is created
WorktreeRemoveWhen Worktree is removed
InstructionsLoadedWhen CLAUDE.md / rules load
MCP & PermissionsElicitationWhen MCP requests user input
ElicitationResultAfter user responds to MCP request
StopFailureWhen turn ends due to API error
CwdChangedWhen working directory changes
FileChangedWhen monitored files change (requires matcher)
PermissionDeniedAfter auto mode denies tool call (retryable)

Config Examples

Hooks are configured in Settings, or via Skill frontmatter per-need activation.

{
  "hooks": {
    "Stop": [{
      "type": "command",
      "command": "python3 .claude/hooks/scripts/hooks.py --event Stop"
    }],
    "PostToolUse": [{
      "type": "command",
      "command": "python3 .claude/hooks/scripts/hooks.py --event PostToolUse"
    }]
  }
}

Advanced Tool Usage

Prompt-to-Code (PTC) — Paradigm Shift

Instead of stuffing instructions into the system prompt, PTC compiles them into executable code rules that run in a sandbox. Result: shorter prompts, more precise reasoning, ~37% token savings.

ComparisonTraditional PromptPTC Mode
Instruction formatNatural language promptCode rules + allowed_callers
ExecutionModel interprets line by lineSandbox code execution, returns result
Token costHigh (full prompt sent each time)Low (code + return value)
DeterminismLow (interpretation may vary)High (explicit code logic)
PTC Configuration Example
{
  "type": "code_execution_20250825",
  "name": "data_processor",
  "allowed_callers": ["code_execution_20250825"],
  "input_schema": {
    "type": "object",
    "properties": {
      "task": { "type": "string" }
    }
  }
}

PTC Advanced Patterns

  • Batch Processing — Loop through multiple records in a single PTC call, reducing tool invocations. Ideal for batch translation, classification, etc.

  • Early Termination — Add conditional checks in code to return immediately when threshold is met. Avoids unnecessary computation.

  • Conditional Branching — Dynamically select different processing branches based on input type, instead of defining separate tools for each.

PTC Constraints

LimitationDescription
Platform supportNo Bedrock / Vertex support, API direct only
Tool typeNo MCP tools, API native tools only
Container lifecycle~4.5 min timeout
Model requirementOpus 4.5+ or Sonnet 4.5+

Dynamic Tool Filtering

Web Search / Web Fetch results are pre-processed by code before entering context, rather than injected raw. Requires beta header anthropic-beta: code-execution-web-tools-2026-02-09.

BenchmarkModelNo FilterWith FilterImprovement
BrowseCompSonnet33.3%46.6%+13.3pp
Opus45.3%61.6%+16.3pp
DeepsearchQASonnet52.6%59.4%+6.8pp
Opus69.8%77.3%+7.5pp

Mark infrequently used tools with defer_loading: true; the model searches and loads them on demand, reducing tool definitions by ~85%.

// Tool definitionsExample
{
  "name": "specialized_analyzer",
  "defer_loading": true,
  "description": "..."
}

// Claude Code environment variable
ENABLE_TOOL_SEARCH=auto:5  // Keep 5 common tools, defer the rest

Tool Use Examples

Add an input_examples array (1-5 items) to tool definitions with real data samples. Model call accuracy jumps from 72% to 90%.

{
  "name": "query_database",
  "input_examples": [
    { "sql": "SELECT * FROM users WHERE active = true LIMIT 10" },
    { "sql": "SELECT COUNT(*) FROM orders WHERE date > '2026-01-01'" }
  ]
}

Availability in Claude Code

StrategyClaude Code CLIAPI / SDK
Tool Search✅ Built-in (v2.1.7+)✅ Manual config
Tool Use Examples✅ Configure in CLAUDE.md✅ Configure in tool definitions
PTC❌ Not applicable in CLI✅ API-level feature
Dynamic Filtering❌ Not applicable in CLI✅ API-level feature

CLI User Priority: Configure Tool Use Examples and Tool Search in CLAUDE.md first (ENABLE_TOOL_SEARCH=auto:5). These provide the most benefit for CLI users. PTC and Dynamic Filtering are primarily for SDK/API deep integration scenarios.

Configuration & Memory System

5-Layer Config Priority · CLAUDE.md Spec · Auto Memory · MCP Extensions

Settings 5-Layer Priority

PrioritySourceScopeSharing
1 (Highest)Managed SettingsOrganizationIT deployed
2CLI argumentsSingle sessionNo
3.claude/settings.local.jsonProject personalgit-ignored
4.claude/settings.jsonProject teamCommitted
5 (Lowest)~/.claude/settings.jsonGlobalNo

Managed Settings Delivery Methods

MethodPlatform
Server-managedRemote push
MDM ProfilemacOS com.anthropic.claudecode
Registry PolicyWindows HKLM\SOFTWARE\Policies\ClaudeCode
managed-settings.jsonmacOS /Library/Application Support/ClaudeCode/
Drop-in directorymanaged-settings.d/*.json merged alphabetically

Core Settings

80+ Settings Complete List (Click to expand)
CategoryKeyDefaultDescription
ModelmodeldefaultDefault model alias or full ID
Modelagent-Default agent name
ModeleffortLevel-Reasoning effort: low/medium/high/xhigh
ModelmodelOverrides-Model ID mapping (Bedrock/Vertex)
ModelavailableModels-Restrict available model list
LanguagelanguageenglishResponse language
LanguagealwaysThinkingEnabledfalseEnable extended thinking by default
MaintenancecleanupPeriodDays30Session cleanup period (days)
UpdatesautoUpdatesChannellateststable/latest
PlansplansDirectory~/.claude/plansPlan file storage directory
MemoryautoMemoryEnabledtrueEnable auto memory
MemoryautoMemoryDirectory-Custom memory directory
MemoryclaudeMdExcludes-Glob pattern to exclude CLAUDE.md files
DisplaystatusLine-Custom status line
DisplayoutputStyledefaultOutput style
DisplayeditorModenormalnormal/vim
DisplayviewMode-default/verbose/focus
Displaytuidefaultfullscreen/default render mode
DisplayprefersReducedMotionfalseReduce animation
Worktreeworktree.symlinkDirectories[]Symlink directories
Worktreeworktree.sparsePaths[]Sparse checkout paths
Worktreeworktree.baseReffreshfresh/head branch source
Attributionattribution.commitCo-authored-byGit commit attribution
Attributionattribution.prGeneratedPR description attribution
TeamteammateModeautoauto/in-process/tmux
Sandboxsandbox.enabledfalseEnable Bash sandbox
Sandboxsandbox.autoAllowBashIfSandboxedtrueAuto-approve in sandbox
Sandboxsandbox.network.allowedDomains[]Network domain allowlist
Sandboxsandbox.customExecutable-Custom sandbox executable
Sandboxsandbox.profileName-Sandbox profile name
PluginsallowedPlugins[]Plugin allowlist
PluginsdeniedPlugins[]Plugin denylist
PluginspluginRegistry-Custom plugin registry URL
PluginspluginInstallDir-Plugin install directory
PluginspluginWorkingDir-Plugin working directory
PluginsenableAllProjectMcpServersfalseAuto-enable project-level MCP
DisplaystatusLine.enabledtrueEnable status line
DisplaystatusLine.fontSize-Status line font size
DisplaystatusLine.theme-Status line theme override
Attributionattribution.hideFromGitLogfalseHide attribution from git log
Attributionattribution.hideFromPrDescriptionfalseHide attribution from PR description
CoreverbosefalseVerbose output mode
CoremaxTurns-Max conversation turns
CoredisallowedTools[]Globally disabled tools list
CoreallowedTools[]Pre-approved tools list
Corehooks{}Lifecycle hooks config
CoremcpServers{}MCP server config
Coreenv{}Environment variable injection
CoreincludeContext[]Extra context files
Corepermissions{}Permission override config
CoreforceLoadSkills[]Forced skill loading
CoreminimumVersion-Prevent auto-update downgrade below this version
CoredefaultShellbashDefault shell (bash / powershell)
CoreincludeGitInstructionstrueInclude commit/PR workflow instructions in system prompt
CorefastModePerSessionOptInfalseRequire manual fast mode enable per session
CoreapiKeyHelper-Shell script path that outputs auth token
CoreclaudeMd- (managed only) Org-level CLAUDE.md instructions
LanguageshowThinkingSummariesfalseShow extended thinking summaries
Languagevoice-Voice dictation config (enabled, mode, autoSubmit)
SkillsdisableSkillShellExecutionfalseDisable inline shell execution for skills
SkillsmaxSkillDescriptionChars1536Per-skill description + when_to_use char limit
SkillsskillListingBudgetFraction0.01Fraction of model context window reserved for skill listing
SkillsskillOverrides-Per-skill name visibility override
FeaturesdisableAllHooks-Disable all hooks (including custom status line)
FeaturesdisableRemoteControlfalseDisable remote control
FeaturesdisableAgentViewfalseDisable background agents and agent view
FeaturesdisableWorkflowsfalseDisable dynamic workflows (/workflows)
FeaturesawaySummaryEnabledtrueGenerate idle session summary on user return
DisplayrespectGitignoretrueFile picker follows .gitignore
DisplayautoScrollEnabledtrueAuto-scroll conversation in fullscreen
DisplayshowTurnDurationtrueShow turn duration after response
DisplaysyntaxHighlightingDisabledfalseDisable code syntax highlighting
DisplaypreferredNotifChannelautoTask completion / permission prompt notification method
DisplayshowClearContextOnPlanAcceptfalseShow "clear context" option on plan accept
MCPenabledMcpjsonServers[]MCP server allowlist (by name)
MCPdisabledMcpjsonServers[]MCP server denylist (by name)
Sandboxsandbox.failIfUnavailablefalseExit with error if sandbox enabled but unavailable
Sandboxsandbox.excludedCommands[]Commands to run outside sandbox
Sandboxsandbox.filesystem.allowWrite[]Extra writable paths inside sandbox
Sandboxsandbox.filesystem.denyWrite[]Paths denied write inside sandbox
Sandboxsandbox.filesystem.denyRead[]Paths denied read inside sandbox
Worktreeworktree.bgIsolationworktreeBackground session isolation mode (worktree/none)
IDEautoConnectIdefalseAuto-connect to running IDE from external terminal
IDEautoInstallIdeExtensiontrueAuto-install extension from VS Code terminal
FeaturesworkflowKeywordTriggerEnabledtrueWhether typing "ultracode" triggers dynamic workflow (v2.1.157)
Featuresultracode- (session-only) Auto-generate workflow for each task, maximize thoroughness (v2.1.154)
FeaturesfeedbackSurveyRate-Session quality survey probability (0-1)
CoredisableDeepLinkRegistration-Prevent registering claude-cli:// protocol handler
AuthforceLoginMethod-Restrict login method: claudeai or console
AuthforceLoginOrgUUID-Restrict login to specified org UUID
AuthapiKeyHelper-Shell script path that outputs auth token
AuthgcpAuthRefresh-Custom script to refresh GCP ADC
PluginsstrictPluginOnlyCustomization- (managed) Lock skills/agents/hooks/MCP to plugins only
PluginsstrictKnownMarketplaces- (managed) Allowed marketplace allowlist
PluginsblockedMarketplaces- (managed) Blocked marketplace denylist
PluginsenabledPlugins-Enable/disable by plugin name
DisplayspinnerTipsEnabledtrueShow tips while waiting
DisplayspinnerVerbs-Custom spinner verbs (mode + verbs array)
DisplayfileSuggestion-Custom file suggestion command
DisplayterminalProgressBarEnabledtrueEnable terminal progress bar
AttributionprUrlTemplate-PR link template (self-hosted GitLab/Bitbucket etc.)
FeaturescompanyAnnouncements-Show custom announcements at startup (random rotation)

Deny rules always have highest priority — deny at any level overrides all allow rules. Array settings are merged and deduplicated across levels, not replaced.

Managed Layer Internal Priority

Within the managed layer, sources are used in this order (only one source, no cross-layer merging):

PrioritySource
1Server-managed remote push
2MDM Profile / Registry Policy
3managed-settings.d/*.json + managed-settings.json
4HKCU Registry (Windows only)
Managed-Layer Policy Keys (Click to expand)
KeyTypeDescription
parentSettingsBehaviorstringControls how SDK parent process managed settings interact with MDM layer. "first-wins"(default) discards parent; "merge" allows parent to tighten but not relax policy. Requires v2.1.133+
policyHelperobjectExecutable that dynamically computes managed settings. Format {path: string}, only effective in MDM or system managed-settings.json. Executed on each startup and merged into managed layer. Requires v2.1.136+
forceRemoteSettingsRefreshbooleanBlock CLI startup until remote managed settings fetch completes. Exit on failure (fail-closed)
wslInheritsWindowsSettingsbooleanRead Windows policy chain on WSL (requires Windows admin to set)
allowManagedPermissionRulesOnlybooleanOnly managed permission rules take effect; user/project allow/ask/deny ignored
allowManagedMcpServersOnlybooleanOnly allow MCP servers in managed allowlist
allowManagedHooksOnlybooleanOnly allow hooks defined in managed layer

v2.1.126 Change: /config now persists changes to ~/.claude/settings.json instead of keeping them in memory only. Edits via the interactive Config UI survive restarts.

Permission Modes

Configure via permissions key in Settings.

ModeDescriptionScenario
defaultHigh-risk operations require confirmationDay-to-day development
planRead-only exploration, overrides explicit allow rules (v2.1.136)Planning phase
acceptEditsAuto-accept file edits. Extra prompt for build tool config files (v2.1.160)Trusted Claude
dontAskAuto-deny unless pre-approvedRestricted environments
autoAuto-approve via background safety check. Falls back to prompt after 3 consecutive or 20 cumulative blocksHigh-efficiency development (research preview)
bypassPermissionsSkip all confirmations. .claude/commands|agents|skills|worktrees/ write exempt from promptCI/CD only

Tool Permission Syntax

ToolSyntaxExample
BashBash(command pattern)Bash(npm run *), Bash(git *)
ReadRead(path pattern)Read(.env), Read(./src/**)
EditEdit(path pattern)Edit(*.ts)
WriteWrite(path pattern)Write(*.md)
WebFetchWebFetch(domain:*)WebFetch(domain:example.com)
AgentAgent(name)Agent(Explore)
SkillSkill(name)Skill(weather-fetcher)
MCPmcp__server__toolmcp__memory__*

Path Prefixes

PrefixMeaningExample
//Absolute pathRead(//Users/alice/file)
~/Relative to HomeRead(~/.zshrc)
/Relative to project rootEdit(/src/**)
No prefixCurrent directoryRead(*.ts)

Matching Rules

  • Compound commands: Split by &&, ||, ;, |, each sub-command matches independently. Bash(safe-cmd *) does not cover safe-cmd && other-cmd
  • Wildcard position: * can appear as prefix, suffix, or infix. Bash(* install) matches npm install; Bash(git * main) matches git push main
  • Word boundary: Bash(ls *) (with space) does not match lsof; Bash(ls*) (no space) matches both
  • Symlinks: allow requires both symlink and target both in allowed dirs; deny triggers on either
  • Process wrappers: timeout, time, nice, nohup stripped before matching. watch, find -exec always prompt

Global vs Project Config

  • Global ~/.claude/settings.json Global settings CLAUDE.md All project instructions Best for: personal preferences, general config, shell aliases

  • Project .claude/settings.json Team shared (committed) settings.local.json Personal override (git-ignored)) CLAUDE.md Project instructions agents/ SubAgent definitions skills/ Skill definitions commands/ Custom commands

6 Configuration Dimensions

DimensionGlobalProject
Settings~/.claude/settings.json.claude/settings.json + settings.local.json
Memory~/.claude/CLAUDE.mdPer-directory CLAUDE.md + auto memory
MCP~/.claude/mcp.json.mcp.json
Skills~/.claude/skills/.claude/skills/
Agents~/.claude/agents/.claude/agents/
Hookshooks field in settings.jsonhooks field in settings.json

Directory Structure

~/.claude/                          .claude/
├── settings.json      ← Global settings    ├── settings.json      ← Team shared
├── settings.local.json               ├── settings.local.json ← Personal override
├── CLAUDE.md          ← Global instructions    ├── CLAUDE.md          ← Project instructions
├── mcp.json           ← Global MCP    ├── agents/            ← Subagent definitions
├── agents/            ← Global agents    │   ├── reviewer.md
│   ├── explorer.md                   │   └── coder.md
│   └── researcher.md                 ├── skills/            ← Skill definitions
├── skills/            ← Global skills    │   ├── lint-check/
│   └── deploy-check/                 │   │   └── SKILL.md
├── commands/          ← Global commands    │   └── test-runner/
│   └── review.md                     │       └── SKILL.md
├── plans/             ← Plan files    ├── commands/          ← Custom commands
├── tasks/             ← Task persistence  │   └── commit.md
├── memory/            ← Auto memory    ├── rules/             ← Conditional rules
└── plugins/           ← Plugin installs    │   ├── tests.md
                                      │   └── security.md
                                      └── mcp.json           ← Project MCP

6 Design Principles

PrincipleDescription
Least SurpriseDefault behavior is intuitive, minimal unexpected config
Layered OverrideHigher layers override lower; deny always highest
Progressive DisclosureZero config for simple cases; unfold for complex
Team FriendlyProject config committable; personal config git-ignored
Security FirstMulti-layer permission protection, sandboxed execution
ExtensibleMCP + Skills + Hooks — three extension dimensions

Global-Only Features

  • allowedPlugins / deniedPlugins — Plugin allowlist/denylist
  • managedSettings — IT-deployed org-level config
  • autoUpdatesChannel — Update channel control
  • cleanupPeriodDays — Session auto-cleanup
  • pluginRegistry — Custom plugin source
  • plansDirectory — Global plan files directory
  • autoMemoryEnabled — Memory system toggle

CLAUDE.md Specification

CLAUDE.md is the single most impactful configuration in Claude Code. A well-structured CLAUDE.md improves output quality more than any Settings tuning.

4 Storage Locations

FileLocationLoad timingPurpose
CLAUDE.mdProject rootAt startup (traverse upward)Team shared instructions
CLAUDE.local.mdProject root (git-ignored)At startup (traverse upward)Personal preferences, not committed
~/.claude/CLAUDE.mdUser home dirEvery sessionGlobal personal instructions, all projects
.claude/rules/*.mdProject rules/Depends on frontmatterConditionally loaded rules

.claude/rules/ Conditional Loading

  • With paths: frontmatterLazy-loaded only when operating on matching paths. Ideal for framework-specific rules, e.g. paths: ["src/**/*.test.ts"] loads only when editing test files.

  • Without frontmatterLoaded every session, equivalent to CLAUDE.md. Best for project-wide rules.

Writing Guidelines

  • Keep under 200 lines — compliance drops beyond this
  • Write WHY not WHAT — code already explains WHAT; document hidden constraints, subtle invariants, workarounds for specific bugs
  • Negative instructions are more effective — “don’t use pattern X” is clearer than “use pattern Y”
  • Don’t state the obvious that code already expresses — CLAUDE.md’s value is pushing Claude out of default thinking
  • Don’t save code patterns, architecture snapshots, or git history — these are derivable from code
  • Include project-specific constraints: build order dependencies, known incompatible library versions, special deployment processes

claudeMdExcludes

Use claudeMdExcludes setting to skip unwanted CLAUDE.md files:

{
  "claudeMdExcludes": [
    "**/vendor/**/CLAUDE.md",
    "**/node_modules/**/CLAUDE.md"
  ]
}

Exclusion applies to user, project, and local memory only; managed policy files cannot be excluded.

Monorepo Loading Mechanism

CLAUDE.md Loading in Monorepos

CLAUDE.md loading mechanism in monorepos (Boris Cherny original)

  • Ancestor Loading — At startup, traverses upward and immediately loads all CLAUDE.md files. Immediate

  • Descendant Loading — Subdirectory CLAUDE.md files load only when operating in that directory. Lazy

Scenario Comparison

Assume monorepo structure: frontend/CLAUDE.md, backend/CLAUDE.md, api/CLAUDE.md, root CLAUDE.md.

Scenario 1: Start from root cd /mymonorepo && claude

FileLoaded?Reason
Root CLAUDE.md✓ ImmediateCurrent working directory
frontend/CLAUDE.md✗ LazyLoads when operating in frontend/
backend/CLAUDE.md✗ LazyLoads when operating in backend/
api/CLAUDE.md✗ LazyLoads when operating in api/

Scenario 2: Start from component directory cd /mymonorepo/frontend && claude

FileLoaded?Reason
Root CLAUDE.md✓ ImmediateAncestor directory, upward traversal
frontend/CLAUDE.md✓ ImmediateCurrent working directory
backend/CLAUDE.md✗ NeverSibling directory on different branch
api/CLAUDE.md✗ NeverSibling directory on different branch

Best practice: Shared conventions in root CLAUDE.md, component-specific instructions in component CLAUDE.md. Personal preferences in CLAUDE.local.md (git-ignored).

Auto Memory

Claude Code ‘s auto memory system persists information across sessions. Memory files are stored in the project .claude/ directory or global ~/.claude/, organized in YAML frontmatter + Markdown format.

4 Memory Types

TypeContentWhen to saveTypical file
userRole, goals, knowledge backgroundWhen learning about useruser_role.md
feedbackPreferences and correctionsOn user correction/confirmationfeedback_testing.md
projectProject progress, milestonesWhen learning project statusproject_auth_rewrite.md
referenceExternal system pointersWhen learning about external resourcesref_linear_ingest.md

Memory File Structure

Each memory is an independent Markdown file using YAML frontmatter:

---
name: feedback-testing
description: Testing preferences and corrections
metadata:
  type: feedback
---

Integration tests must use a real database, not mocks.
**Why:** Last quarter a migration failed due to mock/production environment divergence. 

[[testing-patterns]]  ← link to related memory

MEMORY.md Index

All memories are managed via the MEMORY.md index file, kept under 200 lines. Index format per line:

- [Title](filename.md) — one-line summary

What NOT to Save

  • Code patterns, architecture, file paths — derivable from code
  • Git history, recent changes — git log is authoritative
  • Debug solutions — the fix is in code, context in commit message
  • Content already covered in CLAUDE.md
  • Ephemeral task details — use Task or Plan instead

Configuration

KeyDefaultDescription
autoMemoryEnabledtrueEnable auto memory, toggle via /memory
autoMemoryDirectory-Custom memory directory (global/managed layer only)

Agent Memory 3 Scopes

With Subagents, Memory can persist knowledge across agents.

ScopeStorageNotes
user~/.claude/Global, shared across all projects
project.claude/Project-level, team shared
local.claude/ (git-ignored)Local, personal

Keep the MEMORY.md index file under 200 lines.

MCP Services

Common MCP Services

MCPUsageConfig
Context7Latest library docsAuto
PlaywrightBrowser automation testingnpx @anthropic-ai/mcp-playwright
Chrome DevToolsBrowser debuggingChrome Extension
DeepWikiGitHub repo docsAuto
ExcalidrawDiagram drawingAuto

MCP Settings Keys

KeyScopeDescription
enableAllProjectMcpServersAnyAuto-approve all .mcp.json servers
enabledMcpjsonServersAnyAllowlist by name
disabledMcpjsonServersAnyDenylist by name
allowedMcpServersManagedAllowlist by name/command/URL matching
deniedMcpServersManagedDenylist by matching pattern
allowManagedMcpServersOnlyManagedOnly allow MCP servers in managed allowlist
allowAllClaudeAiMcpsManagedAllow claude.ai cloud MCP connectors
channelsEnabledManagedAllow Channel message push (Team/Enterprise)

Configuration Example

{
  "mcpServers": {
    "context7": {
      "command": "npx",
      "args": ["-y", "@anthropic-ai/mcp-context7"]
    },
    "always-on-server": {
      "type": "http",
      "url": "https://mcp.example.com",
      "alwaysLoad": true
    }
  }
}

Key Features

  • alwaysLoad (v2.1.121) — Set "alwaysLoad": true in server config to load all tools immediately instead of lazy discovery. Only for small tool sets needed every turn.

  • Hot Reload (v2.1.139)/mcp Reconnect re-reads .mcp.json without restarting the session. Also injects CLAUDE_PROJECT_DIR into stdio server environment.

Environment Variable Expansion

Use ${ENV_VAR} syntax in .mcp.json to reference environment variables, avoiding hardcoded secrets:

{
  "mcpServers": {
    "my-api": {
      "url": "https://mcp.example.com/mcp?token=${MCP_API_TOKEN}"
    }
  }
}

workspace is a reserved MCP server name (v2.1.128). User-defined servers with this name will be skipped with a warning.

OAuth-compatible servers complete authentication automatically (following RFC 9728), no manual apiKeyHelper config needed.

Development Workflows

RPI · CRISPY · Cross-Model · Agent Teams · Automation

RPI Workflow

Research → Plan → Implement, each phase has a validation gate. Orchestrates multiple agent roles via Subagents.

Step 1: RESEARCH   → RESEARCH.md (GO / NO-GO) 
Step 2: PLAN       → PLAN.md + pm.md + ux.md + eng.md
Step 3: IMPLEMENT  → IMPLEMENT.md (phased, each phase has test gates) 

8 Agent Roles

AgentModelResponsibility
requirement-parsersonnetParse unstructured requirements into standardized format (functional/non-functional, constraints, complexity estimation)
product-manageropusTransform high-level requirements into PRD (user stories, acceptance criteria, success metrics, scope definition)
senior-software-engineeropusTDD-first implementer: small commits, clear boundaries, reversible, observable
ux-designeropusGenerate UX Brief: all-state design (loading/empty/error/success), accessibility annotations
code-revieweropusCode review: correctness, security, dependencies, architectural boundaries, outputs NEEDS REVISION / APPROVED
technical-cto-advisoropusCTO-level strategic assessment: tech stack alignment, risk assessment, business risk integration
constitutional-validatoropusFive-dimensional framework validation: mission alignment, architecture alignment, knowledge management, human-AI collaboration, complexity fit
documentation-analyst-writeropusProduce documentation per project standards (API, architecture, user guide), with self-check protocol

3 Commands

CommandParamAgents UsedOutput
/rpi:research<feature-slug>requirement-parser → product-manager → Explore → senior-engineer → cto-advisor → doc-writerRESEARCH.md (GO/NO-GO/CONDITIONAL/DEFER)
/rpi:plan<feature-slug>product-manager → ux-designer → senior-engineer → doc-writerpm.md + ux.md + eng.md + PLAN.md
/rpi:implement<feature-slug> [--phase N]Explore → senior-engineer → code-reviewer (per-phase loop)IMPLEMENT.md (includes PR notes)
Project Directory Structure
rpi/{feature-slug}/
├── REQUEST.md              # Feature description
├── research/RESEARCH.md    # GO/NO-GO analysis
├── plan/
│   ├── PLAN.md             # Implementation roadmap (3-5 phases) 
│   ├── pm.md               # Product requirements document
│   ├── ux.md               # UX design draft
│   └── eng.md              # Technical specification
└── implement/IMPLEMENT.md  # Implementation log (per-phase verification) 

CRISPY Method

C — Clarify      Define requirements
R — Research     Technical research
I — Ideate       Brainstorm solutions
S — Structure    Architecture design
P — Plan         Create plan
Y — Yield        Produce implementation
  + Iterate      Iterate & refine

CRISPY is an evolution of RPI, adding Ideate and Structure phases, emphasizing that solution design matters more than implementation.

Cross-Model Collaboration (Claude + Codex)

Cross-Model Workflow

Claude Code (Opus) + Codex CLI (GPT) cross-model 4-step collaboration workflow

STEP 1: PLAN          Claude Code Opus · Plan Mode
STEP 2: QA REVIEW     Codex CLI GPT · Review plan, insert findings
STEP 3: IMPLEMENT     Claude Code Opus · Phase-by-phase implementation
STEP 4: VERIFY        Codex CLI GPT · Verify against plan

**Core idea:**Different models review each other. Codex appends “Codex Finding” annotations without rewriting the original plan.

Agent Teams

Agent Teams

Agent Teams multi-agent collaboration workflow

Coordinate multiple agents via shared task list (TaskCreate/TaskUpdate). Ideal for large refactors decomposable into independent subtasks.

Team Coordination Pattern

Take Time Orchestration as an example — three roles build in parallel, sharing a data contract {time, timezone, formatted}:

RoleOutputDescription
Command Architecttime-orchestrator commandDesign slash command, orchestrate Agent → Skill call order
Agent Engineertime-agent + time-fetcher skillLightweight Agent (haiku, maxTurns:3), fetches Dubai time via preloaded Skill
Skill Designertime-svg-creator skillReceive data contract, generate SVG time card + output.md

Agent Teams Component List

time-agent definition
---
name: time-agent
description: Get current Dubai time (Asia/Dubai, UTC+4) 
tools: Bash
model: haiku
color: blue
maxTurns: 3
skills: time-fetcher
---
Use Bash to execute `TZ='Asia/Dubai' date`, return time/timezone/formatted fields. 
time-orchestrator command
---
description: Get Dubai time and generate SVG time card
model: haiku
---
1. Agent(time-agent) → fetch {time, timezone, formatted}
2. Skill(time-svg-creator) → generate SVG card
Note: Must execute sequentially, cannot parallelize. 
time-fetcher Skill
---
name: time-fetcher
description: Fetch current Dubai time via bash
user-invocable: false
---
Command: TZ='Asia/Dubai' date '+%Y-%m-%d %H:%M:%S %Z'
Return format: { time: "HH:MM:SS", timezone: "GST (UTC+4)", formatted: "full output" }
time-svg-creator Skill
---
name: time-svg-creator
description: Create Dubai time SVG card
allowed-tools: Write, Read
---
Receive time/timezone/formatted, generate self-contained SVG card. 
Output: agent-teams/output/dubai-time.svg + output.md

Scheduled Tasks

# CronCreate Parameters
cron: "*/5 * * * *"     # Standard 5-field cron (local timezone) 
prompt: "Check CI status"   # Prompt executed on trigger
recurring: true          # true=recurring, false=one-shot
durable: true            # true=persist to file

Goal-Driven

Automatically decompose and track progress with the task system.

  1. User sets a goal
  2. Claude decomposes into subtasks and creates a task list
  3. Implement step by step, updating status each step
  4. Request user input when blocked

Community Goal Tips

  • Let the Agent propose Goals — describe the problem context first, then let the Agent suggest appropriate goals, usually more precise than hand-written ones
  • Let the Agent draft /goal prompts — the Agent knows its own capability boundaries better, producing more feasible goal prompts
  • /goal <condition> Conditional Goals — e.g. /goal all tests pass and no lint errors, Agent keeps working until the condition is met
  • Goal + TaskCreate Integration — Decompose Goal into TaskCreate task list, mark each done on completion

Session Management

ScenarioRecommended Action
Starting complex task/plan
Context > 50%/compact
Hallucination detected/undo to revert
Multi-file changesAgent parallel dispatch
Long-running taskBackground agent

Context Rot starts appearing at ~300-400k. Revert > Correct.

Deep Reports

LLM Performance · Tool Comparison · Usage · Learning Path

LLM Performance Degradation Analysis

LLM Degradation

Daily fluctuations in LLM output quality

9-Layer Inference Stack (Frozen Weights ≠ Frozen Behavior)

┌──────────────────────────────────────────────┐
│  User session context              ← In-session degradation    │
│  System Prompt                    ← Periodically updated      │
│  Post-Training (RLHF/fine-tuning)  ← Can update silently    │
│  Sampling params (temperature/top-p) ← Server-adjustable    │
│  Speculative Decoding (draft model) ← Quality fluctuation      │
│  MoE routing / batch composition   ← ±8-14% variance   │
│  Hardware routing (TPU/GPU/Trainium)← Different failure modes  │
│  Quantization level (FP16/INT8/INT4)← May change under load │
│  Compiler & runtime (XLA:TPU/CUDA) ← Confirmed bugs  │
├──────────────────────────────────────────────┤
│  Model weights (frozen) ← This layer does not change                    │
└──────────────────────────────────────────────┘

Key Findings

QuestionAnswer
Do model weights change?No — confirmed by all providers
Can daily behavior differ?Yes — ±8-14% variance confirmed
Is it intentional “dumbing down”?No — no evidence of intentional degradation
Are infrastructure bugs real?Yes — Anthropic confirmed 3 bugs, affecting up to 16% of requests
Are there psychological factors?Yes — confirmation bias and honeymoon effect are real
Should you trust personal perception?Partially — real causes exist, but perception amplifies them

Anthropic 2025.9 Post-Mortem: 3 Infrastructure Bugs

Bug #1 — Context Window Routing Error

DimensionDetails
CauseSonnet 4 requests incorrectly routed to 1M token context window servers
TimelineIntroduced Aug 5, worsened after Aug 29 load balancer change
Peak Impact16% of Sonnet 4 requests affected (Aug 31 worst period)
User Impact~30% of Claude Code users received at least one degraded response
Hidden DetailRouting was “sticky” — once hitting a bad server, subsequent requests kept routing there
FixSept 4-18 rolling deployment across platforms

Bug #2 — TPU Output Corruption

DimensionDetails
CauseTPU server misconfiguration, assigning high probability to low-frequency tokens during generation
SymptomsSudden Thai/Chinese characters in English responses, obvious code syntax errors
ScopeOpus 4.1/Opus 4 (Aug 25-28), Sonnet 4 (Aug 25-Sept 2); Claude API only
FixRolled back on Sept 2

Bug #3 — XLA:TPU Compiler Miscompilation (Most Tricky)

DimensionDetails
Root CauseA code change fixing precision issues accidentally exposed a latent compiler bug in XLA:TPU
BehaviorApproximate top-k operation “sometimes returned completely wrong results”, but only for specific batch sizes and model configs
Why Hard to FindBehavior depended on preceding/succeeding operations and whether debugging tools were enabled
Hidden DurationA Dec 2024 workaround had been masking this deeper bug all along
ImpactHaiku 3.5 confirmed; Sonnet 4/Opus 3 partially suspected
ResolutionSwitched from approximate top-k to exact top-k, accepting slight efficiency loss

Claude runs on three different hardware platforms (AWS Trainium, NVIDIA GPU, Google TPU), each with different failure modes, compilers, and precision behavior. Your requests may hit different hardware on different days.

MoE Routing Variance (Scale AI Research)

In MoE (Mixture of Experts) architecture, the query composition of other users in the batch determines which experts your request is routed to — and this composition is non-deterministic.

ProviderDaily Score Variance
OpenAI (GPT-4 series)±10-12%
Anthropic (Claude series)±8-11%
Google (Gemini series)±9-14%

Specific example: the same model scored 77% on jailbreak resistance one day and 63% the next — a 14-point swing with zero bugs, zero changes.

System Prompt & Post-Training Updates

FactorDescription
System Prompt ChangesModel weights unchanged, but system prompt can update anytime. Claude 3.7 had multiple hot-fix instructions, 4.0 removed them all (solved via RL)
Post-Training UpdatesCan update RLHF/fine-tuning without changing base weights — technically “model unchanged” but behavior has shifted
Silent Model SwitchingOpenAI has been documented silently swapping user-facing models multiple times (GPT-4o→GPT-5 forced switch, autoswitcher bug)

Stanford Study (2023) — and Its Controversy

Chen/Zaharia/Zou’s landmark study found GPT-4 accuracy on “prime number judgment” dropped from 97.6% to 2.4% (Mar→Jun 2023), but had methodological issues:

  • March version used temperature 0.0, June version used temperature 1.0 — a fundamental confounding variable
  • Only 500 queries per task — sample size too small
  • “Math problems” were actually yes/no questions, model guessing pattern changed rather than math ability declining
  • Changes may be intentional post-training safety updates, not unintentional degradation

Psychological Factors

EffectDescription
Confirmation BiasOnce someone tweets “Claude is dumb today”, you start noticing every error
Honeymoon EffectInitial experience with new models is always impressive, expectations rise faster than capability
”Weekend Claude” MythStrict analysis found no consistent day-of-week pattern
RandomnessSame prompt produces different output each time. A few bad responses in a row may just be bad luck

Codex 5.3 Comparison Analysis

When Claude has short-term degradation, Codex 5.3 may appear significantly better, reasons:

  1. Product-Goal Fit — Codex is optimized for code generation, producing better coding results even at equal model strength
  2. Reasoning Strategy Differences — Each provider independently tunes latency/reasoning depth/decoding defaults
  3. Service Path Isolation — Different routing layers/compilers/release pipelines, one failing doesn’t affect the other
  4. Release Timing — One provider mid-release while another is stable can create large temporary quality divergence

Degradation Hypothesis Ranking

HypothesisLikelihoodReasoning
Provider incident + rollbackHighBest matches “days of decline followed by quick recovery” pattern
Service configuration changeHighCommon source of sudden behavior changes, no retraining needed
Silent alias/snapshot moveMedium-HighCan change behavior without user action
Prompt drift + context pollutionMediumCan degrade individual sessions, but hard to explain widespread multi-day reports
Permanent base model degradationLowInconsistent with quick recovery to prior quality

Practical Recommendations

  1. Lock model snapshots when available (instead of using floating aliases)
  2. Store request metadata (model ID, parameters, latency, error rates)
  3. Run fixed daily canary tests, alert on regression
  4. Reset or compact long sessions after multiple failures
  5. Maintain backup provider/model paths
  6. Separate “model quality” from “service reliability” in internal dashboards

**The single most important action:**When quality feels degraded, use /compact or start a fresh session. This is the most effective single action — most “Claude got dumber” is context pollution, not model degradation.

Harness Importance

Common misconception: skill/command/subagent/hook all end up as prompts, so writing good prompts is enough. **This is wrong.**At the engineering level, the Harness is a prompt construction system + deterministic execution system + context architecture system.

MetricValue
User input tokens6–60
Model actual reasoning tokens5,000–50,000+
CLI modular prompt fragments110+

Harness 10 Capabilities (cannot be replicated by prompts)

#CapabilityDescription
1Context isolationN parallel subagents ≈ N× effective context
2Tool restriction enforcementallowed/disallowedTools intercept before model calls
3Lazy loading rulespaths: frontmatter loads on demand
4Hooks determinismLifecycle events trigger shell commands, can block tool calls
5Model routingmodel: haiku / model: opus route to different endpoints
6Parallel executionMultiple subagents run concurrently
7Cross-session persistenceMemory system and settings layers persist across conversations
8Modular system prompt110+ fragments conditionally loaded by function
9Skill preloadingFull skill content injected into subagent startup context
10Permission classificationauto mode background classifier pre-approves/blocks

Output quality = f(effective context, model capability, iteration loops). Users control only a tiny fraction of effective context; the harness controls the rest and the entire iteration loop. Strong prompts are necessary but not sufficient.

Browser MCP Comparison

MetricChrome DevToolsClaude in ChromePlaywright
Tool Count26 tools16 tools21 tools
Token Cost~19.0k (9.5%)~15.4k (7.7%)~13.7k (6.8%)
Browser SupportChrome onlyChrome onlyChromium/Firefox/WebKit
Headless ModeSupportedNot supportedSupported
CI/CD IntegrationExcellentPoor (requires login)Excellent
SecurityIsolated profilesAttack rate 23.6%→11.2%Mature security model
CostFreeRequires paid planFree
StepPurposeTool
DevelopmentTerminal codingClaude Code
TestingE2E/cross-browserPlaywright MCP
DebuggingPerformance/networkChrome DevTools MCP
VerificationQuick visual checkClaude in Chrome
CI/CDHeadless automationPlaywright MCP
# Install command
npx playwright install
claude mcp add playwright -s user -- npx @playwright/mcp@latest
claude mcp add chrome-devtools -s user -- npx chrome-devtools-mcp@latest

Playwright has the highest token efficiency (186.3k remaining), Chrome DevTools the lowest (181k remaining). Gap of ~5.3k tokens.

Monorepo Skill Discovery

Skills discovery/loading mechanism is different from CLAUDE.md: CLAUDE.md traverses upward (ancestor loading) , while Skills use nested directory auto-discovery (descendant discovery), and are only loaded on demand when editing files in the corresponding directory. See Monorepo Loading Mechanism.

Standard Skill Locations

ScopePathApplies To
EnterpriseManaged settingsAll users in organization
Personal~/.claude/skills/<name>/SKILL.mdAll projects
Project.claude/skills/<name>/SKILL.mdCurrent project only
Plugins<plugin>/skills/<name>/SKILL.mdWhere plugin is enabled

CLAUDE.md vs Skills Loading Comparison

BehaviorCLAUDE.mdSkills
Upward traversal (ancestor)YesNo
Downward discovery (descendant)Yes (lazy loading)Yes (auto discovery)
Default content loadingAll contentDescription only (full on demand)

Character budget defaults to 15,000 characters, adjustable via SLASH_COMMAND_TOOL_CHAR_BUDGET environment variable. Use /context to check if any skills were excluded due to budget limits.

  • General workflows go in root .claude/skills/
  • Package-specific skills go in the corresponding package .claude/skills/
  • Dangerous operation skills should set disable-model-invocation: true
  • Use package name prefixes to avoid confusion (e.g. frontend-review, backend-deploy)

Usage & Limits

MetricValue
Context Window1M token
Recommended compaction point~50%
Degradation onset~300-400k
CLAUDE.md recommendation<200 lines
Extra Usage daily limit$2,000/day
Limit reset windowEvery 5 hours

Monitoring Commands

CommandFeatureApplies To
/usageView plan and rate limitsPro/Max 5x/Max 20x
/extra-usageConfigure pay-per-use overflowPro/Max 5x/Max 20x
/costCurrent session tokens and costAPI key users
/insightsUsage pattern analysis reportAll users

Cost Optimization

  • Use model: haiku for simple tasks
  • effort: low reduces reasoning
  • Background agent avoids blocking
  • API key users use --max-budget-usd to control costs
  • Configure extra-usage monthly cap to avoid unexpected charges

Fast Mode (/fast) counts as extra usage from the first token, not consuming subscription plan included quota. Must enable and fund extra-usage to use.

Spinner Verbs

Claude Code’s loading animation uses 179 random verbs. Common ones:

VerbImplies
Thinking / CogitatingReasoning
Reading / PerusingReading files
Editing / CraftingEdit file
Searching / SpelunkingSearching code
OrchestratingOrchestrating agents
SynthesizingSynthesizing information

Learning Path

A complete learning journey building a Weather Reporter from scratch, through 5 major phases · 37 slides:

Phase Order (reordered by cognitive dependencies)

OrderPhaseSlidesCore Idea
1Agents7First understand “who” does the work
2Skills8Skills are the agent’s “capabilities”
3Context7Context Window & memory system
4CLAUDE.md7Project instructions are “rules”
5Commands8Commands are the “orchestration layer”

LEVELS Mapping (6 levels)

const LEVELS = {
  context:     '🔴 Context Window',   // context-window.jpeg, context.jpg
  claude_md:   '🟠 CLAUDE.md',   // Project instruction system
  agents:      '🟡 Agent System',     // Built-in + custom agents
  skills:      '🟢 Skills System',     // Skills framework
  commands:    '🔵 Commands System',     // Commands orchestration
  workflow:    '🟣 Full Workflow'    // End-to-end integration
}

37 Slides Outline

Expand all slide content

Agents Phase (Slides 1-7)

  1. What is an Agent? — Agent = Model + Tools + Context
  2. 5 built-in agent types — general-purpose / Explore / Plan / statusline-setup / claude-code-guide
  3. Agent Frontmatter — 16 tools field details
  4. Model selection — inherit / haiku / sonnet / opus tradeoffs
  5. Tool control — tools vs disallowedTools
  6. Permission Mode — acceptEdits / plan / bypassPermissions
  7. Weather Agent Design — weather agent in practice

Skills Phase (Slides 8-15)

  1. What is a Skill? — Skill = prompt template + metadata
  2. SkillTrigger — auto (PROACTIVELY) vs manual (/skill-name)
  3. Frontmatter fields — name / description / tools / model
  4. weather-fetcher skill — fetch weather data from API
  5. weather-analyzer skill — analyze weather trends
  6. Skill composition — multiple skills working together
  7. Skill testing — verify skill output quality
  8. Skill best practices — writing reusable skills

Context Phase (Slides 16-22)

  1. Context Window — 200K token boundary
  2. Context Compression — automatic summarization
  3. Memory System — user / project / local three tiers
  4. MEMORY.md Index — persistent memory management
  5. CLAUDE.md Injection — context loading strategy
  6. Resource Reuse — context-window.jpeg / context.jpg
  7. Context Window visualization — understanding token allocation

CLAUDE.md Phase (Slides 23-29)

  1. What is CLAUDE.md? — Project instructions file
  2. Three-level loading — global / project / local
  3. Writing conventions — structured instruction format
  4. Environment config — development environment conventions
  5. Code style — project code conventions
  6. Security rules — sensitive operation constraints
  7. Weather Reporter's CLAUDE.md — practical example

Commands Phase (Slides 30-37)

  1. What is a Command? — command = orchestration layer
  2. Command vs Skill vs Agent — three-layer architecture comparison
  3. weather-orchestrator — weather orchestration command
  4. Command flow — prompt → steps → output
  5. Dynamic context injection — !`command` syntax
  6. Error handling & retries — robustness design
  7. End-to-end integration — Agents + Skills + Commands
  8. Review & outlook — from zero to complete Weather Reporter

Resource Reuse

AssetReused InDescription
context-window.jpegSlide 16Context Window visualization
context.jpgSlide 22Context allocation diagram

Redesign Accounting

  • goToSlide() target: all 37 call sites need updated index numbers
  • data-level attribute: each slide’s level marker needs mapping to LEVELS
  • Navigation component: prev/next buttons need binding to new slide order
  • Progress bar: 5-segment progress indicator maps to 5 phases

Start simple → compose gradually → full orchestration. Don’t build complex architecture from the start. Phase order is rearranged by cognitive dependencies: first understand “who” (Agents), then “what they can do” (Skills), then “environment” (Context), then “rules” (CLAUDE.md), finally “orchestration” (Commands).

SDK vs CLI System Prompts

Claude Code CLI and Agent SDK use different system prompt strategies:

Agent SDK
  • Base prompt about ~269 tokens
  • Minimal guidance, highly customizable
  • modular type supports custom system prompts
  • 110+ system prompt strings available
  • Suitable for building custom agent applications
CLI Mode
  • System prompt includes complete tool definitions
  • Pre-installed Bash/Read/Write/Edit tool descriptions
  • CLAUDE.md auto-injection
  • Includes safety rules and behavior constraints
  • Ready to use, zero configuration

Core Differences

DimensionAgent SDKClaude Code CLI
System prompt length~269 tokens (minimal)~3000+ tokens (complete)
Tool descriptionsLoaded on demandAll pre-installed
CustomizabilityFully controllableCLAUDE.md + Settings
Use caseBuild AI applicationsDevelopment workflows
Model selectionAny Claude modelOpus/Sonnet/Haiku

SDK provides a modular prompt type, allowing tool descriptions to be added individually, saving many tokens over CLI’s full loading.

Billion Dollar Questions

13 unanswered deep questions from the community — if you have answers, these are billion-dollar insights.

Memory & Instructions (4 questions)

  1. What should CLAUDE.md contain? — What to include, what to exclude?
  2. If CLAUDE.md exists, do you still need constitution.md or rules.md?
  3. How often should CLAUDE.md be updated? How to tell if it’s outdated?
  4. Why does Claude still ignore instructions in CLAUDE.md — even with MUST in all caps?

Agents, Skills & Workflows (6 questions)

  1. When to use Command vs Agent vs Skill — when is native Claude Code better?
  2. How often should agents/commands/workflows be updated as models upgrade?
  3. General-purpose vs role/function-specific subagents — does detailed persona actually improve quality?
  4. Use Claude Code’s built-in plan mode, or build custom planning commands/agents to enforce team workflows?
  5. How do personal skills and community skills coexist? Who takes priority on conflict?
  6. **The ultimate question:**Can you convert an existing codebase to spec, delete the code, and have AI regenerate from spec alone?

Specs & Documentation (3 questions)

  1. Should every feature in the repo have a spec file?
  2. How often should specs be updated to stay current?
  3. When implementing a new feature, how to handle cascading impacts on other features’ specs?

The answers to these questions will determine the direction of Agentic Engineering best practices. If you have insights, this is the frontier.

Expert Insights

Boris Cherny · Thariq · Community Best Practices

Boris Cherny — 13 Rules

Boris Cherny

Boris Cherny — Claude Code Core Engineer

Boris Cherny is a core engineer on Claude Code at Anthropic, where he leads development of the agentic coding tools used by hundreds of thousands of developers. He’s the author of Programming TypeScript (O’Reilly) and a frequent speaker on AI-assisted development workflows. The 13 rules below distill his most-repeated guidance from talks, demos, and PR comments — the same advice he gives teammates onboarding to Claude Code.

  1. Write great CLAUDE.md — highest ROI optimization
  2. Under 200 lines — compliance drops beyond this
  3. Negative instructions — "don't do X" is more effective
  4. Manual /compact — proactively compress at 50%
  5. Plan before implementing — use /plan for complex tasks
  6. Subagent parallelism — dispatch independent tasks simultaneously
  7. Specify model explicitly — haiku for simple, opus for complex
  8. Revert > Correct — /undo is more reliable than post-hoc fixes
  9. Trust code reading — no need to manually paste code
  10. Hooks automation — use hooks for repetitive operations
  11. CLAUDE.local.md — personal preferences without polluting team
  12. Rules for conditional loadingpaths to scope
  13. /doctor for diagnostics — run /doctor first when issues arise

15 Hidden Features

15 lesser-known Claude Code features from Boris Cherny (Meta), each significantly changing how you use it.

  1. Claude Mobile App — iOS/Android serve as voice+text entry points for Claude Code, code conversations during commute
  2. Teleport (Remote Control) claude --teleport or remote-control MCP, remote control local terminal from browser/phone
  3. /loop & /schedule — Set up recurring tasks or timed wake-ups: Agent continuously monitors, executes periodically (e.g. check CI every 5 min)
  4. Hooks Automationsettings.json configures PreToolUse/PostToolUse/Stop event hooks for auto-notification, validation, formatting
  5. Cowork Dispatch — Multi-Agent coordinated scheduling, different agents work independently without interference
  6. Chrome Extension — Claude in Chrome MCP, lets Agent directly operate browser, read console logs, screenshot comparison
  7. Desktop Web Server — Claude desktop has built-in web server, Agent can directly access local dev pages
  8. /branch Fork — One-click fork from current conversation to new branch, preserving full context, discardable on failed experiment
  9. /btw Sidebar Query — Ask temporary questions without interrupting the main flow, answers injected into current context
  10. Git Worktree Parallelism/batch fans out multiple worktrees, each independent branch handles different tasks
  11. --bare SDK Acceleration — SDK mode strips interactive UI, pure function calls, significant speed improvement
  12. --add-dir Multi-Repo — Load multiple project directories into the same session simultaneously, cross-repo operations
  13. --agent Custom Prompt — Specify Agent type or custom system prompt directly from command line
  14. /voice Voice Input — Voice commands via microphone, automatic transcription
  15. Background Agent — Long tasks in background without blocking main session, auto-notification on completion

12 Customization Tips

  1. Custom Subagents.claude/agents/*.md, YAML frontmatter defines tools/model/memory
  2. Custom Commands.claude/commands/*.md, parameterized with $ARGUMENTS
  3. Custom Skills.claude/skills/<name>/SKILL.md, description drives auto-discovery
  4. Hooks Automation — settings.json configures lifecycle hooks (PreToolUse/PostToolUse/Stop)
  5. Rules Conditional Loading.claude/rules/*.md + paths: to scope
  6. Permission Templates — allowed-tools controls at tool+path granularity
  7. Model Selection — haiku for simple, opus for complex, sonnet for balance
  8. Effort Tuning — low for quick response, max for deep reasoning
  9. Memory scopes — user (global) / project (team) / local (personal)
  10. MCP Integration — Connect external tools (databases, browsers, APIs)
  11. Worktree Isolation--worktree or isolation: "worktree" for independent experiments
  12. Background Tasks — Long tasks run in background, notification on completion

10 Advanced Tips

  1. Plan Mode First — Use /plan for complex tasks, state goals not steps
  2. Agent parallel orchestration — dispatch independent tasks simultaneously, leveraging context isolation
  3. Skills progressive disclosure — description always loaded, full content on demand
  4. Context Budget 50% — Proactively /compact, stay in the smart zone
  5. code-reviewer for Consistency — Cross-validate cross-file logic
  6. Iterative Refinement — Better than one-shot perfection, progressively approach the goal
  7. Error Recovery: /undo First — Reverting is more reliable than patching
  8. Testing First — TDD red-green-refactor combined with AI
  9. Docs as Context — Good docs = good output, write WHY not WHAT in comments
  10. Monitor Context Usage/context for visual token distribution check

Code Review Tips

Test Time Compute: Code Review makes the model “think again” in an independent context, increasing output by 200%. Multi-Agent parallel review (security + performance + architecture) yields higher quality than single review.

  • effort: high for more thorough review, effort: low for fewer but more focused findings
  • Have AI play "adversary" role — raise objections rather than surface-level review
  • Auto-trigger before PR submission (Hooks PreToolUse config)
  • Use with --comment to add PR comments
  • Review scope: correctness, security vulnerabilities, code quality, project specs
  • Different Agents play different roles (security review vs performance review vs architecture review)

PR Statistics (Boris Cherny’s Real Data)

MetricValue
Daily contributions266/day
Total PRs141 (all squash merge)
Total lines changed45,032 lines
Median PRp50 = 118 lines
P90 PR490 lines
P99 PR2,978 lines
Smallest PR2 lines
Largest PR10,459 lines

Boris has approximately 100% new code written by AI, humans review and guide direction. Key is independent commits per file for clearer history.

2 Merge Tips

  1. Commit per file — Each file gets its own commit, clearer history, easier to review/revert
  2. Don't amend — Create new commits to preserve history, avoid overwriting pre-commit hook checks

6 Opus 4.7 Efficiency Tips

6 core efficiency improvement methods summarized by Boris Cherny after Opus 4.7 release.

  1. Auto Mode (Shift+Tab) — One-click full auto mode, Agent autonomously decides read/write/execute, no step-by-step confirmation
  2. /fewer-permission-prompts Skill — Preset skill that auto-configures common tool permissions, drastically reducing popup interruptions
  3. Recaps Summary — Agent auto-generates execution summary after each turn, keeping context clear
  4. Focus Mode (/focus) — Filters irrelevant output, showing only core decisions and results, ideal for long tasks
  5. Effort Levellow quick response (simple queries), medium default, high deep reasoning (code review), xhigh/max maximum depth (architecture design)
  6. Verification mode — backend: auto-start server to verify; frontend: Chrome Extension checks rendering; desktop: Computer Use automated UI testing

Auto Mode Best Practice: Use with effort: high and /focus, let Agent work autonomously at high reasoning depth, reporting only key decision points.

Thariq — Skill Design

Thariq Koya is an engineer on the Claude Code team at Anthropic, where he focuses on skill design, session management, and practical agentic workflows. The sections below distill his most-cited guidance — from internal Anthropic skill reviews (March 2026) and his field notes on real-world Claude Code usage. They’re the same patterns he follows when designing skills for production teams.

  • Single Responsibility — each Skill does one thing
  • Precise descriptions — determines auto-discovery accuracy
  • Use when_to_use wisely — reduce false triggers
  • Parameterized templates — arguments dynamic replacement
  • Path scoping — paths avoid irrelevant activation
  • Progressive disclosure — gradual loading

Thariq — Practical Tips

17 Mar Tips
  • /doctor for environment diagnostics
  • CLAUDE.md for constraints
  • haiku for cost savings
  • background for long tasks
  • disallowedTools to restrict dangerous operations
16 Apr Tips
  • Session management > Skill design
  • /compact at 50%
  • /undo > manual fixes
  • Split into independent subagents
  • Each < 50% context

Session Management — Deep Guide

Thariq’s deep Session management framework: understanding context degradation, branching strategies, subagent garbage collection.

Context Rot: At approximately 300k-400k tokens the model starts “forgetting” earlier conversation, output quality drops significantly. This is not a bug, but a mathematical property of attention.

5 Branching Strategies

  • StrategyScenarioDescription continueContinue from lastRestore full context to continue conversation rewindReturn to a pointUndo to specified step and restart clearFresh startClear context, start from scratch compactCompress & retainIntelligently compress while retaining key info subagentIsolated executionDispatch subagent, no main context pollution

Key Decision Table

  • ScenarioRecommended Action Context > 50%/compact or dispatch subagent Wrong directionrewind to divergence point, don’t correct in place Poor quality after compactUse /compact [brief] with summary instructions, or directly clear + CLAUDE.md Need to preserve historySubagent handles new tasks, main conversation stays lean Subagent context bloatSubagents have built-in GC — auto-collected after completion, no impact on main session

Compact vs Fresh: If conversation history is highly relevant (e.g. debugging chain), use compact + brief; if topic has completely shifted, clear and rebuild context from CLAUDE.md is more efficient. Typical cause of bad compact: vague compression instructions causing key constraints to be dropped.

83 Categorized Tips

From community practices and official recommendations, organized into 16 tool categories. Core references: CLAUDE.md conventions, Subagents parallelism, RPI Workflow.

Prompting Tips (3)
  1. State goals not steps — Tell Claude what result you want, not how to do each step
  2. Negative instructions are more effective — "Don't do X" is more reliable than "please do Y"
  3. Example-driven — Provide input/output examples, more accurate than abstract descriptions
Planning (7)
  1. Use /plan for complex tasks first, state goals not detailed steps
  2. Split into independent subtasks, each < 50% context
  3. Use TaskCreate to track progress, set dependencies
  4. Plan Mode should clearly describe expectations, let model plan the path
  5. Multi-round iteration beats one-shot perfection — progressively approach the goal
  6. Priority ordering: core first then edge cases, blocking first then independent
  7. Estimate context consumption, avoid oversized single tasks
Context (5)
  1. /compact proactively at 50% context
  2. Use /compact [focus instructions] to retain key information
  3. Context budget management — regular cleanup in long conversations
  4. --resume / --continue to restore previous session
  5. Good docs = good output, write WHY not WHAT in comments
Session (6)
  1. Session management is more important than Skill design — longer sessions are smarter
  2. /compact at 50%, avoid quality degradation
  3. /undo > manual fixes — reverting is more reliable than post-hoc correction
  4. Split into independent subagents, Each < 50% context
  5. --continue seamlessly continue previous session
  6. maxTurns limits subagent turns, preventing infinite loops
CLAUDE.md (8)
  1. Writing great CLAUDE.md is the highest ROI optimization
  2. Under 200 lines — compliance drops beyond this
  3. Negative instructions — "don't do X" is more effective
  4. CLAUDE.local.md personal preferences without polluting team
  5. Only write information the model cannot infer on its own
  6. .claude/rules/*.md + paths: conditional loading
  7. claudeMdExcludes exclude unneeded CLAUDE.md files
  8. 4 scopes: global / project / directory / personal
Agents (4)
  1. Custom subagents .claude/agents/*.md, YAML frontmatter defines tools/model/memory
  2. Subagent parallelism — dispatch independent tasks simultaneously
  3. context: fork isolates subagent context, preventing main conversation pollution
  4. Specify model explicitly — haiku for simple, opus for complex
Commands (3)
  1. .claude/commands/*.md Custom commands
  2. $ARGUMENTS parameterized — command template dynamic replacement
  3. /project:command-name to call project commands
Skills (9)
  1. Single responsibility — each skill does one thing
  2. Precise descriptions — determines auto-discovery accuracy
  3. Use when_to_use wisely — reduce false triggers
  4. Progressive disclosure — gradual content loading
  5. Path scoping — avoid irrelevant activation
  6. Arguments parameterized template — dynamic replacement
  7. forceLoadSkills forced loading — preload critical skills
  8. disallowedTools restriction — skill-level tool control
  9. Pick the right type from 9 options — skill/agent/Explore/code-simplifier etc.
Hooks (5)
  1. PreToolUse intercepts and modifies before tool execution
  2. PostToolUse triggers automation after tool execution
  3. Stop executes cleanup when session ends
  4. Auto-trigger code review before PR submission
  5. Use hooks for repetitive operations — formatting, lint, notifications etc.
Workflows (5)
  1. RPI Loop: Research → Plan → Implement
  2. CRISPY: Clarify → Research → Ideate → Structure → Plan → Yield
  3. Cross-Model Collaboration: Claude plans + Codex/Gemini executes
  4. Agent Teams: Multi-Agent parallel (Amp, Codex, Claude)
  5. Scheduled Tasks: CronCreate timed scheduling for auto-execution
Advanced Workflows (9)
  1. Background agent avoids blocking main session
  2. Worktree isolated experiments — independent branch + context
  3. Goal-driven — set goals for model to achieve autonomously
  4. Session management > skill design — long session strategies first
  5. Browser MCP automated testing — Playwright or Chrome DevTools
  6. Multi-Provider multi-cloud deployment — Bedrock/Vertex/Foundry
  7. Sandbox isolation — network whitelist + filesystem restrictions
  8. Agent SDK for custom Agents — Python/TS SDK
  9. Computer Use GUI interaction — controlling desktop applications
Git / PR (5)
  1. Commit per file — each file gets its own commit
  2. Don't amend — create new commits to preserve history
  3. --comment auto-add PR comments
  4. 141 PRs / 45K lines / all squash merge
  5. Code Review 200% output increase — Test Time Compute
Debugging (6)
  1. /doctor for environment diagnostics — run this first when issues arise
  2. /undo to revert operations and code changes
  3. context: fork isolated experiments — safe trial and error
  4. maxTurns limits turns — preventing infinite loops
  5. effort: low quick diagnostics — improve efficiency
  6. /context visualize token distribution
Utilities (5)
  1. disallowedTools ban specific tools — security boundary
  2. MCP Server connects external services — databases/APIs/browsers
  3. allowedTools pre-approve tools — reduce confirmations
  4. includeContext inject extra files — enrich context
  5. env environment variable injection — unified config
Daily (2)
  1. Keyboard Shortcuts — Escape to interrupt, Shift+Tab to switch modes
  2. Regular /compact — proactively compress at 50% context

Video Highlights

Boris × Ryan Peterman Boris Cherny × Ryan Peterman — Career story of Claude Code's creator Beginner Boris × Lenny's Podcast Boris Cherny × Lenny's Podcast — Birth of Claude Code and product philosophy Product Karpathy Karpathy × AI Engineer — From Vibe Coding to Agentic Engineering Advanced Matt Pocock Matt Pocock Workshop — 2-hour Claude Code practical workshop Tutorial
Boris × Lenny's Podcast — Claude Code's Birth and the 100% AI Coding Era
  • Claude Code was born from an internal hackathon, evolving from a simple CLI into an Anthropic core product
  • "Latent Demand" is the core of product success — demand naturally explodes after lowering the barrier
  • Approximately 100% of new code in Claude Code is written by AI, humans review and guide direction
  • Plan Mode should state clear goals not detailed steps, let the model plan autonomously
  • "Bitter Lesson": Don't optimize workflows for current models, build systems for stronger models 6 months from now
  • CLAUDE.md should be minimal — only write information the model cannot infer on its own
  • Security layer designed as multi-layer defense: permission system + confirmation prompt + sandboxed execution
Boris × Pragmatic Engineer — Engineering Journey from Meta to Anthropic
  • Boris's career path from startup to Meta E8 embodies the generalist engineer philosophy — solving problems across domains
  • Claude Code architecture deliberately stays simple, using Bash tool instead of complex file operation tools
  • Anthropic internally uses Agentic Search (glob/grep) to completely replace RAG
  • Boris submits 20-30 PRs daily, using parallel Agents to handle multiple tasks simultaneously
  • During code review, have AI play "adversary" role, raising objections
  • Prototype culture is core — build fast, iterate fast, quickly discard approaches that don't work
Boris × Ryan Peterman — From E4 to E8 Engineer Growth
  • Meta promotion key is finding "latent demand" opportunities — Groups, Marketplace, Dating are all classic cases
  • Side projects (Undux ORM, TypeScript practical handbook) are important paths for technical growth
  • Generalist philosophy: don't define as "frontend" or "backend", be able to solve problems across domains
  • Claude Code was born from competitive pressure with Codex, going from prototype to product in extremely short time
  • In large organizations, the best influence is amplifying the entire team's efficiency through tools and systems
  • "Anti-Eating Own Dog Food" (using your own product at scale internally) is the best way to discover issues
Boris × Y Combinator — CLI's Unexpected Rise and AI Agent Topology
  • Claude Code choosing CLI over IDE plugin was accidental not planned — CLI's simplicity became an advantage
  • Agent topology is diverse: single Agent, parallel Agents, hierarchical Agents, different tasks suit different topologies
  • Multiple agents' context windows are uncorrelated — this is the theoretical basis for parallel execution
  • CLAUDE.md should be minimal — only write project-specific information the model cannot infer
  • Plan Mode is a temporary tool, as model capabilities improve dedicated planning mode will no longer be needed
  • Plugin ecosystem is built by "swarm" development — many external contributors building different plugins simultaneously
Cat & Boris × Every — Dual-Use Tool Design & Compounding Engineering
  • Dual-use tools: Claude Code serves both humans and AI, Slash commands are shared human-AI interface
  • "Adversary Subagent" pattern: one Agent submits expenses, another plays auditor raising objections
  • Compounding Engineering: every code change makes subsequent changes easier
  • "Unshipping" strategy: removing rarely-used features improves focus more than adding new ones
  • Subagent architecture breaks complex tasks into focused small tasks for parallel execution
Dex Horthy × MLOps — RPI to Crispy Methodology Evolution
  • The most common mistake in RPI is skipping Research and going directly to Plan
  • "Read code not plans" — must deeply understand existing codebase before planning
  • Instruction budget should be kept under 150-200 lines, beyond which model compliance drops significantly
  • Context Window has "smart zone" and "dumb zone" — first half understood well, second half often ignored
  • Vertical slices planning beats horizontal layers — each delivery is end-to-end verifiable functionality
  • "Crispy" methodology 7 steps, core is each step has clear completion criteria
  • Design discussions should produce 200 lines of refined plan not 1000 lines of verbose document
  • "No slop in 2026" — don't tolerate AI-generated redundant code and generic statements
  • Don't outsource thinking — you must understand every line of AI output, otherwise you can't verify
  • CRISPY Methodology Evolution — from RPI (Research→Plan→Implement) evolved into a more precise 7-step process, each step with crispy (clear) completion criteria
Karpathy × AI Engineer — Software 3.0 & Verifiability Principle
  • Software 1.0 (handwritten code), 2.0 (neural network weights), 3.0 (LLM prompts) three paradigms coexist
  • "Jagged Intelligence": LLMs surpass humans on some tasks yet make errors on simpler ones
  • Verifiability is the core principle of AI coding — only let AI do tasks that can be automatically verified
  • Vibe Coding suits rapid prototyping, Agentic Engineering suits production code
  • "Animals vs Ghosts" framework: understand whether code is an observable "animal" or an elusive "ghost"
  • Education philosophy: "Outsource thinking, but don't outsource understanding"
Matt Pocock Workshop — Smart/Dumb Zones, Vertical Slices & TDD
  • Smart/Dumb Zones: first half of context is the efficient processing zone, put key instructions here
  • "Grill Me" skill: have AI confirm it truly understands requirements through Q&A before coding
  • PRD goal document: transform requirements into clear "destination documents", let AI know success criteria
  • Vertical Slices (Tracer Bullets): each slice is a complete feature from UI to database
  • AFK Agent Loop ("Ralph Loop"): Agent continues working in a loop while unattended
  • TDD red-green-refactor with AI: write failing test first (red), AI implements (green), AI refactors
  • Deep vs Shallow Modules: design deep modules with simple interfaces, reducing surface area AI needs to understand
  • Sand Castle Parallelism: independent tasks assigned to multiple Agents, progressively stacked

Cheat Sheet

Common Commands · CLI Flags · Environment Variables · Config Templates

Common Commands (82 built-in)

Session Management
CommandDescription
/clearClear context and start new conversation (aliases /reset, /new)
/compact [instructions]Compress context, optionally with focus instructions
/resume [session]Resume session (alias /continue)
/branch [name]Fork current conversation (alias /fork)
/rewindRewind conversation and code (aliases /checkpoint, /undo)
/goal [condition]Set persistent goal, clear to remove
/stopStop background session
/exitExit CLI (alias /quit)
/background [prompt]Detach session to background (alias /bg)
/rename [name]Rename session
/recapGenerate one-line summary of current session
/btw <question>Quick sidebar question, not added to conversation
/workflowsView/manage workflow progress
Model (Model)
CommandDescription
/model [model]Switch model, ← → to adjust effort
/effort [level]Set reasoning effort low~max/ultracode
/fast [on|off]Fast mode toggle
/plan [description]Enter plan mode
/ultraplan <prompt>Draft plan in browser, execute remotely or locally
/passesShare one week Free Claude Code (eligible users only)
Config (Configure)
CommandDescription
/configSettings interface (alias /settings)
/permissionsManage permission rules (alias /allowed-tools)
/sandboxToggle sandbox mode
/statuslineConfigure status line
/keybindingsCustom keybindings
/themeSwitch theme (includes light/dark/colorblind-friendly/custom)
/tui [default|fullscreen]Render mode
/voice [hold|tap|off]Voice dictation
/focusFocus view (hide intermediate steps)
/color [color|default]Set prompt bar color (red/blue/green etc.)
/radioOpen Claude FM lo-fi radio in browser
/scroll-speedInteractively adjust mouse scroll speed
/stickersOrder Claude Code stickers
/terminal-setupConfigure terminal shortcuts (Shift+Enter, etc.)
/privacy-settingsView and update privacy settings (Pro/Max)
Context & Cost
CommandDescription
/contextVisualize context usage
/usageSession cost and usage (aliases /cost, /stats)
/usage-creditsConfigure usage credits
/insightsUsage pattern analysis report
/statusVersion, model, account status
Extensions
CommandDescription
/agentsManage agent configs
/mcpManage MCP servers
/pluginManage plugins
/reload-pluginsReload all active plugins (no restart needed)
/reload-skillsRescan skills/commands directories
/skillsList available skills (sorted by t for token count)
/hooksView hooks config
/ideManage IDE integrations
/chromeChrome settings
/memoryEdit CLAUDE.md and auto memory
Project
CommandDescription
/initInitialize project CLAUDE.md
/diffInteractive diff viewer
/reviewLocal PR review
/ultrareview [PR]Cloud-based deep multi-agent review
/security-reviewSecurity vulnerability analysis
/add-dir <path>Add working directory
/team-onboardingGenerate team onboarding guide
Remote & Automation
CommandDescription
/teleportPull web session to local (alias /tp)
/remote-controlRemote control session (alias /rc)
/scheduleCreate/manage scheduled tasks (alias /routines)
/desktopContinue in Desktop app (alias /app)
/mobileDownload mobile App (aliases /ios, /android)
/autofix-prAuto-fix PR CI failures
/remote-envConfigure default remote environment
/web-setupConnect GitHub to web via gh CLI
/install-github-appSet up GitHub Actions app
/install-slack-appInstall Slack app
Debug & Auth
CommandDescription
/doctorEnvironment diagnostics (press f for auto-fix)
/loginLog in to Anthropic account
/logoutLog out
/setup-bedrockConfigure Bedrock auth (requires env var)
/setup-vertexConfigure Vertex AI auth (requires env var)
/upgradeUpgrade to a higher plan
/helpHelp information
/feedbackSubmit feedback or report bug (aliases /bug, /share)
/heapdumpExport JS heap snapshot to ~/Desktop
/powerupInteractive feature exploration course
/release-notesInteractive release notes viewer
/tasksManage background tasks (alias /bashes)
Export
CommandDescription
/copy [N]Copy recent response to clipboard (N=which one)
/export [filename]Export conversation as plain text
Subcommands (run directly in terminal)
CommandDescription
claudeStart interactive REPL
claude "question"Start with initial prompt
claude agentsList configured agents
claude authManage authentication
claude installInstall or switch native build
claude remote-controlManage remote control sessions
claude doctorCLI diagnostics
claude mcpConfigure MCP (add/remove/list/get/enable)
claude pluginManage plugins
claude setup-tokenCreate long-lived token
claude updateUpdate version

CLI Flags (16 categories)

Complete CLI startup flags reference, organized by function.

Session Management
FlagShortDescription
--continue-cContinue most recent conversation
--resume-rResume session by ID/name
--from-prResume session associated with PR
--fork-sessionCreate new session ID on resume
--session-idSpecify session UUID
--no-session-persistenceDisable session persistence (print mode only)
--remoteCreate claude.ai web session
--teleportWeb session to local terminal
Model & Configuration
FlagDescription
--model <NAME>Set model (sonnet/opus/haiku or full ID)
--fallback-modelFallback when primary model overloaded (print mode)
--betas <LIST>Beta feature headers (API key users)
Permissions & Security
FlagDescription
--dangerously-skip-permissionsSkip all permission prompts (use with extreme caution)
--allow-dangerously-skip-permissionsAllow skipping permissions (doesn't activate, just enables option)
--permission-mode <MODE>Permission Mode: default/plan/acceptEdits/bypassPermissions
--permission-prompt-tool <TOOL>Use MCP tool for permission prompts in non-interactive mode
--allowedToolsPre-approved tool list
--disallowedToolsFully removed tools
--toolsRestrict available tool set
Output & Format
FlagShortDescription
--print-pNon-interactive / headless mode
--output-formattext / json / stream-json
--input-formattext / stream-json
--json-schemaOutput matching JSON Schema (print mode)
--verboseVerbose logging
--include-partial-messagesInclude streaming partial events (requires --print + stream-json)
System Prompt
FlagDescription
--system-prompt <TEXT>Replace entire system prompt
--system-prompt-file <PATH>Load system prompt from file
--append-system-prompt <TEXT>Append to default prompt
--append-system-prompt-file <PATH>Append prompt from file
Agent & Subagent
FlagDescription
--agent <NAME>Specify agent
--agents <JSON>Dynamically define subagents
--teammate-mode <MODE>Agent display: auto/in-process/tmux
MCP & Plugins
FlagDescription
--mcp-config <PATH|JSON>Load MCP server configuration
--strict-mcp-configOnly use specified MCP config
--plugin-dir <PATH>Load plugin directory (repeatable)
Directory & Workspace
FlagDescription
--add-dir <PATH>Add working directory
--worktree / -wStart in isolated worktree
Budget & Limits
FlagDescription
--max-budget-usdMaximum cost (print mode)
--max-turnsMaximum turns (print mode)
Integration
FlagDescription
--chrome / --no-chromeBrowser integration toggle
--ideAuto-connect IDE
Initialization & Maintenance
FlagDescription
--initRun init hooks and start interactive mode
--init-onlyRun init hooks then exit (no interactive)
--maintenanceRun maintenance hooks then exit
Debug & Settings Override
FlagDescription
--debug <CATS>Debug categories (e.g. "api,hooks")
--settings <PATH|JSON>Override settings
--setting-sources <LIST>Specify load sources: user,project,local
--disable-slash-commandsDisable all skills and slash commands
Version & Help
FlagShortDescription
--version-vOutput version number
--help-hShow help

Environment Variables

Startup Environment Variables (shell config)
VariableDescription
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1Enable experimental Agent Teams
CLAUDE_CODE_TMPDIROverride temp file directory
DISABLE_AUTOUPDATER=1Disable auto-update
CLAUDE_CODE_EFFORT_LEVELControl reasoning depth
USE_BUILTIN_RIPGREP=0Use system ripgrep (Alpine)
CLAUDE_CODE_SIMPLESimple mode (Bash + Edit only)
CLAUDE_BASH_NO_LOGIN=1Skip login shell
CCR_FORCE_BUNDLE=1Force bundle upload (--remote)
Auth & Model & Provider
VariableDescription
ANTHROPIC_API_KEYAPI key (direct auth)
ANTHROPIC_AUTH_TOKENOAuth token
CLAUDE_CODE_USE_BEDROCK=1Use AWS Bedrock
CLAUDE_CODE_USE_VERTEX=1Use Google Vertex
CLAUDE_CODE_MODELDefault model ID
CLAUDE_CODE_SMALL_FAST_MODELFast/small model ID
MAX_THINKING_TOKENSMax thinking tokens
Sandbox & Security & Performance
VariableDescription
CLAUDE_CODE_SANDBOX_MODESandbox mode (docker/macOS/docker-arm)
CLAUDE_CODE_MAX_TURNSDefault max turns
CLAUDE_CODE_ENABLE_TASKS=1Enable task system
CLAUDE_CODE_DISABLE_BACKGROUND_TASKS=1Disable background tasks
CLAUDE_CODE_USE_POWERSHELL_TOOLEnable PowerShell tool
CLAUDE_CODE_SHELLCustom shell path
Display & MCP & Plugins & Telemetry
VariableDescription
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1Disable non-essential network requests
CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1Disable experimental betas
CLAUDE_MCP_TIMEOUTMCP tool timeout (ms)
CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1Load additional directory CLAUDE.md
CLAUDE_CODE_SKIP_DOCTOR_CHECKSkip startup diagnostics
CLAUDE_CODE_NO_ATTRIBUTION=1Skip commit attribution

Config Templates

CLAUDE.md Template
# Project Name

## Tech Stack
- Frontend: React + TypeScript
- Backend: Node.js + Express

## Coding Conventions
- File naming: kebab-case
- Components: functional + hooks
- Testing: Vitest

## Constraints
- Do not use any type
- Do not skip tests
- API must have error handling
.claude/settings.json Template
{
  "permissions": {
    "allow": ["Bash(npm run *)","Bash(git status)","Read","Grep","Glob"],
    "deny": ["Bash(rm -rf *)","Bash(git push --force)"]
  }
}
Agent Definition Template
---
name: my-agent
description: Perform specific task
tools: "Bash,Read,Write,Edit,Grep"
model: sonnet
maxTurns: 20
memory: project
---

# My Agent
1. Read relevant files
2. Analyze code
3. Implement changes
4. Verify results
Skill Definition Template
---
name: my-skill
description: What to do
arguments: filename
allowed-tools: "Read,Write,Edit"
paths: "src/**/*.ts"
---

Process $filename: 
1. Read → 2. Transform → 3. Write back

Workflow Cheatsheet

RPI Workflow
  1. /rpi:research REQUEST.md
  2. Check GO/NO-GO
  3. /rpi:plan feature-name
  4. /rpi:implement feature-name
Cross-Model Collaboration
  1. Claude Code Plan Mode
  2. Codex CLI QA review
  3. Claude Code implement
  4. Codex CLI verify
Daily Development
  1. /plan to plan
  2. Confirm approach
  3. Implement
  4. /code-review to review
  5. /verify to verify
Troubleshooting
  1. /doctor to check
  2. /debug to debug
  3. /undo to revert
  4. /compact to clean