evolve-context
npx skills add https://github.com/llblab/skills --skill evolve-context
Agent 安装分布
Skill 文档
Self-Evolving Context Protocol
Basics
Activation
- ‘POST_TASK’ (default) â execute post-task protocol when task warrants it
- ‘ALWAYS_ON’ (opt-in) â monitor every interaction; use only when explicitly requested
- ‘ON_REQUEST’ â full context lifecycle audit when user asks
Paths
- ‘
SKILL_DIR‘ â the directory containing thisSKILL.mdfile (resolved by the agent at runtime) - ‘Scripts’:
${SKILL_DIR}/scripts/â skill automation scripts - ‘Detailed docs’:
${SKILL_DIR}/docs/protocols.mdâ full protocol specifications
Managed Targets
- ‘Root README’:
README.mdâ human entry point - ‘Index File’: One of
AGENTS.md|CLAUDE.md|CODEX.md|GEMINI.md|CONTEXT.md - ‘Docs Index’:
/docs/README.mdâ living index of/docs - ‘Project Docs’:
/docs/'â documentation files
Purpose
Maintain a living knowledge system that captures insights, prevents repeated mistakes, and evolves project documentation through structured feedback loops.
‘Target format’: GitHub-Flavored Markdown. ‘Sweet spot’: Projects with extensive documentation. ‘Core guarantee’: No insight is lost. No mistake is repeated. No documentation goes stale.
Axioms
A1: Reflexive Integrity
The protocol applies its own rules to itself. Process context (index file) â project docs (/docs).
A2: Constraint-Driven Evolution
Complexity is earned through discovered constraints, not invented upfront.
A3: Single Source of Truth
Every piece of knowledge lives in exactly one place. Navigate via hierarchy, never duplicate.
Three-Layer Architecture
Layer 0: README.md â "what is this & where to go"
Layer 1: AGENTS.md (index) â "how we work" (conventions, insights, mistakes)
Layer 2: /docs/README.md â "what docs exist"
Layer 3: /docs/' â "what we build"
Routing Decision Tree
About how we work? â Layer 1 (index file)
About what we build? â Layer 3 (/docs), then update Layer 2
About project identity? â Layer 0 (README.md)
Connectivity Invariant
README.md â /docs/README.md â /docs/’. README.md â AGENTS.md. Every doc reachable within 2 clicks from root. No dead ends.
Activation Modes
Mode 1: POST_TASK (Default)
‘Trigger decision tree’:
Task touched any *.md file? â YES â run POST_TASK
NO â Changed public APIs/architecture? â YES â run POST_TASK
NO â skip
‘Farmville guard’: Before writing any update, ask: “Does this prevent a future mistake or capture a non-obvious constraint?” If no â skip. Silence is a valid output. Measuring documentation activity instead of prevented errors is the Farmville trap.
‘Light post-task’ (default â â¤3 files changed, no architectural impact):
- EVALUATE â anything worth capturing? If no â skip
- ROUTE & WRITE â update appropriate layer
- SYNC â ensure /docs/README.md is current
‘Full post-task’ (>3 files changed OR architectural impact detected):
1â7. Full protocol steps (see protocols.md) 8. VALIDATE â bash "${SKILL_DIR}/scripts/validate-context"
Mode 2: ALWAYS_ON (Opt-in)
Only when explicitly requested by the user. Silently track during any task: surprises, wrong assumptions, recurring patterns, stale/missing/duplicated docs. Flag for post-task capture.
Cost: agent attention on every turn. Use only when task density justifies it.
Mode 3: ON_REQUEST (Explicit)
Full context lifecycle audit + validation. See protocols.md.
Pre-Task Protocol
1. READ index file â scan for relevant conventions and insights
2. READ /docs/README.md â understand documentation landscape
3. CHECK if similar task was done before â review past decisions
4. SCAN relevant /docs/' files
5. PROCEED with task execution
Entry Templates
Defaults for new files. If a file already has a format â match THAT format.
Full templates: docs/templates.md
Quick Reference
‘Index file entry’:
- '[label]': [description] | Trigger: [cause] | Action: [what to do]
‘Change History entry’:
- `[Current]` [Task]. Impact: [what changed]. Insight: [lesson learned].
‘Change History rotation’: [Current] â [Previous] â [Legacy-0] â [Legacy-1] â [Legacy-2] â CHANGELOG.md
Tooling: validate-context
Automated documentation health checker. Detects index file, validates links (skipping code blocks), analyzes bloat heuristically, checks docs index coverage.
- ‘Design’:
docs/validation-design.md - ‘Usage’:
bash "${SKILL_DIR}/scripts/validate-context"from project working directory - ‘Override root’:
VALIDATE_CONTEXT_ROOT=/path/to/project bash ... - ‘Exit 0’ = passed, ‘Exit 1’ = errors found
Lifecycle & Maintenance
- ‘Growth control’: Discovery â Active â Consolidation â Strategic Pattern â Archive
- ‘GC triggers’: 3+ bloat signals from validator â mandatory garbage collection
- ‘Change History’: Max 5 entries, rotate older to
CHANGELOG.md - ‘Mistake escalation’: Insight â Convention â Hard rule â Structural change
- ‘Details’: protocols.md