Reflect temp

From DNYoussef/context-cascade · View interactive version

Reflect temp is an AI agent skill from the GitHub repository DNYoussef/context-cascade. Extract learnings from session corrections and patterns, update skill files with persistent memory. Implements Loop 1.5 - per-session micro-learning between execution and meta-optimization.

How to use this skill

Skill file

L1 Improvement



LIBRARY-FIRST PROTOCOL (MANDATORY)

Before writing ANY code, you MUST check:

Step 1: Library Catalog

Step 2: Patterns Guide

Step 3: Existing Projects

Decision Matrix

| Match | Action |

|-------|--------|

| Library >90% | REUSE directly |

| Library 70-90% | ADAPT minimally |

| Pattern exists | FOLLOW pattern |

| In project | EXTRACT |

| No match | BUILD (add to library after) |


TIER 1: CRITICAL SECTIONS

Overview

The Reflect skill solves a fundamental limitation of LLMs: they don't learn from session to session. Every conversation starts from zero, causing the same mistakes to recur and forcing users to repeat corrections endlessly.

Philosophy: Corrections are signals. Approvals are confirmations. Both should be captured, classified, and persisted into skill files where they become permanent knowledge that survives across sessions.

Methodology: 7-phase extraction and update pipeline that:

  1. Detects learning signals in conversation
  2. Maps them to invoked skills
  3. Classifies confidence levels (VERIX-aligned)
  4. Proposes skill file updates
  5. Applies changes via Skill Forge patterns
  6. Stores in Memory MCP for Meta-Loop aggregation
  7. Commits to Git for version tracking

Value Proposition: Correct once, never again. Transform ephemeral session corrections into persistent skill improvements that compound over time.

Core Principles

The Reflect skill operates on 5 core principles:

Principle 1: Signals Over Commands

Corrections are the strongest learning signals. When a user says "No, use X instead", this is more valuable than explicit instructions because it reveals a gap between expectation and delivery.

In practice:

Principle 2: Evidence-Based Confidence

All learnings must have VERIX-aligned confidence ceilings. Don't overclaim certainty from limited evidence.

In practice:

Principle 3: Skill File as Memory

Store learnings in SKILL.md, not in embeddings. Skill files are human-readable, version-controlled, and immediately effective.

In practice:

Principle 4: Safe by Default

Preview all changes before applying. HIGH confidence changes require explicit approval; automation only for MEDIUM/LOW.

In practice:

Principle 5: Feed the Meta-Loop

Session learnings aggregate into system optimization. Micro-learning feeds macro-optimization.

In practice:

When to Use

Use Reflect when:

Do NOT use Reflect when:

Main Workflow

Phase 1: Signal Detection

Purpose: Scan conversation for learning signals

Agent: intent-parser (from registry)

Input Contract:

inputs:
  conversation_context: string  # Full session transcript
  invoked_skills: list[string]  # Skills used in session

Process:

  1. Parse conversation for signal patterns
  2. Classify each signal by type and strength
  3. Extract the learning content

Signal Types:

| Type | Pattern | Confidence |

|------|---------|------------|

| Correction | "No, use X", "That's wrong", "Actually..." | HIGH (0.90) |

| Explicit Rule | "Always do X", "Never do Y" | HIGH (0.90) |

| Approval | "Perfect", "Yes, exactly", "That's right" | MEDIUM (0.75) |

| Rejection | User rejected proposed solution | MEDIUM (0.75) |

| Style Cue | Formatting or naming preferences | LOW (0.55) |

| Observation | Implicit preference detected | LOW (0.55) |

Output Contract:

outputs:
  signals: list[Signal]
  Signal:
    type: correction|explicit_rule|approval|rejection|style_cue|observation
    content: string  # The actual learning
    context: string  # Surrounding context
    confidence: float  # 0.55-0.90
    ground: string  # Evidence source
Phase 2: Skill Mapping

Purpose: Map signals to the skills they apply to

Agent: skill-mapper (custom logic)

Process:

  1. Parse conversation for Skill() invocations
  2. Check command history for /skill-name calls
  3. Match each signal to its relevant skill
  4. Handle multi-skill sessions (separate updates per skill)

