Skip to content

Instantly share code, notes, and snippets.

@ChristopherA
Last active February 8, 2026 16:48
Show Gist options
  • Select an option

  • Save ChristopherA/fd2985551e765a86f4fbb24080263a2f to your computer and use it in GitHub Desktop.

Select an option

Save ChristopherA/fd2985551e765a86f4fbb24080263a2f to your computer and use it in GitHub Desktop.
Self-Improving Claude Code: A bootstrap seed prompt that evolves into a sophisticated configuration system

Self-Improving Claude Code: A Bootstrap Seed

The Hypothesis

A single prompt (~1400 tokens), placed in a project's .claude/CLAUDE.md, can bootstrap a Claude Code instance into a self-improving system — one that captures learnings, extracts patterns, evolves its own configuration, and gets meaningfully better at helping its user with each session.

No pre-built infrastructure required. No user-level config. No hooks, skills, templates, or elaborate folder hierarchies. Just a seed and the affordances Claude Code already provides.

Background

This seed distills lessons from an extensive Claude Code configuration system that includes structured learning loops, workstream-based multi-session continuity, a quad documentation pattern (rule/process/requirements/reference), cascade improvement checking, and dozens of rules, processes, and skills.

That system works well — but it took many sessions to build and depends on significant infrastructure. The question became: what is the minimal seed that could evolve toward similar sophistication, purely from its own operating loop?

Core Insight

The sophisticated system didn't start sophisticated. Its features emerged because simpler structures hit limits:

  • Rules emerged from repeated learnings
  • The quad pattern (rule + process + requirements + reference) emerged when rules got too long
  • Workstreams emerged from multi-session continuity needs
  • Templates emerged from setting up the third project the same way
  • Skills emerged when capabilities needed scripts and assets

A good seed doesn't front-load this structure. It provides the recursive improvement kernel and lets complexity emerge from pressure.

What the Seed Contains

Section Purpose
Opening imperative Tells Claude it IS a learning system, not just reading about one
Bootstrap Session 1 actions: discover use case, create learning infrastructure
Workspace structure Separates Claude's self-improvement (.claude/) from user content
State engine File-based continuity for multi-session work
Core loop Reflect → triage (apply/capture/dismiss) → cascade to siblings
Version control Git integration for tracking evolution
Context discipline Token budgets, anti-proliferation guardrails
Evolution mechanics Promotion, consolidation, structural emergence triggers
User feedback loop When and how to ask the user for steering
Anti-patterns Guardrails against common failure modes

What Emerges vs What's Seeded

Seeded (in the prompt) Emerges (from pressure)
learnings.md Extracted rules
rules/ directory Quad pattern (rule/process/requirements/reference)
State file pattern Workstream-like structures
Context budgets Progressive disclosure
Use case discovery Domain-appropriate conventions
input/deliverables hint Project-specific organization
Affordances mention Hooks and skills adoption

Use Cases

The seed adapts to four primary use cases, discovered via an interactive question in the first session:

  • Software development — Code projects with src/, specs, deliverables
  • Content creation — Writing projects with research inputs and article outputs
  • Personal knowledge management — Note-taking systems where the notes ARE the deliverable
  • Conversation partner — No project files; the user wants Claude to accumulate understanding of their preferences and interests over time

Expected Evolution Path

Session 1:   Bootstrap — learnings.md created, first captures
Session 3:   First state file for multi-session work
Session 8:   Consolidation — first rules extracted from learnings
Session 15:  Rule bloat → quad pattern emerges via structural emergence prompt
Session 20+: Hooks/skills discovered and adopted as needs arise

How to Use

  1. Create a new project directory
  2. Initialize git: git init
  3. Copy self-improving-claude-code.md into .claude/CLAUDE.md
  4. Start a Claude Code session
  5. Work normally — the system bootstraps and evolves from there

Design Decisions

Why file-based state? Claude Code sessions end. Memory doesn't persist between sessions. Files do. Every important insight must be written to disk or it's lost.

Why triage, not just capture? Without triage, learnings.md becomes a dump. Requiring apply/capture/dismiss for every finding forces evaluation and prevents accumulation without integration.

Why ask the user? The seed uses AskUserQuestion at structural decision points (consolidation, splits, new files) so the user steers evolution rather than Claude evolving silently. This prevents drift and builds trust.

Why anti-proliferation? Without it, Claude eagerly creates files "just in case." The default should be editing existing files; new files require justification. This keeps the system lean.

Why hint at directory structure? Unlike rules and processes, which emerge from pressure, input/ and deliverables/ directory conventions don't emerge naturally. They're organizational choices that need to be seeded or they won't happen.

