Agent Development Kit
6-layer model - understand the complete architecture
title: "Agent Development Kit" description: "6-layer model - understand the complete architecture" section: "Core" readTime: "18 min" badge: "POPULAR"
Agent Development Kit: The 6-Layer Model
"Claude Code isn't a coding assistant. It's an agent platform."
Most people are using 10% of it.
The key is understanding the 6-layer composition model that powers everything.
Layer 1: CLAUDE.md — Memory Layer
Your agent's constitution.
Think of it as an employee onboarding document, not a novel. Keep it under 200 lines.
## Tech Stack
- Node.js 20
- TypeScript
- React 19
## Conventions
- Kebab-case filenames
- camelCase variables
- ESLint strict mode
## Architecture
- /src/app (Next.js App Router)
- /src/components (React)
- /src/lib (utilities)
## Security
- No .env in git
- API keys environment-only
- Rate limiting on all endpointsWhat goes in CLAUDE.md:
- Tech stack (not installation instructions)
- Coding conventions (not tutorials)
- Architecture overview (not detailed design)
- Hard constraints (banned patterns, security rules)
- Key file locations (not every file)
What belongs in Skills instead:
- Multi-step workflows
- Complex procedures
- Decision trees
- Testing strategies
- Deployment procedures
CLAUDE.md is for facts you want in every session. Skills load on demand — only when you invoke them or Claude decides they're relevant. Auto memory (Layer 6) is what Claude writes for itself.
Layer 2: Skills — Knowledge Layer
Extend your agent with reusable knowledge modules.
Skills use the Agent Skills open standard (agentskills.io).
Skill Anatomy
---
name: db-migrate
description: "Safe schema migrations with rollback. Use when adding or changing database tables."
user-invocable: true
disable-model-invocation: false
allowed-tools: ["Read", "Bash(npx prisma *)"]
model: "sonnet"
effort: "high"
context: "fork"
hooks:
PostToolUse:
- matcher: "Bash"
hooks:
- type: command
if: "Bash(*ALTER TABLE*)"
command: "${CLAUDE_PROJECT_DIR}/.claude/hooks/validate-migration.sh"
paths:
- "db/migrations/**"
- "prisma/schema.prisma"
---
# Database Migration Skill
Use this skill to create safe migrations...
## Usage
- /db-migrate "add users table"
- /db-migrate --rollback
## Current schema
!`head -20 prisma/schema.prisma`Skill Frontmatter Fields
| Field | Type | Purpose |
|---|---|---|
name | string | Command name (lowercase, hyphens); defaults to the directory name |
description | string | What it does and when to use it — Claude uses this to decide when to load it |
when_to_use | string | Extra trigger phrases, appended to description |
argument-hint | string | Autocomplete hint, e.g. [issue-number] |
user-invocable | bool | false hides it from the / menu (Claude-only). Default true |
disable-model-invocation | bool | true stops Claude loading it automatically (you-only). Default false |
allowed-tools | string / list | Tools pre-approved (no permission prompt) while the skill runs — not a restriction |
disallowed-tools | string / list | Tools removed from Claude's pool while the skill is active |
model | string | Model override: any /model value (e.g. sonnet, opus, haiku) or inherit |
effort | string | Effort level: low, medium, high, xhigh, or max (depends on model) |
context | string | fork runs the skill in a forked subagent |
agent | string | Subagent type for context: fork (Explore, Plan, general-purpose, or a custom agent) |
hooks | object | Hooks keyed by event name, active for the rest of the session once invoked |
paths | string[] | Globs that limit automatic activation to matching files |
shell | string | Shell for !`command` injection: bash (default) or powershell |
Dynamic Context: Code Injection
$ARGUMENTS # All arguments as typed
$ARGUMENTS[0] # First argument (shorthand: $0)
${CLAUDE_SESSION_ID} # Current session UUID
${CLAUDE_SKILL_DIR} # Skill directory path
!`git log -1 --oneline` # Shell output injection (runs before Claude sees the skill)A skill is a directory with a required SKILL.md (e.g. .claude/skills/db-migrate/SKILL.md) plus optional supporting files such as reference.md or scripts/, which load only when needed. Keep SKILL.md under 500 lines.
Skill Scope Priority
- Enterprise (global across org, managed policy)
- Personal (
~/.claude/skills/) - Project (
.claude/skills/) - Plugin (namespaced as
/plugin-name:skill-name, so they never collide with the others)
When the same name exists at several levels, the higher one wins: enterprise over personal, personal over project.
Skill directories are watched live — adding or editing a SKILL.md takes effect in the current session without restarting. If you create a brand-new top-level skills directory mid-session, run /reload-skills.
In monorepos, skills in nested .claude/skills/ directories are discovered automatically the first time Claude reads or edits a file in that subdirectory.
Layer 3: Hooks — Guardrail Layer
Hooks intercept Claude Code at specific points:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"if": "Bash(rm *)",
"command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/confirm-rm.sh"
}
]
}
],
"PostToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"if": "Bash(git commit *)",
"command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/notify-commit.sh"
}
]
}
]
}
}Common Hook Events:
PreToolUse— Before a tool call; can block it or ask for confirmationPostToolUse— After a tool call succeedsNotification— When Claude Code sends a notificationStop— When Claude finishes respondingSessionEnd— When a session terminates
There are no dedicated events for commits or file deletion; filter PreToolUse/PostToolUse with matcher and if instead. See Hooks for the full format.
Layer 4: Subagents — Delegation Layer
Isolate context. Run agents in parallel.
---
context: fork # Runs in isolated subagent
---
This skill always runs in a fresh context window.
It starts in the same working directory and sees
the same files, but none of the main conversation.A subagent gets its own context window, system prompt, and tool access — but not a separate filesystem. For an isolated copy of the repo, a custom subagent can set isolation: worktree.
Built-in Agent Types:
- Explore agent (read-only codebase search and analysis)
- Plan agent (read-only research during plan mode)
- General-purpose agent (all tools; complex multi-step tasks)
Define your own as Markdown files with name/description frontmatter in .claude/agents/ (project) or ~/.claude/agents/ (personal).
Parallel Execution:
/batch migrate all API routes from Express to Fastify/batch takes one instruction, researches the codebase, splits the work into 5–30 independent units, and — after you approve the plan — runs one background subagent per unit in its own git worktree.
Each parallel agent consumes its own tokens, so parallelism costs more in total but saves wall-clock time.
Layer 5: Plugins — Distribution Layer
Bundle skills, subagents, hooks, and MCP servers into one installable unit. A plugin is a directory with a manifest — not an npm package:
acme-tools/
├── .claude-plugin/
│ └── plugin.json # manifest (only this file goes here)
├── skills/
│ ├── db-migrate/SKILL.md
│ └── deploy/SKILL.md
├── agents/reviewer.md
├── hooks/hooks.json
└── .mcp.json
{
"name": "acme-tools",
"description": "Acme's shared Claude Code setup",
"version": "1.0.0"
}Components are discovered from their standard directories; plugin skills run as /acme-tools:db-migrate.
Plugins are distributed through marketplaces (catalogs listed in a .claude-plugin/marketplace.json). Install:
# Inside a session (opens the plugin's details so you can pick a scope)
/plugin install commit-commands@claude-plugins-official
# From your shell
claude plugin marketplace add your-org/plugins
claude plugin install acme-tools@your-org --scope project
# Test locally without installing
claude --plugin-dir ./acme-toolsBundled Skills (Pre-Loaded)
| Skill | Command | Purpose |
|---|---|---|
| Batch | /batch <instruction> | Split a large change into units run by parallel agents in worktrees |
| Simplify | /simplify | 4 parallel review agents for reuse, simplification, efficiency, and abstraction level; applies fixes (not a bug hunt) |
| Code Review | /code-review | Review the current diff or a PR for correctness bugs (--fix to apply) |
| Debug | /debug | Turn on debug logging and troubleshoot from the session debug log |
| Loop | /loop [interval] [prompt] | Re-run a prompt on an interval while the session is open |
| Claude API | /claude-api | Load Claude API / Managed Agents reference for your project's language |
Type / for the full current list; the disableBundledSkills setting turns them all off.
Layer 6: Auto Memory — Learning Layer
Claude writes notes for itself across sessions — without you doing anything.
What Claude remembers:
- Build commands it discovered
- Debugging insights from your sessions
- Architecture patterns specific to your project
- Code style preferences it inferred
Storage: ~/.claude/projects/<project>/memory/MEMORY.md plus topic files (debugging.md, api-conventions.md, etc.).
The first 200 lines / 25KB of MEMORY.md load at every session start. Topic files load on demand.
# Browse and edit memory in a session
/memory| Mechanism | Written by | Loaded | Best for |
|---|---|---|---|
| CLAUDE.md | You | Every session (full) | Team standards, constraints |
| Auto memory | Claude | Every session (200 lines) | Learned insights, project patterns |
| Skills | You | On demand | Workflows, procedures |
Putting It Together: A Real Example
Project Structure:
├── CLAUDE.md # Layer 1: Memory
├── .claude/
│ ├── skills/
│ │ ├── db-migrate/SKILL.md # Layer 2: Skills
│ │ └── deploy/SKILL.md
│ ├── agents/ # Layer 4: Custom subagents
│ └── settings.json # Layer 3: Hooks
├── .mcp.json # MCP config (project root)
├── .git/
└── src/
User runs: claude "Add user authentication"
Agent process:
- Reads CLAUDE.md (constraints, tech stack)
- Checks hooks (pre-tool safety rules)
- Searches for relevant Skills
- Creates plan (ask for approval)
- Forks subagent if using isolation
- Executes with fallback to Layer 2, 3 constraints
- Logs via Hooks (Layer 3)
Programmatic Access: Claude Agent SDK
Every layer above also works when you embed Claude Code in your own app. The Claude Agent SDK (formerly the Claude Code SDK) gives Python and TypeScript the same tools, agent loop, and context management that power the CLI.
npm install @anthropic-ai/claude-agent-sdk # TypeScript (Node.js 18+)
pip install claude-agent-sdk # Python 3.10+
export ANTHROPIC_API_KEY=your-api-keyimport { query } from "@anthropic-ai/claude-agent-sdk";
for await (const message of query({
prompt: "Review utils.py for bugs that would cause crashes. Fix any issues you find.",
options: {
allowedTools: ["Read", "Edit", "Glob"],
permissionMode: "acceptEdits",
settingSources: ["user", "project"] // load CLAUDE.md, skills, hooks
}
})) {
if (message.type === "result") console.log(message.subtype);
}| Layer | How the SDK uses it |
|---|---|
| CLAUDE.md, skills, settings hooks | Loaded from disk via settingSources (omitted = ["user", "project", "local"], same as the CLI; [] = none) |
| Hooks | Filesystem hooks, plus programmatic callbacks passed in the hooks option |
| Subagents | agents option (and .claude/agents/ files) |
| Plugins | Loaded by local path through the SDK's plugin option |
| Auto memory | Read regardless of settingSources; disable with CLAUDE_CODE_DISABLE_AUTO_MEMORY=1 |
Products built on the Agent SDK must authenticate with an API key (or Bedrock / Vertex / Foundry credentials). Unless previously approved, third-party apps may not offer claude.ai login or rate limits.
See the Agent SDK overview for sessions, permissions, MCP, and hosting.
Composition Benefits
✅ Reusable knowledge (Skills)
✅ Safety guardrails (Hooks)
✅ Scalability (Plugins)
✅ Isolation (Subagents)
✅ Governance (CLAUDE.md)
✅ Persistent learning (Auto Memory)
Next: Explore Architecture for runtime details, or dive into Skills and Auto Memory for deep-dives.