Output Contract:

outputs:
  skill_signals: dict[skill_name, list[Signal]]
Phase 3: Confidence Classification

Purpose: Apply VERIX-aligned confidence levels

Agent: prompt-architect patterns

Classification Rules:

HIGH   [conf:0.90] = Explicit "never/always" rules
                      Direct corrections with clear alternative
                      User used emphatic language

MEDIUM [conf:0.75] = Successful patterns (2+ confirmations)
                      Single strong approval
                      Rejection with implicit preference

LOW    [conf:0.55] = Single observations
                      Style cues without explicit statement
                      Inferred preferences

Ceiling Enforcement:

Phase 4: Change Proposal

Purpose: Generate proposed skill file updates

Agent: skill-forge patterns

Process:

  1. Read current SKILL.md for target skill
  2. Check if LEARNED PATTERNS section exists (create if not)
  3. Generate diff showing proposed additions
  4. Format commit message

Output Format:

## Proposed Updates

**Skill: {skill_name}** (v{old} -> v{new})

### Signals Detected
- {count} corrections (HIGH)
- {count} approvals (MEDIUM)
- {count} observations (LOW)

### Diff Preview

### Commit Message
reflect({skill}): [{LEVEL}] {description}

---
[Y] Accept  [N] Reject  [E] Edit with natural language
Phase 5: Apply Updates

Purpose: Safely update skill files

Agent: skill-forge

Process:

  1. If approved (manual) or auto-mode enabled:
  2. Read skill file
  3. Find or create LEARNED PATTERNS section
  4. Append new learnings under appropriate confidence level
  5. Increment x-version in frontmatter
  6. Set x-last-reflection to current timestamp
  7. Increment x-reflection-count
  8. Write updated file

LEARNED PATTERNS Section Format:

## LEARNED PATTERNS

### High Confidence [conf:0.90]
- ALWAYS check for SQL injection vulnerabilities [ground:user-correction:2026-01-05]
- NEVER use inline styles in components [ground:user-correction:2026-01-03]

### Medium Confidence [conf:0.75]
- Prefer async/await over .then() chains [ground:approval-pattern:3-sessions]
- Use descriptive variable names in examples [ground:approval-pattern:2-sessions]

### Low Confidence [conf:0.55]
- User may prefer verbose error messages [ground:observation:1-session]
Phase 6: Memory MCP Storage

Purpose: Persist learnings for Meta-Loop aggregation

Agent: memory-mcp integration

Storage Format:

{
  "WHO": "reflect-skill:{session_id}",
  "WHEN": "{ISO8601_timestamp}",
  "PROJECT": "{project_name}",
  "WHY": "session-learning",
  "x-skill": "{skill_name}",
  "x-version-before": "{old_version}",
  "x-version-after": "{new_version}",
  "x-signals": {
    "corrections": 2,
    "approvals": 1,
    "observations": 1
  },
  "x-learnings": [
    {
      "content": "ALWAYS check for SQL injection",
      "confidence": 0.90,
      "ground": "user-correction",
      "category": "HIGH"
    }
  ]
}

Storage Path: sessions/reflect/{project}/{skill}/{timestamp}

Phase 7: Git Commit (Optional)

Purpose: Version the skill evolution

Agent: bash git commands

Commit Format:

reflect({skill_name}): [{LEVEL}] {description}

- Added {n} learnings from session
- Confidence levels: HIGH:{n}, MEDIUM:{n}, LOW:{n}
- Evidence: user-correction, approval-pattern, observation

Generated by reflect skill v1.0.0

TIER 2: ESSENTIAL SECTIONS

Pattern Recognition

Different session types require different reflection approaches:

Debugging Session

Patterns: "bug", "fix", "error", "not working"

Common Corrections: Framework choice, error handling patterns, edge cases

Key Focus: What was the root cause? What pattern prevents recurrence?

Approach: Extract diagnostic insights and prevention rules

Code Review Session

Patterns: "review", "check", "looks good", "change this"

Common Corrections: Style violations, security concerns, naming

Key Focus: What standards emerged? What was consistently flagged?

