Skip to main content
Module 1: Core Agent 5 / 6
Beginner S05 Skills Knowledge System Prompt

Skills & Knowledge Loading

Understand Claude Code's two-layer knowledge injection — how skill names are loaded upfront while full definitions are deferred until needed.

March 20, 2026 16 min read
Verified Curriculum reviewed: Oct 21, 2026

What You’ll Learn

Claude Code has a rich set of skills — from code review to test running to debugging. But loading all skill definitions into the system prompt at once would waste precious context tokens. The solution: a two-layer injection system.

By the end, you’ll understand:

  • How skills and agents extend Claude Code’s capabilities
  • The two-layer loading pattern (names upfront, bodies on demand)
  • How CLAUDE.md files provide project-specific knowledge
  • The knowledge hierarchy and resolution order

The Problem

Claude Code can have dozens of skills (specialized prompts for specific tasks) and agents (specialized subagent configurations). Each skill’s full definition might be 500-2000 tokens. Loading all of them up front would add 10,000+ tokens to every request before the conversation even starts.

But the AI needs to know what skills are available so it can use them when appropriate.

How It Works

The Two-Layer System

Layer 1: Skill listing (always in context)
┌────────────────────────────────────────┐
│ Available skills:                       │
│ • commit — Git commit with quality      │
│ • review-pr — Review a pull request     │
│ • workflow — 5-step development flow    │
│ • test-runner — Run and analyze tests   │
│ • ...                                   │
│ (names + 1-line descriptions only)      │
└────────────────────────────────────────┘

Layer 2: On-Demand (loaded when invoked)
┌────────────────────────────────────────┐
│ [User types /commit]                    │
│                                         │
│ Full skill body injected:               │
│ • Step-by-step instructions             │
│ • Formatting rules                      │
│ • Examples                              │
│ • Edge case handling                    │
│ (500-2000 tokens)                       │
└────────────────────────────────────────┘

Layer 1 has a budget: the skill listing gets about 1% of the model’s context window. It always contains every skill name, but when it overflows, Claude Code drops descriptions starting with the skills you invoke least. Once a skill is invoked, its body enters the conversation and stays there across later turns.

Skill Definition Format

Each skill is a directory containing a SKILL.md file, such as .claude/skills/smart-commit/SKILL.md in a project or ~/.claude/skills/smart-commit/SKILL.md for all your projects. The file starts with YAML frontmatter:

---
name: smart-commit
description: Conventional Commits with quality checks
---

# Instructions

When the user asks to commit...
1. Run git status
2. Analyze changes
3. Draft commit message following Conventional Commits
4. Run pre-commit checks
...

The frontmatter (name, description) is loaded in Layer 1. The body (instructions) is loaded only when the skill is invoked. By default, both you (by typing /smart-commit) and Claude can invoke a skill. Two optional fields change that: disable-model-invocation: true lets only you start the skill and keeps its description out of context until then, which suits side-effecting workflows like commits and deploys; user-invocable: false hides it from the / menu so that only Claude loads it.

Knowledge Hierarchy

Claude Code assembles its knowledge from multiple sources. They don’t override one another; they are layered into context in this order:

Load order (earliest → latest in context):
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

1. System prompt (built-in)
2. Managed policy CLAUDE.md (organization)
3. User CLAUDE.md + rules (~/.claude/)
4. Project CLAUDE.md + rules (.claude/rules/*.md)
5. Local CLAUDE.local.md
6. Conversation history
7. User message (current prompt)

On demand: subdirectory CLAUDE.md files, path-scoped
rules, skill bodies, subagent definitions

The CLAUDE.md files are concatenated from the broadest scope to the most specific, so a project instruction appears after a user-level one. Their content arrives as a user message after the system prompt, so Claude treats it as context to follow, not enforced configuration. If two instructions conflict, Claude may follow either one, so remove contradictions instead of relying on precedence.

CLAUDE.md as Project Knowledge

The CLAUDE.md file is the most important knowledge injection point for project-specific context:

# Project: My E-commerce App

## Tech Stack
- Next.js 14 with App Router
- PostgreSQL with Prisma ORM
- Stripe for payments

## Development Commands
- `pnpm dev` — start dev server
- `pnpm test` — run tests with Vitest
- `pnpm db:migrate` — apply database migrations

## Conventions
- Use server components by default
- API routes in app/api/
- All prices stored in cents (integer)

This tells Claude Code exactly how to work with your project — what commands to run, what conventions to follow, where things are. In a repository that has no CLAUDE.md, Claude Code v2.1.277 and later reads AGENTS.md instead.

Agent Definitions

Agents work similarly to skills but define specialized subagent behaviors. Save this one as .claude/agents/code-reviewer.md:

---
name: code-reviewer
description: Expert code reviewer for quality, security, and best practices
tools: [Read, Grep, Glob, Bash]
---

Review the code for:
1. Security vulnerabilities (OWASP Top 10)
2. Performance issues
3. Code quality and maintainability
...

When the parent agent spawns a code-reviewer subagent, these instructions become the subagent’s system prompt, in place of the Claude Code system prompt.

Key Insight

The two-layer system is a token budget optimization. It’s the same principle behind lazy loading in web development — don’t load what you don’t need yet.

This design lets Claude Code carry dozens of skills and agents without paying their full context cost upfront. The AI knows what’s available (Layer 1) and can access full details when needed (Layer 2).

For your own projects, the key takeaway is: put project knowledge in CLAUDE.md, and move multi-step procedures into skills. CLAUDE.md is the most efficient way to give Claude Code the facts it needs in every session. A well-crafted CLAUDE.md is worth more than dozens of back-and-forth messages explaining your codebase.

Hands-On Example

Create a minimal skill at .claude/skills/deploy/SKILL.md:

---
name: deploy
description: Deploy to production with safety checks
disable-model-invocation: true
---

## Deploy Workflow

1. Run the test suite: `pnpm test`
2. If tests pass, build: `pnpm build`
3. Check for uncommitted changes
4. If clean, deploy: `pnpm deploy`
5. Verify deployment health check

## Safety Rules
- NEVER deploy if tests fail
- ALWAYS check for uncommitted changes first
- Ask for confirmation before deploying to production

This skill can be invoked with /deploy and provides structured guidance for the deployment process. Because of disable-model-invocation: true, Claude can’t decide to deploy on its own, and the skill’s description stays out of context until you run it. To see what each of your skills costs in context and which ones go unused, run /skill-doctor (v2.1.252 or later).

CLAUDE.md Design Tips

# DO: Be specific and actionable
"Use pnpm, not npm. Run tests with pnpm test."

# DON'T: Be vague
"Follow best practices for the project."

# DO: Include error handling guidance
"If pnpm install fails, try deleting node_modules and pnpm-lock.yaml first."

# DON'T: Include obvious things
"JavaScript files end in .js" (Claude already knows this)

What Changed

Loading EverythingTwo-Layer Loading
10,000+ tokens on every requestNames + short descriptions within a listing budget
Slow initial loadFast startup
Wastes context on unused skillsFull body only when invoked
Hard to scale skill countScales to dozens of skills; least-used descriptions drop first if the listing overflows
Project context via conversationProject context via CLAUDE.md

Next Session

Session 6 covers Context Compaction — what happens when the context window fills up, and how Claude Code’s 3-layer compression strategy keeps conversations going without losing critical information.