Skip to content
AI Growth Lab
Navigation menu
AI Growth Lab

Loading lesson…

CoursesContactPrivacy

Curriculum based on Datawhale / Easy Vibe · CC BY-NC-SA 4.0

← Back to course

AI-Native Engineer

Claude Code Fundamentals
  1. Getting Started with Claude Code
  2. Essential Claude Code Techniques
  3. Configuring Claude Code for Your Project
  4. Everyday Development Workflows
  5. Troubleshooting Claude Code
MCP: Connecting Claude Code to Tools
  1. Getting Started with MCP in Claude Code
  2. Using and Troubleshooting MCP
  3. Configuring Common MCP Servers
Claude Code Skills
  1. Finding and Using Your First Skills
  2. Understanding Skills and SKILL.md
  3. Creating and Improving Your Own Skills
  4. How Claude Skills Work Internally
Claude Agent Teams
  1. Understanding and Setting Up Agent Teams
  2. Build an RPG with Agent Teams
  3. Agent Teams Best Practices
  4. Choosing When to Use Agent Teams
AI-Assisted Development Workflows
  1. Choosing an AI Development Strategy
  2. Developing Features and Fixing Bugs with AI
  3. Refactoring and Reviewing Code with AI
  4. Building a Project Knowledge Base
  5. Improving AI Collaboration Efficiency
Building Agents with Claude Agent SDK
  1. Getting Started with Claude Agent SDK
  2. Advanced Features and Practical Agent Examples
  3. Building a Code-Quality Guardrail Pipeline
Engineering Workflows with Superpowers
  1. Getting Started with Superpowers and Its Core Skills
  2. Build an Authentication System with Superpowers
  3. Configuring and Using Superpowers Effectively
Spec Coding
  1. Spec Coding Foundations
  2. Practicing Spec Coding in Claude Code
  3. Moving from Vibe Coding to Spec Coding
  4. Spec Coding FAQ and Summary
GitHub Spec-Driven Development
  1. Workflow Foundations and Setup
  2. From Product Idea to Specification
  3. From Specification to Working Software
  4. Reusable Prompts and Responsible Autonomy
Cross-Platform Development
  1. From a Web Page to Real Software and an AI-Native Product
  2. How to Choose the Right Platform for Your App
  3. How to Build an Android App with Jetpack Compose
  4. How to Build an iOS App with SwiftUI
  5. Build a Store Inspection App with React Native and Expo

Lesson Contents

  1. Further Reading: The Internal Mechanism of Claude Skills