Approach: Extract style rules and security patterns

Feature Development Session

Patterns: "build", "create", "implement", "add"

Common Corrections: Architecture choices, component usage, API patterns

Key Focus: What design decisions worked? What was rejected?

Approach: Extract architectural preferences and component rules

Documentation Session

Patterns: "document", "explain", "readme", "describe"

Common Corrections: Tone, structure, level of detail

Key Focus: What style resonated? What format preferred?

Approach: Extract documentation style guide entries

Advanced Techniques

Multi-Session Pattern Detection

Track signals across sessions to identify recurring patterns:

Negative Space Analysis

Learn from what was NOT corrected:

Skill Dependency Tracking

When correcting skill A, check impact on skills that depend on it:

Conflict Resolution

Handle contradictory signals:

Common Anti-Patterns

| Anti-Pattern | Problem | Solution |

|--------------|---------|----------|

| Over-Learning | Capturing every small preference | Only persist signals that appear 2+ times or are explicit rules |

| Under-Confidence | All learnings at LOW confidence | Explicit "always/never" statements are HIGH; don't downgrade |

| Eval-Harness Modification | Attempting to update frozen harness | BLOCK: eval-harness never self-improves |

| Silent Updates | Applying changes without preview | ALWAYS show diff and require confirmation for HIGH |

| Orphan Learnings | Storing in Memory but not SKILL.md | Write to BOTH: skill file for immediate effect, Memory for aggregation |

| Version Skip | Not incrementing x-version | ALWAYS bump version on any skill file change |

Practical Guidelines

Full vs Quick Mode

Full Mode (default for manual /reflect):

Quick Mode (/reflect --quick or auto mode):

Decision Points

When to ask user:

When to auto-apply:


TIER 3: INTEGRATION SECTIONS

Cross-Skill Coordination

Upstream Skills (provide input)

| Skill | When Used Before | What It Provides |

|-------|------------------|------------------|

| intent-analyzer | Before reflection | Parsed user intent for signal context |

| prompt-architect | For constraint classification | HARD/SOFT/INFERRED distinction |

Downstream Skills (use output)

| Skill | When Used After | What It Does |

|-------|-----------------|--------------|

| skill-forge | After signal classification | Applies safe SKILL.md updates |

| bootstrap-loop | During Meta-Loop | Aggregates learnings for optimization |

Parallel Skills (work together)

| Skill | When Used Together | How They Coordinate |

|-------|-------------------|---------------------|

| memory-manager | During storage phase | Stores in Memory MCP |

| github-integration | During commit phase | Handles git operations |

MCP Requirements

Required:

Optional:

Input/Output Contracts

inputs:
  # Required
  trigger: manual | automatic  # How reflect was invoked

  # Optional
  skill_name: string  # Target specific skill (else detect from session)
  mode: full | quick  # Reflection depth
  auto_apply: boolean  # Skip approval for MEDIUM/LOW (requires reflect-on)

outputs:
  # Always returned
  signals_detected: list[Signal]
  skills_updated: list[string]
  learnings_stored: list[MemoryKey]

  # If changes made
  skill_diffs: dict[skill_name, diff_preview]
  version_changes: dict[skill_name, {old: string, new: string}]

  # If git enabled
  commit_hash: string
  commit_message: string

Recursive Improvement

Role in Meta-Loop:

The reflect skill is ITSELF subject to Meta-Loop optimization:

Eval Harness Integration:

Memory Namespace:


TIER 4: CLOSURE SECTIONS

Examples

Example 1: Manual Reflection After Debugging Session
User: /reflect

Claude: Analyzing session for learning signals...

## Session Reflection Report

### Signals Detected
- 2 corrections (HIGH confidence)
- 1 approval (MEDIUM confidence)
- 1 observation (LOW confidence)

### Proposed Updates

**Skill: debug** (v2.1.0 -> v2.1.1)

+

+

+


### Commit Message
reflect(debug): [HIGH] Add null check and structured logging rules

---
[Y] Accept  [N] Reject  [E] Edit with natural language

User: Y

