Complete Architecture Reference · 2025

Master Claude Code Skills · Agents · Memory

The complete guide to structuring Claude Code's extension stack — from global cross-project knowledge to project-specific automation, with the full tools annexure.

Watch the walkthrough

📚 Claude Code Series

Memory — CLAUDE.md Hierarchy

Claude Code reads memory files before every session. More specific files override broader ones. Understanding this hierarchy is the foundation of everything.

Key insight: The hierarchy loads bottom-up. Enterprise policies load first, personal preferences second, then project-level, then subdirectory-level. More specific instructions win on conflict.
LEVEL 1 · LOWEST PRIORITY
Managed Enterprise Policy
/etc/claude-code/CLAUDE.md  ·  /Library/Application Support/ClaudeCode/CLAUDE.md
Set by IT/DevOps. Org-wide security rules, approved tool lists, compliance constraints. Cannot be overridden by individuals. Use for: forbidden bash commands, required code style policies.
🏢 Enterprise
LEVEL 2
User Memory
~/.claude/CLAUDE.md
Your personal preferences across all projects. Package manager preference (pnpm vs npm), your code style, default test framework, preferred commit message format, personal shortcuts.
👤 Personal
LEVEL 3
User Rules (Modular)
~/.claude/rules/*.md
Break personal preferences into focused modules. Each .md file covers one domain — git.md for commit conventions, formatting.md for spacing/style, testing.md for test patterns. Symlinks here let you share rules across projects.
🔧 Modular
LEVEL 4 · PROJECT LEVEL
Project Memory
./CLAUDE.md  (repo root — commit this)
The most important file for team use. Stack description, test commands, architecture notes, team conventions, important file locations, patterns to follow/avoid. Keep under 300 lines — every irrelevant line competes with real instructions.
📄 Project
LEVEL 5
Project Rules (Modular)
./.claude/rules/*.md
Modular project rules. Can include path-scoped rules using paths frontmatter — e.g., rules that only apply when editing src/api/** vs src/ui/**. Perfect for monorepos with different standards per package.
⚙️ Rules
LEVEL 6
Project Local (Private)
./CLAUDE.local.md  (auto-gitignored)
Your personal project-level overrides. Never committed to git. Use for local API keys references, personal shortcut commands, your own staging environment config, WIP notes. Perfect for "my version" without affecting team.
🔒 Private
LEVEL 7 · HIGHEST PRIORITY
Subdirectory Memory
./src/CLAUDE.md  ·  ./packages/api/CLAUDE.md  etc.
Scoped to specific paths. The most specific rules win. Use in monorepos to set different standards per package — e.g., the mobile app package gets React Native patterns while the backend package gets Node.js patterns.
📍 Path-scoped
🤖 Auto Memory: Claude also generates its own memory at ~/.claude/projects/<hash>/memory/ — facts it learns during sessions like "user prefers verbose logging" or "this project uses pnpm". Use /memory to view and edit. Auto memory is gitignored.
CLAUDE.md
# Project: E-Commerce API (Node.js + PostgreSQL) ## Stack Runtime: Node.js 20, TypeScript 5.3 DB: PostgreSQL via Drizzle ORM Package Manager: pnpm (never use npm or yarn) ## Commands test: pnpm test:integration build: pnpm build migrate: pnpm drizzle-kit push ## Patterns - Controllers in src/controllers/, services in src/services/ - Never put business logic in controllers - All DB calls go through the repository layer - Use zod for all input validation ## Don't - Never use default exports - Never use any (use unknown + type guard)

Skills — Teachable Workflows

Skills are directories with a SKILL.md file that teach Claude how to handle specific tasks. Unlike CLAUDE.md facts, skills are procedural — they teach Claude what to do, step by step.

📦

What is a Skill?

A directory with a SKILL.md file containing YAML frontmatter (how it runs) and markdown content (what Claude does). Claude loads the file on-demand when your intent matches the skill's description — zero context window cost when idle.

🎯

Invocation Types

Skills can be invoked by Claude automatically (when it detects relevance), by you via slash command (e.g., /code-review), or by another agent. The frontmatter invocation field controls this.

🗃️

Bundled Supporting Files

Skills can include reference .md files, Python scripts, shell scripts, templates. Claude only loads what it needs for the specific task — a skill with 20 reference files only loads the relevant 2 for your request. Efficient token usage.

🔗

Agent Skills Open Standard

Claude Code skills follow the Agent Skills open standard — compatible with Cursor, Gemini CLI, Windsurf, Aider, GitHub Copilot, Zed, Warp, RooCode, and more. Build once, run everywhere in your AI toolchain.

Structure
code-review/ ← skill name = command └── SKILL.md ← required entrypoint └── CHECKLIST.md ← reference (loaded on demand) └── SECURITY-RULES.md ← reference └── scripts/ └── lint_check.py ← runs, only output enters context └── complexity_scan.sh
SKILL.md
--- name: code-review description: Review code changes for quality, security vulnerabilities, and style allowed-tools: Read, Grep, Glob, Bash invocation: auto # or: slash, agent version: 1.0.0 --- # Code Review Skill When invoked, perform a thorough review: 1. Security vulnerabilities (see SECURITY-RULES.md) 2. Test coverage gaps 3. Style consistency with project patterns 4. Run: scripts/lint_check.py $ARGUMENTS
FieldTypeDescriptionExample
namestringCreates the /name slash commandcode-review
descriptionstringClaude uses this for auto-matching your intentReview code for quality…
allowed-toolsstringComma-separated tools this skill can use without askingRead, Write, Bash(git*)
invocationenumauto | slash | agentauto
versionstringSemantic version for the skill1.2.0
modelstringOverride model for this skill (default: inherits)claude-haiku-4-5
contextstringUse fork to run in isolated agent contextfork
agentstringWhich subagent type runs this skillExplore
licensestringLicense reference (points to LICENSE.txt in skill dir)MIT
● Global Skill
~/.claude/skills/ └── CodeReview/SKILL.md └── Documentation/SKILL.md └── Testing/SKILL.md └── SecurityAudit/SKILL.md

Available across all your projects. Good for personal coding preferences, your favorite review checklists, documentation templates you always use. Stored in your home directory.

● Project Skill
.claude/skills/ └── DeployToProd/SKILL.md └── SeedTestDB/SKILL.md └── GenerateMigration/SKILL.md

Available only in this repository. Good for project-specific workflows: deploy scripts, seed data commands, project-specific test patterns. Committed to git — team shares them.

💡 Bundled Skills (ship with Claude Code): /simplify (3-agent parallel code review), /batch (large-scale parallel changes with git worktrees), /claude-api (auto-activates when Anthropic SDK is imported).

Agents — Specialized Subprocesses

Agents are separate Claude instances with their own context window, tool permissions, and model. Use agents when you need parallel execution, isolated memory, or a true specialist that should not be polluted with your main conversation context.

Built-in · Read-only

Explore

Uses Claude Haiku (fast, cheap). Fires automatically on "where is X?" or "find all files that…". Read-only tools. Perfect for codebase navigation.

Glob Grep Read
Built-in · Read-only

Plan

Inherits your current model. Used in plan mode for research before implementation. Analyzes requirements, produces implementation plans. Read-only.

Read Glob Grep
Built-in · Full Access

General-Purpose

Full tool access. Used for complex delegated tasks. Can spawn further sub-agents. Your main workhorse for autonomous multi-step work.

All Tools Bash Write
~/.claude/agents/security-reviewer.md
--- name: security-reviewer description: Reviews code for security vulnerabilities, OWASP top 10, injection risks. Use after implementing auth, payments, or file I/O. tools: - Read - Glob - Grep - Bash model: claude-sonnet-4-6 memory: project --- # Security Reviewer Agent You are an expert in application security. When given code, perform OWASP analysis...

Agent Frontmatter Fields

FieldPurpose
nameAgent identifier & command
descriptionWhen Claude auto-invokes it
toolsAllowed tools (principle of least privilege)
modelOverride model per agent
memoryproject | none | user
mcpServersMCP servers this agent can use
● Global Agent
~/.claude/agents/ └── researcher.md ← web research specialist └── security-reviewer.md └── code-explainer.md

Available in all projects. General-purpose specialists you always want — researcher, security reviewer, documentation writer.

● Project Agent
.claude/agents/ └── db-migration.md ← knows your schema └── api-designer.md ← knows your API conventions └── release-manager.md

Project-specific specialists with deep knowledge of your repo. Committed to git so your team shares them.

Complete File Hierarchy

Everything in one view — global vs. project-level, what's committed vs. gitignored, what's shared vs. personal.

GLOBAL (~/.claude/)
└── CLAUDE.md ← personal prefs └── rules/ │ └── formatting.md ← code style │ └── git-conventions.md ← git format │ └── testing.md ← test patterns └── skills/ │ └── CodeReview/ │ │ └── SKILL.md │ │ └── CHECKLIST.md │ └── Documentation/ │ │ └── SKILL.md │ └── SecurityAudit/ │ └── SKILL.md └── agents/ └── researcher.md └── security-reviewer.md
PROJECT (my-repo/)
└── CLAUDE.md ← ✓ committed └── CLAUDE.local.md ← ✗ gitignored └── src/ │ └── CLAUDE.md ← src rules └── .claude/ └── rules/ │ └── api-conventions.md │ └── db-patterns.md └── skills/ │ └── DeployToProd/ │ │ └── SKILL.md │ │ └── scripts/deploy.sh │ └── SeedDatabase/ │ └── SKILL.md └── agents/ └── db-migration.md └── api-designer.md
● Green = Global (~/.claude) — crosses all projects ● Pink = Project (.claude/) — this repo only ● Orange = Local — personal, gitignored

Decision Framework

The mental model is simple: Memory = what Claude knows, Skills = what Claude does, Agents = who Claude delegates to.

🧠

Memory

What Claude knows
  • Persist facts across sessions
  • Team conventions & stack info
  • Share rules across all projects
  • Path-scoped rules per module
  • Personal overrides (gitignored)
  • Enterprise-enforced policies
🛠️

Skills

What Claude does
  • Repeatable, multi-step workflows
  • Domain-specific procedures
  • Slash commands your team uses
  • Workflows with supporting scripts
  • Auto-triggered by intent matching
  • Bundle reference docs + scripts
🤖

Agents

Who Claude delegates to
  • Parallel / concurrent execution
  • Isolated context window needed
  • Specialist with restricted tools
  • Long-running background tasks
  • Different model per task type
  • Sub-agent orchestration
You want to…UseLocation
Persist facts across all sessionsCLAUDE.mdGlobal
Share rules across all your projects~/.claude/CLAUDE.md or rules/Global
Teach Claude a repeatable workflowSkillEither
Skill available everywhere~/.claude/skills/Global
Skill scoped to one repo.claude/skills/Project
Run parallel or isolated tasksAgentEither
Share an agent across projects~/.claude/agents/Global
Agent only in one project.claude/agents/Project
Personal overrides, not in gitCLAUDE.local.mdLocal
Path-specific rules (monorepo).claude/rules/*.md + pathsProject

Complete Tools Reference

Every tool available in Claude Code as of 2025 — built-in tools, permission scoping, and the complete allowed-tools syntax.

ToolCategoryDescriptionKey Parameters
Read File I/O Read any file — text, images (visual), PDFs (page selection), Jupyter notebooks. Returns content with line numbers. Supports pagination for large files. file_path, start_line?, end_line?
Write File I/O Create or overwrite a file entirely. Use for new files or complete rewrites. Sends all file content — use Edit for small targeted changes to avoid token waste. file_path, content
Edit File I/O Targeted find-and-replace within a file. Must Read the file first. Fails if the target string isn't found (safety guarantee). Far more token-efficient than Write for small changes. file_path, old_str, new_str, replace_all?
Bash Execution Execute shell commands in a persistent bash session. State persists across calls (env vars, working directory). Supports background processes. Git, npm, docker, pytest, any CLI tool. command, description, timeout?, restart?
Glob Search Fast file pattern matching. Returns list of matching paths sorted by modification time. Use for finding files before reading. More efficient than Bash find for file discovery. pattern, path?
Grep Search Regex search across file contents. Returns matching lines with context. Supports recursive search and file type filtering. Faster than Bash grep for codebase search. pattern, path?, recursive?, include?
WebFetch Web Fetch and read web pages. Returns text content. Useful for reading documentation, GitHub files, API references. Used by research agents and the /claude-api skill. url, prompt?
WebSearch Web Search the web and return results with snippets. Used by researcher agents. Combine with WebFetch to get full article content after finding relevant URLs. query
NotebookEdit File I/O Edit Jupyter notebook cells directly — add, update, or delete cells. Understands notebook structure: code cells, markdown cells, outputs. Works with .ipynb files natively. notebook_path, cell_index, new_source, cell_type?
TodoWrite Planning Manage the active task list. Create, update, and mark tasks as complete. Claude uses this internally to track multi-step work. Visible via /todos command. Persists through the session. todos: [{id, content, status, priority}]
BashOutput Execution Retrieve output from a running or completed background bash shell. Use when you launched a long-running process with Bash and need to check its output without blocking. shell_id
KillShell Execution Terminate a running background bash shell. Use to clean up long-running processes (dev servers, watchers) that are no longer needed. shell_id
SlashCommand Meta Execute slash commands within the conversation programmatically. Allows agents to trigger other skills and commands. Used for meta-orchestration patterns. command, args?
ExitPlanMode Meta Exit plan mode and transition to execution mode. Used by the Plan agent after producing an implementation plan. Signals Claude is ready to start making changes. (none)
ToolCategoryDescription
Task Agent Launch a specialized sub-agent for complex, multi-step tasks. The agent gets its own context window and tool access. Specify subagent_type: general-purpose, Explore, Plan, or any custom agent name from your .claude/agents/.
Skill (meta-tool) Skills The meta-tool managing all skills. Appears in Claude's tools array alongside Read, Write, Bash. Its description contains the formatted list of all available skills. Claude uses it to invoke the right skill by command name.
mcp__* MCP Tools dynamically loaded from connected MCP servers. Each server exposes its own set of tools prefixed with the server name. Examples: mcp__github__create_pr, mcp__postgres__query, mcp__stripe__create_payment.
Batching principle: Always batch independent tool calls in a single response for optimal performance. Never make sequential calls when parallel execution is possible — e.g., Read file1 + Read file2 + Read file3 simultaneously, not one after another.
.claude/settings.json
{ "permissions": { "allow": [ "Read", "Write(src/**)", // src only "Bash(git *)", // all git cmds "Bash(npm test*)", // test only "Bash(npx tsc*)", "Bash(npm run build)" ], "deny": [ "Read(.env*)", // protect secrets "Write(production.*)", "Bash(rm -rf *)", // block danger "Bash(sudo *)" ] } }
SyntaxMeaning
ToolNamePermit all uses of this tool
ToolName(*)Permit any argument (explicit wildcard)
ToolName(filter)Permit only matching calls
Write(src/**)Write only inside src/ (glob)
Bash(git *)Any git subcommand
Bash(git commit:*)git commit with any message
Read(.env*)Deny reading .env files (in deny list)
Note: Deny rules override allow rules. Claude walks the list first-to-last. Use .claude/settings.local.json for personal local overrides (auto-gitignored).

MCP (Model Context Protocol) servers extend Claude Code with tools from external services. Each server exposes tools that appear in Claude's tool list prefixed by the server name.

MCP ServerTypeKey Tools ExposedInstall Command
GitHub Official create_pr, list_issues, create_issue, search_code, get_file_contents, push_files npx @modelcontextprotocol/server-github
PostgreSQL Official query, list_tables, describe_table, execute_ddl npx @modelcontextprotocol/server-postgres
Filesystem Official read_file, write_file, list_directory, search_files, move_file, create_directory npx @modelcontextprotocol/server-filesystem
Brave Search Official brave_web_search, brave_local_search npx @modelcontextprotocol/server-brave-search
Slack Official post_message, list_channels, get_channel_history, add_reaction npx @modelcontextprotocol/server-slack
Puppeteer Official navigate, screenshot, click, fill_form, evaluate_js, pdf_export npx @modelcontextprotocol/server-puppeteer
Memory (KV) Official store_memory, retrieve_memory, search_memories, list_memories npx @modelcontextprotocol/server-memory
Google Drive Community list_files, read_file, create_file, update_file, share_file npx @modelcontextprotocol/server-gdrive
Stripe Community create_customer, create_payment, list_subscriptions, create_refund mcp.stripe.com/sse
Asana Community create_task, list_tasks, update_task, create_project, assign_task mcp.asana.com/sse
Perplexity Community search (deep web research with citations) via Perplexity API
Firecrawl Community scrape, crawl_site, search, extract (structured data from web) via Firecrawl API
Jira Community create_issue, list_issues, update_issue, add_comment, transition_issue via Atlassian MCP
Linear Community create_issue, list_issues, update_issue, list_projects, list_cycles via Linear MCP
Sentry Community list_issues, get_issue_details, generate_agents_md, create_fix via Sentry MCP
🔗 Adding MCP servers: claude mcp add --transport stdio github npx -y @modelcontextprotocol/server-github — stores config in .claude/mcp.json. Use --transport http for URL-based servers.