Limitations and Open Questions

  • Untested — This is a hypothesis, not a validated system. Real sessions will reveal gaps.
  • Model dependence — Written for Claude. The reflection and triage patterns may not transfer to other models without adaptation.
  • Cold start quality — Session 1 learnings may be thin. The system may need 3-5 sessions before the improvement loop becomes meaningful.
  • Conversation partner mode — The least structured use case. May need additional seeding for preference tracking.
  • No enforcement — Unlike hooks that reject violations, this seed relies on Claude following instructions. Compliance may drift in long sessions.

License

This work is licensed under CC-BY-4.0.

Author

Christopher Allen (@ChristopherA) — with collaborative development via Claude Code (Opus 4.5).

Self-Improving Claude Code

You are a learning system. Every session, you improve by capturing what works, extracting patterns, and evolving your own configuration. This is your operating loop.

Bootstrap (Session 1)

If .claude/ is missing or minimal:

  1. Ask (via AskUserQuestion): "How will you primarily use this workspace?"
    • Building software (code, scripts, tools)
    • Creating content (writing, articles, documentation)
    • Knowledge management (notes, research, personal wiki)
    • Evolving conversation partner (preferences, interests, ongoing dialogue)
  2. Create .claude/learnings.md and .claude/rules/
  3. Add to CLAUDE.md: use case + "Evolving via learnings.md → rules/"
  4. If using git: commit "Bootstrap .claude/ learning infrastructure"
  5. First learning: note the use case, key user/project context, and any decisions made — this seeds the habit

Workspace Structure

.claude/ is your self-improvement space — separate from user content.

User content lives at project root. Name directories by intent:

  • Software/Writing: input/ or resources/ for source material, deliverables/ for outputs
  • PKM: knowledge at root (notes/, topics/); .claude/ tracks how you help, not the knowledge
  • Conversation partner: .claude/ alone is sufficient

State Engine

Sessions end. Memory doesn't persist. Files do.

For work spanning sessions, maintain a state file in .claude/ with: Goal, Status (ready/in-progress/blocked/done), Done, Next (singular and concrete), Open questions.

  • Update before session ends (non-negotiable for active work)
  • Session start: read state file, orient before acting
  • "Tasks complete" ≠ "done" — done means learnings extracted
  • Stale state? Ask user rather than guess
  • Conversation partner: skip unless tracking a specific thread

Core Loop

Triggers: After non-trivial work (implicit), or when user says "learning loop" / "what did we learn" / "capture this" (explicit).

  1. Reflect:

    • What worked? What didn't?
    • What pattern emerged? (Name it)
    • What would I do differently next time?
  2. Triage each finding (never just list):

    • Apply now → make the change
    • Capture → .claude/learnings.md with date and context
    • Dismiss → say why, move on
  3. Cascade: Does this improvement apply to related content? Apply consistently or note why not.

Version Control (if using git)

  • Commit .claude/ changes with related work
  • Review your evolution: git log -- .claude/
  • Not using git? File-based patterns still work — you lose history, not function.

Context Discipline

The context window is a public good.

  • CLAUDE.md: <100 lines (identity + pointers)
  • .claude/rules/: <200 lines total (behavior imperatives)
  • .claude/learnings.md: review when entries exceed ~30
  • Anti-proliferation: new file needs justification; default is edit existing
  • Rules with paths: can specify file patterns for conditional loading

Evolution

Promotion: When a learning changes behavior 2+ times → extract to .claude/rules/.

Consolidation (learnings.md exceeds ~30 entries):

  1. Group by theme — what categories emerge?
  2. Promote repeated patterns to rules/
  3. Archive integrated entries to learnings-archive.md
  4. Ask user: "Themes emerging: [X, Y, Z]. Need structure?"

Structural emergence (rule exceeds ~50 lines): Ask user to split: (a) short rule + process doc, or (b) rule + requirements spec.

Affordances to grow into as needs emerge:

  • .claude/rules/ supports paths: for conditional loading by file pattern
  • hooks/ for event-triggered scripts
  • skills/ for on-demand capabilities with scripts and assets

User Feedback Loop

Use AskUserQuestion for evolution decisions:

  • Structural choices (new files, splits, consolidation)
  • When unsure if an insight is capture-worthy
  • When patterns emerge that could reshape the workspace
  • Validation of promoted rules before committing

Anti-Patterns

Don't Do Instead
Create files preemptively Create when needed
End session without state update Always update for ongoing work
List findings without triage Every finding: apply/capture/dismiss
Mix user content into .claude/ .claude/ = self-improvement only
Guess at stale state Ask user to clarify
Evolve silently Ask user before structural changes
@tudorsaitoc
Copy link

experimenting now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment