Agent skill

Karpathy System Prompt Learning

by LearnPrompt in LearnPrompt/andrej-karpathy-skills

Write explicit strategy into system prompts as a learning mechanism — making LLM behavior more predictable and teachable through prompt-as-textbook approach.

MITAuto-check passedAI & LLM Engineering

Install Karpathy System Prompt Learning

skills CLI
$ npx skills add LearnPrompt/andrej-karpathy-skills --skill karpathy-system-prompt-learning -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install LearnPrompt/andrej-karpathy-skills karpathy-system-prompt-learning --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/LearnPrompt/andrej-karpathy-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/karpathy-system-prompt-learning .claude/skills/karpathy-system-prompt-learning && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
karpathy-system-prompt-learning
GitHub stars
110
Token cost
~1.9k tokens
SKILL.md length
185 words
Files
1
Skills in repo
15
Repo updated
First seen
Licence
MIT

At a glance

Write explicit strategy into system prompts as a learning mechanism — making LLM behavior more predictable and teachable through prompt-as-textbook approach.

  • The user wants to improve an agent
  • SKILL.md covers Core Principle, The System Prompt Learning…, Building a System Prompt from… and Improving an Existing System…, plus 6 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md
  • LLMs performance on a specific task through system prompts

What it does

Karpathy System Prompt Learning is an agent skill from LearnPrompt/andrej-karpathy-skills. Write explicit strategy into system prompts as a learning mechanism — making LLM behavior more predictable and teachable through prompt-as-textbook approach. Use this skill when the user wants to improve an agent or LLM's performance on a specific task through system prompts, needs to encode a strategy or workflow into a prompt, wants consistent LLM behavior, or says "improve system prompt", "encode this strategy", "prompt engineering", "make agent follow this workflow", "prompt as textbook". Based on Karpathy…

Its SKILL.md is about 1.9k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in AI & LLM Engineering, covering Prompt engineering. The repository describes itself as: Karpathy-inspired Agent Skills collection. The licence is MIT.

When your agent uses it

  • The user wants to improve an agent
  • LLMs performance on a specific task through system prompts
  • Needs to encode a strategy
  • Workflow into a prompt

Example prompts

  • “improve system prompt”
  • “encode this strategy”
  • “prompt engineering”
  • “/karpathy-system-prompt-learning”

What it can do on your machine

Read from SKILL.md and the folder at commit 9e46dec. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are markdown).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • x.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Karpathy System Prompt Learning loads about 1.9k tokens when it runs. Until then it costs about 144 tokens; SKILL.md has 185 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~144
When it runs · the whole SKILL.md, loaded when a task matches
~1.9k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from LearnPrompt/andrej-karpathy-skills at commit 9e46dec, republished under its MIT licence (© LearnPrompt). 185 words, ~1,852 tokens.

Download SKILL.mdSave it as .claude/skills/karpathy-system-prompt-learning/SKILL.md (or your agent's skills folder).
name
karpathy-system-prompt-learning
description
Write explicit strategy into system prompts as a learning mechanism — making LLM behavior more predictable and teachable through prompt-as-textbook approach. Use this skill when the user wants to improve an agent or LLM's performance on a specific task through system prompts, needs to encode a strategy or workflow into a prompt, wants consistent LLM behavior, or says "improve system prompt", "encode this strategy", "prompt engineering", "make agent follow this workflow", "prompt as textbook". Based on Karpathy system prompt learning post.
disable-model-invocation
false
user-invocable
true
related_skills
karpathy-understanding-first, karpathy-llm-simulator, karpathy-agentic-engineering, karpathy-practice-environments

Skill 13: System Prompt Learning(系统提示学习范式)

Source: https://x.com/karpathy/status/1921368644069765486 "System prompt learning — missing LLM learning paradigm"

Core Principle

The system prompt is a textbook. Write it like one.

Karpathy's insight: there are three learning modes for LLMs (pretrain, finetune, RL) — but there's a fourth that's massively underused: system prompt learning. Explicitly encoding strategy into the system prompt is more sample-efficient than retraining and more reliable than hoping the model figures it out.

Think of it as writing a textbook for the LLM before each task. Not just instructions — strategy with reasoning.

The System Prompt Learning Framework

Good system prompts have three layers (mirroring how humans learn):

Layer 1: EXPOSITION (pretrain equivalent)
→ Background knowledge the model needs
→ Relevant concepts, terminology, context
→ "Here's what you need to know about [domain]"

Layer 2: WORKED EXAMPLES (SFT equivalent)  
→ Step-by-step demonstration of correct behavior
→ Explicit reasoning traces
→ "Here's exactly how to handle [situation]"

Layer 3: STRATEGY (RL equivalent)
→ Explicit decision rules
→ Error patterns to avoid
→ "When you see X, do Y because Z"

Building a System Prompt from Scratch

Build a system prompt that teaches an LLM to [TASK] reliably.

Task description: [WHAT THE LLM SHOULD DO]
Current failure mode: [HOW IT CURRENTLY GOES WRONG]
Desired behavior: [EXACTLY WHAT GOOD LOOKS LIKE]

Structure the system prompt with all three learning layers:

Layer 1 — Exposition:
Write 2-3 paragraphs of background knowledge the LLM needs. 
Include: key concepts, relevant context, domain vocabulary.

Layer 2 — Worked Examples:
Write 2 complete examples of the task done correctly.
Format: INPUT → [step-by-step reasoning] → OUTPUT
Show the thinking, not just the answer.

Layer 3 — Strategy:
Write explicit decision rules as IF/THEN/BECAUSE statements.
Include: common mistakes to avoid, edge cases to handle, quality checks.

End with: "Before responding, verify: [checklist of 3-5 quality checks]"

Improving an Existing System Prompt

When your current system prompt isn't working well:

Diagnose and improve this system prompt.

Current system prompt:
[PASTE CURRENT PROMPT]

Failure mode I'm seeing:
[DESCRIBE HOW IT'S GOING WRONG]

Example of bad output:
[PASTE BAD EXAMPLE]

Example of good output:
[PASTE GOOD EXAMPLE]

Analysis:
1. What's missing from the exposition layer? (background knowledge gaps)
2. What worked examples should I add?
3. What explicit rules would prevent this failure mode?
4. Is the prompt too restrictive? Too vague? Wrong framing?

Output: improved version of the system prompt with changes annotated.

Strategy Encoding Templates

For coding tasks
SYSTEM PROMPT: [CODING TASK]

You are an expert [LANGUAGE] developer. Follow this exact strategy:

UNDERSTANDING PHASE (always do this first):
- Restate the task in your own words
- List all edge cases you can think of
- Identify the one tricky part

IMPLEMENTATION PHASE:
- Start with the simplest working version
- Add complexity only when simple version fails
- Comment every non-obvious line with WHY

VERIFICATION PHASE (always do this last):
- Trace through your code with one concrete example
- Check: does it handle empty input? Large input? Wrong type?
- Confirm: could a junior dev maintain this?

NEVER:
- Assume the input is well-formed without checking
- Add dependencies without saying why
- Write clever code when simple code works
For analysis tasks
SYSTEM PROMPT: [ANALYSIS TASK]

You are an analytical expert. Follow this strategy:

GROUNDING:
- Always cite specific evidence before making claims
- Confidence levels: CERTAIN / LIKELY / SPECULATIVE — always label which
- If you don't know something, say so explicitly

STRUCTURE:
- Lead with the conclusion, then the evidence
- One claim per paragraph
- Maximum 3 levels of nesting

QUALITY CHECKS before responding:
- [ ] Every claim has evidence?
- [ ] Confidence levels labeled?
- [ ] Would an expert in this field agree with this framing?
- [ ] Am I answering the actual question or a related easier one?
For creative/writing tasks
SYSTEM PROMPT: [WRITING TASK]

Writing strategy for this task:

VOICE:
[Describe the tone, style, what to avoid]

STRUCTURE:
[Describe the expected output format]

QUALITY STANDARD:
A response is good when [describe what success looks like].
A response is bad when [describe common failure modes].

EXAMPLE OF GOOD OUTPUT:
[Paste one example]

EXAMPLE OF BAD OUTPUT (and why):
[Paste one example with annotation]

Prompt Version Control

Track your system prompt iterations like code:

markdown
# [PROMPT NAME] — Version History

## v3 (current) — [DATE]
Change: Added explicit "verification phase" checklist
Reason: v2 was skipping edge case checking
Result: Failure rate dropped from ~30% to ~5%

## v2 — [DATE]
Change: Added worked examples section
Reason: v1 was too abstract; model wasn't following the strategy
Result: Moderate improvement

## v1 — [DATE]
Initial version: [PASTE]

The Meta-Prompt (write prompts with an LLM)

Help me write a system prompt for this agent.

Agent task: [WHAT IT SHOULD DO]
I'll be using this with: [CLAUDE / GPT-4 / etc.]
Critical behavior: [WHAT MUST ALWAYS HAPPEN]
Failure modes to prevent: [WHAT GOES WRONG WITHOUT GOOD PROMPTING]

Apply the three-layer system prompt learning framework:
1. Exposition (what the model needs to know)
2. Worked examples (demonstrate correct behavior)
3. Strategy rules (explicit IF/THEN/BECAUSE)

Then: suggest 3 variations I could test to find the best version.

Workflow

属于工作流:反偏见决策(第3步/终点)

位置上游下游
第3步(沉淀)karpathy-understanding-first(验证后)沉淀完成,可复用

完整链路:llm-simulator → understanding-first → system-prompt-learning

也在日常开发中独立使用——任何时候 Agent 反复犯同一类错,都应该触发本 Skill。

Prompt Contract

text
Extract a system prompt lesson from this failure/pattern: <DESCRIBE_THE_RECURRING_ERROR>. Produce: 1) Trigger condition — when does this error occur, 2) Correct strategy — step-by-step what the agent should do instead, 3) Anti-patterns — what specifically to avoid, 4) Worked example — a before/after showing the improvement, 5) Concise instruction block (< 200 words) ready to paste into system prompt or SKILL.md.

Verification Checklist

  • 触发条件描述具体(不是「有时候」)
  • 策略是 step-by-step 的(不是模糊建议)
  • 反模式列出了具体的错误做法
  • 有 before/after 对比示例
  • 指令块 < 200 words,可直接粘贴
  • 在新的测试 case 上验证过指令块有效

© LearnPrompt, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in karpathy-system-prompt-learning of LearnPrompt/andrej-karpathy-skills.

Open the folder on GitHubat commit 9e46dec

Compare with similar skills

Karpathy System Prompt Learning next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Karpathy System Prompt Learning compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Karpathy System Prompt Learning this skillLearnPrompt/andrej-karpathy-skills110—~1.9kAutomated safety check: PassMIT
Prompt Improverseverity1/claude-code-prompt-improver1.9k1 repos~1.7kAutomated safety check: PassMIT
Prompt Engineering Patternsynulihao/AgentSkillOS61814 repos~1.7kAutomated safety check: PassNone
Patch CreationPiebald-AI/tweakcc2.5k—~1.6kAutomated safety check: PassMIT
Senior Prompt Engineermaslennikov-ig/claude-code-orchestrator-kit2603 repos~1.4kAutomated safety check: PassCustom licence
Codex Fable5baskduf/FableCodex437—~1.6kAutomated safety check: PassAGPL-3.0

Similar skills

  • Prompt Improver

    severity1/claude-code-prompt-improver

    This skill enriches vague prompts with targeted research and clarification before execution.

    1.9k GitHub starsUsed in 1 repo~1.7k tokens
    AI & LLM EngineeringAuto-check passed
  • Prompt Engineering Patterns

    ynulihao/AgentSkillOS

    Master advanced prompt engineering techniques to maximize LLM performance, reliability, and controllability in production.

    618 GitHub starsUsed in 14 repos~1.7k tokens
    AI & LLM EngineeringAuto-check passed
  • Patch Creation

    Piebald-AI/tweakcc

    Create and register new patches for tweakcc. An agent skill from Piebald-AI/tweakcc.

    2.5k GitHub stars~1.6k tokensUpdated today
    AI & LLM EngineeringAuto-check passed
  • Senior Prompt Engineer

    maslennikov-ig/claude-code-orchestrator-kit

    Provides reference guides and Python scripts for prompt optimization, RAG evaluation, and agent orchestration when building or tuning LLM systems.

    260 GitHub starsUsed in 3 repos~1.4k tokens
    AI & LLM EngineeringAuto-check passed
  • Codex Fable5

    baskduf/FableCodex

    Apply a Claude Fable 5 inspired operating style inside Codex.

    437 GitHub stars~1.6k tokensUpdated 2 mo ago
    AI & LLM EngineeringAuto-check passed
  • Reference for designing and tuning production LLM prompts: few-shot examples, chain-of-thought, structured outputs, templates and system prompts.

    40k GitHub stars~1.3k tokensUpdated 5 days ago
    AI & LLM EngineeringAuto-check passed

More from LearnPrompt/andrej-karpathy-skills

All 15 skills in this repo
  • Karpathy Methodology Index

    LearnPrompt/andrej-karpathy-skills

    Apply Andrej Karpathy AI methodology and principles from his 2023-2026 insights. Use this skill when the user wants to apply Karpathy-style thinking, needs…

    110 GitHub stars~1.5k tokensUpdated 3 mo ago
    Auto-check passed
  • Karpathy Agentic Engineering

    LearnPrompt/andrej-karpathy-skills

    Apply Karpathy-style agentic engineering to any coding or building task.

    110 GitHub stars~1.2k tokensUpdated 3 mo ago
    Auto-check passed
  • AutoResearch Loop

    LearnPrompt/andrej-karpathy-skills

    Sets up an autonomous research loop where an agent runs experiments on git branches, logs results and proposes the next iteration while you approve each hypothesis change.

    110 GitHub stars~1.4k tokensUpdated 3 mo ago
    Auto-check passed
  • Karpathy Education First

    LearnPrompt/andrej-karpathy-skills

    Apply the education-first mindset — make everything you build teachable, create nano-project explanations, write for beginners.

    110 GitHub stars~1.8k tokensUpdated 3 mo ago
    Auto-check passed
  • Karpathy Idea Files

    LearnPrompt/andrej-karpathy-skills

    Create and share ideas as abstract Gist-style specs instead of code — letting agents or others implement.

    110 GitHub stars~1.5k tokensUpdated 3 mo ago
    Auto-check passed
  • Karpathy LLM Simulator

    LearnPrompt/andrej-karpathy-skills

    Use LLM as a simulator of expert debates and opposing viewpoints instead of getting a single sycophantic answer.

    110 GitHub stars~1.3k tokensUpdated 3 mo ago
    Auto-check passed

Questions about Karpathy System Prompt Learning

What does Karpathy System Prompt Learning do?

Write explicit strategy into system prompts as a learning mechanism — making LLM behavior more predictable and teachable through prompt-as-textbook approach. Karpathy System Prompt Learning is an agent skill from LearnPrompt/andrej-karpathy-skills. Write explicit strategy into system prompts as a learning mechanism — making LLM behavior more predictable and teachable through prompt-as-textbook approach.

When should I use Karpathy System Prompt Learning?

Karpathy System Prompt Learning fits situations like: the user wants to improve an agent; LLMs performance on a specific task through system prompts; needs to encode a strategy; workflow into a prompt.

How do I install Karpathy System Prompt Learning in Claude Code?

Run `npx skills add LearnPrompt/andrej-karpathy-skills --skill karpathy-system-prompt-learning -a claude-code`. Or copy the skill folder (karpathy-system-prompt-learning in LearnPrompt/andrej-karpathy-skills) into .claude/skills/karpathy-system-prompt-learning in your project. Claude Code loads it when a task matches its description.

How do I install Karpathy System Prompt Learning in Codex?

Run `npx skills add LearnPrompt/andrej-karpathy-skills --skill karpathy-system-prompt-learning -a codex`. Or copy the skill folder (karpathy-system-prompt-learning in LearnPrompt/andrej-karpathy-skills) into .agents/skills/karpathy-system-prompt-learning in your project. Codex loads it when a task matches its description.

Can I use Karpathy System Prompt Learning in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add LearnPrompt/andrej-karpathy-skills --skill karpathy-system-prompt-learning -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/karpathy-system-prompt-learning, .gemini/skills/karpathy-system-prompt-learning, .github/skills/karpathy-system-prompt-learning and .opencode/skills/karpathy-system-prompt-learning in your project.

What does Karpathy System Prompt Learning need to run?

SKILL.md names no scripts, command-line tools or credentials: Karpathy System Prompt Learning is instructions for the agent only.

Does Karpathy System Prompt Learning access the network?

SKILL.md names 1 domain. As links in the text: x.com. This is read from the text; nothing was executed.

Is Karpathy System Prompt Learning safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Karpathy System Prompt Learning use?

Karpathy System Prompt Learning is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Karpathy System Prompt Learning use?

About 1.9k tokens (SKILL.md is roughly 7.4k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Karpathy System Prompt Learning?

Skills that share tags, products or a category with Karpathy System Prompt Learning: Prompt Improver (severity1/claude-code-prompt-improver, 1.9k stars), Prompt Engineering Patterns (ynulihao/AgentSkillOS, 618 stars), Patch Creation (Piebald-AI/tweakcc, 2.5k stars) and Senior Prompt Engineer (maslennikov-ig/claude-code-orchestrator-kit, 260 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Karpathy System Prompt Learning?

LearnPrompt (a GitHub user) maintains it in LearnPrompt/andrej-karpathy-skills, which has 110 GitHub stars. The repository holds 15 skills in this directory. The repository was last updated on July 10, 2026.

Source: LearnPrompt/andrej-karpathy-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.