Claude: Updates applied successfully.
- Updated: skills/delivery/debug/SKILL.md (v2.1.0 -> v2.1.1)
- Stored: sessions/reflect/my-project/debug/2026-01-05T10:30:00Z
- Committed: reflect(debug): [HIGH] Add null check and structured logging rules

Confidence: 0.85 (ceiling: observation 0.95)
Example 2: Automatic Reflection via Stop Hook
[Session ending - reflect-on is enabled]

==========================================
   SESSION REFLECTION (Automatic)
==========================================

Detected 3 learning signals across 2 skills.

Skill: code-review
  + [MEDIUM] Prefer early returns over nested conditionals

Skill: tester
  + [LOW] Integration tests should mock external APIs
  + [LOW] Use descriptive test names

Auto-applied 3 MEDIUM/LOW learnings.
Stored in Memory MCP.
Git commit: reflect(code-review,tester): [MEDIUM] Session learnings

Next session will include these patterns.
Example 3: Targeting Specific Skill
User: /reflect code-review

Claude: Reflecting on code-review skill specifically...

### Signals for code-review

Found 4 signals:
1. [HIGH] "Never approve PRs with console.log statements" - user-correction
2. [MEDIUM] Security review phase appreciated - approval
3. [MEDIUM] Diff-only output format works well - approval
4. [LOW] May prefer bullet points over paragraphs - observation

Propose adding to skills/quality/code-review/SKILL.md?
[Y] Accept  [N] Reject  [E] Edit

Troubleshooting

| Problem | Solution |

|---------|----------|

| No signals detected | Ensure conversation had corrections or approvals. Trivial sessions may not have learnings. |

| Skill not found | Verify skill was invoked via Skill() or /command. Check skill-index.json. |

| Memory MCP unavailable | Learnings still applied to skill files. Retry memory storage later. |

| Git commit failed | Check git status. Ensure no merge conflicts. Manual commit may be needed. |

| Conflicting learnings | User must resolve. Show both versions and ask which to keep. |

| Permission denied on skill file | Check file permissions. May need elevated access. |

| x-version not incrementing | Ensure YAML frontmatter is valid. Check for parsing errors. |

Conclusion

The Reflect skill transforms ephemeral session corrections into persistent knowledge by implementing Loop 1.5 - a per-session micro-learning layer that bridges immediate execution (Loop 1) and long-term optimization (Loop 3).

Key capabilities:

By capturing learnings at the session level and persisting them in skill files, the Reflect skill enables a self-improving development experience where corrections compound into expertise over time.

Completion Verification

Confidence: 0.85 (ceiling: observation 0.95) - New skill created following Skill Forge v3.2 required sections with full Tier 1-4 coverage.


LEARNED PATTERNS

Low Confidence [conf:0.55]


VCL COMPLIANCE APPENDIX (Internal Reference)

[[HON:teineigo]] [[MOR:root:R-F-L]] [[COM:Reflect+Skill+Loop]] [[CLS:ge_skill]] [[EVD:-DI<gozlem>]] [[ASP:nesov.]] [[SPC:path:/skills/tooling/reflect]]

[define|neutral] REFLECT_SKILL := Per-session micro-learning that extracts corrections and patterns, updates skill files, and stores in Memory MCP for Meta-Loop aggregation [ground:skill-definition] [conf:0.85] [state:confirmed]

[define|neutral] LOOP_1.5 := Session-level reflection layer between Loop 1 (Execution) and Loop 3 (Meta-Loop) that captures immediate learnings [ground:architecture-design] [conf:0.88] [state:confirmed]

[direct|emphatic] EVAL_HARNESS_FROZEN := Reflect skill MUST NOT modify eval-harness; it is frozen per Bootstrap Loop rules [ground:bootstrap-loop-policy] [conf:0.99] [state:confirmed]

[direct|emphatic] CONFIDENCE_CEILINGS := {HIGH:0.90, MEDIUM:0.75, LOW:0.55}; never exceed observation ceiling (0.95) [ground:verix-spec] [conf:0.95] [state:confirmed]

[commit|confident] <promise>REFLECT_SKILL_VCL_V3.1.1_COMPLIANT</promise> [ground:self-check] [conf:0.88] [state:confirmed]

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.