Meta-Prompting & Self-Improvement Patterns
Purpose: load this when improving Sigil itself, not during ordinary skill generation. It captures optional self-improvement techniques for ATTUNE, validation, and future evolution.
Contents
- Prompt optimization
- Self-correction patterns
- Context engineering
- Automatic rule generation
- Feedback loop design
- Incremental roadmap
Prompt Optimization
DSPy-Style Optimization
Use a closed loop:
prompt -> run -> evaluate -> refine prompt -> run againPotential Sigil uses:
- improve
descriptionrouting quality - compare template variants
- refine discovery heuristics from outcomes
TextGrad-Style Optimization
Treat review feedback as a natural-language gradient:
initial prompt -> output -> critique -> updated promptUse this only when repeated critique clearly improves results.
Self-Correction Patterns
Mistake Ledger
Track recurring failures in a structured log:
## Mistake Ledger
| Date | Failure Pattern | Cause | Fix | Prevention Rule |
|------|-----------------|-------|-----|-----------------|
| YYYY-MM | missing tests | VERIFY skipped | add test check | F-test-required |Use it to avoid repeating the same generation defects.
Reflection Loop
Generate -> Self-Review -> Identify Issues -> RegenerateOptions:
| Variant | Cost | Use |
|---|---|---|
| Self-Refine | low | default internal review |
| Cross-Model | medium | only when another reviewer is available |
| Multi-Agent | high | use for high-stakes quality loops |
Constitutional Guardrails
Keep a compact rule set for self-review:
- Skills MUST mirror project conventions.
- Skills MUST NOT introduce security risk.
- Skills SHOULD stay easy to load and selective to read.
Context Engineering
Spec-First Pattern
spec -> local rules -> generation -> review -> feedbackUse this when the skill itself is complex or safety-sensitive.
Context Budget
| Context window | Suggested allocation |
|---|---|
~200K tokens |
rules 5-10K, code 150-180K, output 10-40K |
~1M tokens |
rules 10-20K, code 800-900K, output 80-100K |
If a generated skill requires too much inline context, split or externalize detail into reference/.
Automatic Rule Generation
Useful source flows:
- existing code -> convention extraction -> skill or
CLAUDE.md - CI failures -> recurring failure pattern -> preventive skill
- PR review comments -> repeated feedback -> new project rule
Feedback Loop Design
Three levels:
- structural quality -> automatic validation
- semantic quality -> self-review or external review
- practical quality -> ATTUNE over time
Map these back to Sigil:
- structural quality ->
validation-rules.md - semantic quality -> recraft / review loop
- practical quality ->
skill-effectiveness.md
Incremental Roadmap
- Add Mistake Ledger to the journal.
- Run Self-Refine inside
VERIFYfor weak drafts. - Track weak
descriptionactivation and propose rewrites. - Measure context cost and recommend skill splitting when needed.