AI Development FAQ and Summary
How to Build a Cross-Platform App with Flutter
  • How to Build a PWA Local App
  • How to Build a Browser AI Assistant Extension
  • How to Build a Cross-Platform Electron Desktop App
  • How to Build Platform, Pixel-Art, and 3D Games with Godot
  • How to Build a VS Code Extension
  • How to Build an Industrial Qt Desktop App
  • How to Build Your Personal Website and Academic Blog
  • How to Publish the Application You Built
  • On this page
    • Further Reading: The Internal Mechanism of Claude Skills

    Further Reading: The Internal Mechanism of Claude Skills

    Next, we will go deeper into how Claude Skills work internally, so you not only know how to use them, but also understand why they are designed this way.

    First-principles view: prompt-based dynamic context injection

    First, understand one key fact: Skills are not executable code.

    Skills are essentially advanced instructions, or prompts, that are "injected" into Claude's context when needed. This design is called "Prompt-based Dynamic Context Injection & Meta-Tool Architecture."

    ┌─────────────┐      ┌─────────────┐      ┌──────────────┐
    │ User Request│ ───> │ LLM Matches │ ───> │ Trigger Skill│
    └─────────────┘      │Description  │      └──────────────┘
                         └─────────────┘              │
                                                     ▼
                                              ┌──────────────┐
                                              │ Inject Full  │
                                              │ Instructions │
                                              └──────────────┘
                                                     │
                                                     ▼
                                              ┌──────────────┐
                                              │ Execute Task │
                                              └──────────────┘
    

    Three-layer progressive loading architecture (token optimization)

    To handle a large number of Skills without consuming too many tokens, Claude uses a smart three-layer loading mechanism:

    LayerContentWhen loadedToken cost
    Layer 1: MetadataYAML frontmatter (name + description)When Claude starts~30-50 tokens/skill
    Layer 2: InstructionsFull SKILL.md contentWhen the Skill is triggered~5,000 tokens
    Layer 3: ResourcesScripts, templates, referencesAccessed from the file system on demandNot added to context

    Advantages of this design:

    • Suppose you have 100 Skills. At startup, only about 3,000-5,000 tokens are consumed for metadata
    • Only the triggered Skill loads its full content
    • Resource files such as reference documents are never fully loaded into the context

    Compared with no Skills:

    Without Skills: every conversation needs 50,000+ tokens to describe all capabilities
    With Skills: startup ~100 tokens/skill + 5,000 tokens loaded on demand
    Savings: on average 40,000+ tokens saved per conversation
    

    Dual context injection mechanism

    When a Skill is activated, the system makes two modifications at the same time:

    1. Conversation context injection

    // What the user sees (visible message)
    <command-message>The "pdf" skill is loading</command-message>
    
    // What the AI actually receives (hidden meta-message)
    {
      isMeta: true,  // marked as a meta-message, not shown in the UI
      content: `
        # PDF Analysis Expert Instructions
    
        You are a professional PDF analysis expert. Workflow:
        1. Use pdftotext to extract text
        2. Analyze the document structure
        3. Generate a summary report
        ...
      `  // full SKILL.md content, possibly thousands of words
    }
    

    2. Execution context modification

    Besides injecting instructions, a Skill can also dynamically modify Claude's environment:

    Modification typeExampleExplanation
    Tool permissionsallowed-tools: "Bash(pdftotext:*)"Temporarily grant access to a specific tool
    Model switchingSwitch from Sonnet to OpusSome complex tasks require stronger reasoning
    Context isolationCreate a child session spaceAvoid polluting the main conversation context

    A routing mechanism based entirely on LLM reasoning

    This is a very important design decision: Claude Skills do not use hardcoded routing.

    Traditional approachClaude Skills
    ❌ Embedding vector matching✅ Pure LLM reasoning
    ❌ Classifier✅ Transformer forward pass
    ❌ Regex or keyword matching✅ Natural language understanding
    ❌ Separate routing algorithm✅ Unified model decision-making

    Workflow:

    1. The name and description of every Skill are formatted into the Skill tool description
    
    2. Claude receives:
       - the user message
       - the list of available tools, including the Skill meta-tool
       - the Skill list, with name + description
    
    3. Claude's natural language understanding matches the user's intent to a Skill description
    
    4. When the match succeeds, it calls: command: "skill-name"
    

    Why design it this way?

    Hardcoded routing requires:

    • extra maintenance cost
    • no ability to understand complex semantic relationships
    • difficulty handling multiple languages
    • no support for fuzzy matching

    Pure LLM reasoning:

    • leverages Claude's own language understanding
    • automatically handles multiple languages, synonyms, and fuzzy descriptions
    • requires no extra maintenance
    • makes routing decisions more intelligent

    File parsing mechanism

    SKILL.md file structure:

    my-custom-skill/
    ├── SKILL.md              # Required: core definition file
    ├── config.json           # Optional: metadata config
    ├── README.md             # Recommended: usage documentation
    ├── scripts/              # Optional: executable scripts
    ├── templates/            # Optional: template folder
    └── references/           # Optional: reference documents
    

    Parsing flow:

    ┌─────────────────────────────────────────────────────────────┐
    │                    Claude Code startup                      │
    └─────────────────────────────────────────────────────────────┘
                                │
                                ▼
    ┌─────────────────────────────────────────────────────────────┐
    │  Scan ~/.claude/skills/ and .claude/skills/ directories    │
    └─────────────────────────────────────────────────────────────┘
                                │
                                ▼
    ┌─────────────────────────────────────────────────────────────┐
    │  Use the gray-matter library to parse each SKILL.md        │
    │  YAML frontmatter                                           │
    └─────────────────────────────────────────────────────────────┘
                                │
                                ▼
    ┌─────────────────────────────────────────────────────────────┐
    │  Validate required fields (name and description)           │
    │  - name: max 64 characters, only lowercase letters,        │
    │    numbers, and hyphens                                     │
    │  - description: used for LLM automatic matching            │
    └─────────────────────────────────────────────────────────────┘
                                │
                                ▼
    ┌─────────────────────────────────────────────────────────────┐
    │  Extract metadata and build the Skill list                 │
    │  (only load name + description, not the full body)         │
    └─────────────────────────────────────────────────────────────┘
    

    Example of the full execution flow

    Let's look at the entire flow through a concrete example:

    User: "Help me analyze this PDF file"
    
    ═══════════════════════════════════════════════════════════════
    
    Step 1: LLM decision
    ────────────────
    Claude finds the description of the "pdf" skill in the Skill list:
      description: "Analyze PDF document content, extract text, generate a summary"
    
    ═══════════════════════════════════════════════════════════════
    
    Step 2: System intervention
    ────────────────
    Claude Code executes:
      1. Read ~/.claude/skills/pdf/SKILL.md
      2. Generate a visible message: "The pdf skill is loading"
      3. Generate a hidden meta-message: the full SKILL.md content
      4. Modify session permissions: allowed-tools = ["Bash(pdftotext:*)"]
    
    ═══════════════════════════════════════════════════════════════
    
    Step 3: LLM execution
    ────────────────
    Now Claude's context contains:
      - the original user request
      - the PDF expert workflow instructions
      - access permission to the pdftotext tool
    
    Claude executes:
      1. Use pdftotext to extract the PDF text
      2. Analyze the content structure
      3. Generate a summary report
      4. Present the result to the user
    
    ═══════════════════════════════════════════════════════════════
    
    Step 4: Dispose after use
    ────────────────
    After the task is completed, the full Skill content is removed from context
    (only the conversation history remains, not the full Skill instruction)
    

    Core design innovations

    InnovationTraditional approachSkills approachAdvantage
    Source of capabilityFixed in model weightsDynamically loaded promptsExtensible and updatable
    Token efficiencyAll capabilities always stay in memoryLoad on demandSave 80%+ tokens
    Knowledge managementScattered in conversation historyModular file systemVersion-controllable and shareable
    LifecycleContinuously occupies spaceDispose after useCleaner context

    Academic foundations

    The design of Claude Skills draws on the following research:

    Research fieldRepresentative workApplied here as
    Reinforcement learningVoyager (2023)The idea of accumulating a skill library
    Cognitive architectureACT-R, SoarSeparation of procedural memory and declarative memory
    Hierarchical policyOptions FrameworkThree-layer progressive loading

    Core shift in thinking:

    Traditional: AI needs to remember everything
          ↓
    Skills: AI knows where to find specialized knowledge
          ↓
    Result: more like the thinking pattern of a human expert
    

    Relationship to the Agent Skills standard

    Claude Skills follows the Agent Skills open standard, which means:

    • ✅ Cross-platform compatibility: tools such as Cursor, Windsurf, and Aider also support it
    • ✅ Unified file format: standardized SKILL.md structure
    • ✅ Interoperability: Skills can be shared across different tools
    Agent Skills standard defines:
    ├── Required: SKILL.md file (metadata + instructions)
    ├── Optional: scripts/ (executable code)
    ├── Optional: references/ (knowledge base documents)
    └── Optional: assets/ (templates and resources)
    

    Summary: why is this design brilliant?

    1. Decouples capability from the model: specialized knowledge no longer depends on model training and can be updated at any time through Markdown files

    2. Extreme token efficiency: the three-layer loading mechanism ensures only necessary content is loaded

    3. Uses the LLM's own strengths: routing and matching rely entirely on Claude's language understanding, with no extra algorithm required

    4. Developer-friendly: creating a Skill only requires writing Markdown, not programming

    5. Composable: Skills can reference and combine with each other to form complex workflows

    6. Dispose after use: automatically cleans up after completion and keeps context fresh


    Summary

    Skills are the key to turning Claude Code from a "general assistant" into a "team expert."

    Through Skills, you can:

    • standardize workflows
    • reuse team knowledge
    • improve collaboration efficiency
    • reduce repeated explanation

    Remember: if you find yourself repeating the same instruction twice, you should consider creating a Skill.

    Now go create your first Skill.

    Previous
    Sign in to track progress
    Next