Skip to content
Back to skills

Reflect Learn

ASecurity

Review user corrections or session outcomes to propose durable workflow improvements. Persist memory or edit agent guidance only when requested.

  • 75 stars
  • 0 votes
  • 0 copies
  • 5 views
  • Added September 12, 2026
ai-agentspythongobashrailsdebuggingcode-reviewgitapifrontendbackend

Works with

  • claude code
  • cli
  • api

Security analysis

A100/100

Pro scans all 19 files and shows the line behind each finding

Scanned November 25, 2026

npx -y skills add seaworld008/Commonly-used-high-value-skills --skill reflect-learn --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Reflect Learn?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Reflect Learn
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/seaworld008-reflect-learn/badge)](https://www.skillsdirectory.com/skills/seaworld008-reflect-learn)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: reflect-learn
description: Review user corrections or session outcomes to propose durable workflow improvements. Persist memory or edit agent guidance only when requested.
zh_description: "分析用户纠正和任务结果,提出可复用的改进建议。"
version: "2.0.5"
author: Claude Code Toolkit
source: "in-house"
source_url: ""
tags: ["learn", "planning", "reflect", "workflow"]
created_at: "2026-03-04"
updated_at: "2026-11-18"
quality: 5
complexity: "intermediate"
allowed-tools:
---

# Reflect - Self-Improvement Skill

## Runtime and Evaluation Contract

Use the current host's available file and conversation tools. The `/reflect`
commands below are optional client integration examples, not commands that every
host registers. Run bundled Python helpers from this skill's directory only when
their state writes are within the user's authorization; analysis alone does not
require initializing global state or installing hooks.

For repeated-task optimization, use the [controlled improvement worksheet](references/controlled-improvement.md).
It preserves baseline evidence, a one-variable comparison, regression checks,
and a rollback decision. Changing memory, prompts, skills, or schedules requires
authorization for that specific destination; a detected signal grants none.

## Quick Reference

| Command | Action |
|---------|--------|
| `/reflect` | Analyze conversation for learnings |
| `/reflect on` | Enable auto-reflection |
| `/reflect off` | Disable auto-reflection |
| `/reflect status` | Show state and metrics |
| `/reflect review` | Review low-confidence learnings |
| `/reflect [agent]` | Focus on specific agent |

## Core Philosophy

**"Correct once, never again."**

A correction can inform a durable improvement. Return a proposal by default and apply it to a specific destination when the task authorizes that update.

## Workflow

### Step 1: Select the destination

For analysis alone, proceed to signal detection. Initialize state only when state storage at the selected destination is authorized.

```bash
# Set REFLECT_STATE_DIR to the authorized state directory first.
REFLECT_STATE_DIR="${REFLECT_STATE_DIR:?set the approved state directory}" python scripts/state_manager.py init

# State directory is configurable via REFLECT_STATE_DIR env var
# Default: ~/.reflect/ (portable) or ~/.claude/session/ (Claude Code)
```

State includes:
- `reflect-state.yaml` - Toggle state, pending reviews
- `reflect-metrics.yaml` - Aggregate metrics
- `learnings.yaml` - Log of all applied learnings

### Step 2: Scan Conversation for Signals

Use the signal detector to identify learnings:

```bash
python scripts/signal_detector.py --input conversation.txt
```

#### Signal Confidence Levels

| Confidence | Triggers | Examples |
|------------|----------|----------|
| **HIGH** | Explicit corrections | "never", "always", "wrong", "stop", "the rule is" |
| **MEDIUM** | Approved approaches | "perfect", "exactly", accepted output |
| **LOW** | Observations | Patterns that worked, not validated |

See [signal_patterns.md](references/signal_patterns.md) for full detection rules.

### Step 3: Classify & Match to Target Files

Map each signal to the appropriate target:

**Learning Categories:**

| Category | Target Files |
|----------|--------------|
| Code Style | `code-reviewer`, `backend-developer`, `frontend-developer` |
| Architecture | `solution-architect`, `api-architect`, `architecture-reviewer` |
| Process | `CLAUDE.md`, orchestrator agents |
| Domain | Domain-specific agents, `CLAUDE.md` |
| Tools | `CLAUDE.md`, relevant specialists |
| New Skill | `.claude/skills/{name}/SKILL.md` |

See [agent_mappings.md](references/agent_mappings.md) for mapping rules.

### Step 4: Check for Skill-Worthy Signals

Some learnings should become new skills rather than agent updates:

**Skill-Worthy Criteria:**
- Non-obvious debugging (>10 min investigation)
- Misleading error (root cause different from message)
- Workaround discovered through experimentation
- Configuration insight (differs from documented)
- Reusable pattern (helps in similar situations)

**Quality Gates (must pass all):**
- [ ] Reusable: Will help with future tasks
- [ ] Non-trivial: Requires discovery, not just docs
- [ ] Specific: Can describe exact trigger conditions
- [ ] Verified: Solution actually worked
- [ ] No duplication: Doesn't exist already

See [skill_template.md](references/skill_template.md) for skill creation guidelines.

### Step 5: Generate Proposals

Produce output in this format:

```markdown
# Reflection Analysis

## Session Context
- **Date**: [timestamp]
- **Messages Analyzed**: [count]
- **Focus**: [all agents OR specific agent name]

## Signals Detected

| # | Signal | Confidence | Source Quote | Category |
|---|--------|------------|--------------|----------|
| 1 | [learning] | HIGH | "[exact words]" | Code Style |
| 2 | [learning] | MEDIUM | "[context]" | Architecture |

## Proposed Agent Updates

### Change 1: Update [agent-name]

**Target**: `[file path]`
**Section**: [section name]
**Confidence**: [HIGH/MEDIUM/LOW]
**Rationale**: [why this change]

```diff
--- a/path/to/agent.md
+++ b/path/to/agent.md
@@ -82,6 +82,7 @@
 ## Section

 * Existing rule
+* New rule from learning
```

## Proposed New Skills

### Skill 1: [skill-name]

**Quality Gate Check**:
- [x] Reusable: [why]
- [x] Non-trivial: [why]
- [x] Specific: [trigger conditions]
- [x] Verified: [how verified]
- [x] No duplication: [checked against]

**Will create**: `.claude/skills/[skill-name]/SKILL.md`

## Conflict Check

- [x] No conflicts with existing rules detected
- OR: Warning - potential conflict with [file:line]

## Commit Message (when a commit was requested)

```
reflect: add learnings from session [date]

Agent updates:
- [learning 1 summary]

New skills:
- [skill-name]: [brief description]

Extracted: [N] signals ([H] high, [M] medium, [L] low confidence)
```

## Review Prompt

Apply these changes?
- `Y` - Apply the proposed updates to the listed destinations
- `N` - Discard all changes
- `modify` - Adjust specific changes
- `1,3` - Apply only changes 1 and 3
- `s1` - Apply only skill 1
- `all-skills` - Apply all skills, skip agent updates
```

### Step 6: Handle User Response

**On approval:** Apply the selected changes to the approved destinations. Stage and commit those files only when the task includes a commit. Write learning logs or metrics only when their destinations and writes are also authorized.

**On rejection:** Discard the proposal and finish.

**On `modify`:**
1. Present each change individually
2. Allow editing the proposed addition
3. Reconfirm before applying

**On selective approval:** Apply only the selected changes under the same destination and action limits.

### Step 7: Record metrics when authorized

Use the authorized state directory for the metric update, for example:

```bash
REFLECT_STATE_DIR="${REFLECT_STATE_DIR:?set the approved metrics directory}" python scripts/metrics_updater.py --accepted 3 --rejected 1 --confidence high:2,medium:1
```

## Toggle Commands

### Enable Auto-Reflection

```bash
/reflect on
# Sets auto_reflect: true in state file
# The toggle applies only to a separately configured PreCompact hook.
```

### Disable Auto-Reflection

```bash
/reflect off
# Sets auto_reflect: false in state file
```

### Check Status

```bash
/reflect status
# Shows current state and metrics
```

### Review Pending

```bash
/reflect review
# Shows low-confidence learnings awaiting validation
```

## Optional Output Locations

**Project-level (versioned with repo):**
- `.claude/reflections/YYYY-MM-DD_HH-MM-SS.md` - Full reflection
- `.claude/reflections/index.md` - Project summary
- `.claude/skills/{name}/SKILL.md` - New skills

**Global (user-level):**
- `~/.claude/reflections/by-project/{project}/` - Cross-project
- `~/.claude/reflections/by-agent/{agent}/learnings.md` - Per-agent
- `~/.claude/reflections/index.md` - Global summary

## Memory Integration

Some learnings belong in **auto-memory** (`~/.claude/projects/*/memory/MEMORY.md`) rather than agent files:

| Learning Type | Best Target |
|---------------|-------------|
| Behavioral correction ("always do X") | Agent file |
| Project-specific pattern | MEMORY.md |
| Recurring bug/workaround | New skill OR MEMORY.md |
| Tool preference | CLAUDE.md |
| Domain knowledge | MEMORY.md or compound-docs |

For a low-confidence project-specific signal, propose a memory entry for review.

## Safety Guardrails

### Human-in-the-Loop
- Persist changes only when the user has requested or approved the specific memory or guidance update; existing authorization remains valid
- Make proposed changes reviewable; include the relevant diff or resulting guidance when reporting an authorized update
- Allow selective application

### Git Versioning
- When a commit is authorized, stage only the approved changes, include a descriptive message and identify the commit for rollback.

### Incremental Updates
- Keep changes confined to the rules or sections covered by the requested update
- Preserve unrelated rules; when the user requests cleanup, remove or rewrite the identified redundant or conflicting rules with a recorded rationale
- Preserve original structure

### Conflict Detection
- Check if proposed rule contradicts existing
- Warn user if conflict detected
- Suggest resolution strategy

## Integration

### Optional PreCompact integration

The bundled Claude Code hook can emit a reminder before compaction. Its auto path checks for a transcript and calls the output generator with empty signals, agent updates and skills. When the helper is available it can write a placeholder and update indexes. Full analysis still requires reviewing the conversation.

Every invocation writes session and trigger metadata to `~/.claude/logs/reflect_precompact.log` before checking the toggle. Select this integration only when that logging destination is specifically authorized, including in reminder mode. If logging is declined, use manual reflection.

For a requested hook installation, point the host command to the absolute path of `hooks/precompact_reflect.py` in the complete installed skill so the adjacent `scripts/` helpers remain available. Choose `--remind` for a reminder. Select `--auto` only when placeholder and index writes at their project and user destinations are also authorized.

## Portability

This skill works with any LLM tool that supports:
- File read/write operations
- Text pattern matching
- Git operations (optional, for commits)

### Configurable State Location

```bash
# Set custom state directory
export REFLECT_STATE_DIR=/path/to/state

# Or use default
# ~/.reflect/ (portable default)
# ~/.claude/session/ (Claude Code default)
```

### No Task Tool Dependency

Unlike the previous agent-based approach, this skill executes directly without spawning subagents. The LLM reads SKILL.md and follows the workflow.

### Git Operations Optional

Use Git only for authorized commits in a repository.

## Troubleshooting

**No signals detected:**
- Session may not have had corrections
- Try `/reflect review` to check pending items

**Conflict warning:**
- Review the existing rule cited
- Decide if new rule should override
- Can modify before applying

**Agent file not found:**
- Check agent name spelling
- Use `/reflect status` to see available targets
- May need to create agent file first

## File Structure

```
reflect/
├── SKILL.md                      # This file
├── scripts/
│   ├── state_manager.py          # State file CRUD
│   ├── signal_detector.py        # Pattern matching
│   ├── metrics_updater.py        # Metrics aggregation
│   └── output_generator.py       # Reflection file & index generation
├── hooks/
│   ├── precompact_reflect.py     # PreCompact hook integration
│   ├── settings-snippet.json     # Settings.json examples
│   └── README.md                 # Hook configuration guide
├── references/
│   ├── signal_patterns.md        # Detection rules
│   ├── agent_mappings.md         # Target mappings
│   └── skill_template.md         # Skill generation
└── assets/
    ├── reflection_template.md    # Output template
    └── learnings_schema.yaml     # Schema definition
```

Files in this skill

  • CLAWDHUB-PUBLISHING-GUIDE.md8.3 KB
  • README.md2.5 KB
  • SKILL.md10.7 KB
  • _meta.json459 B
  • assets/learnings_schema.yaml2.6 KB
  • assets/reflection_template.md2 KB
  • data/agent_mappings.md7.3 KB
  • data/signal_patterns.md7.8 KB
  • hooks/README.md5.8 KB
  • hooks/precompact_reflect.py6.7 KB
  • hooks/settings-snippet.json1.1 KB
  • references/agent_mappings.md7.4 KB
  • references/signal_patterns.md8.2 KB
  • references/skill_template.md8.6 KB
  • scripts/logs/notification.json449 B
  • scripts/logs/stop.json425 B
  • scripts/logs/subagent_stop.json643 B
  • scripts/logs/user_prompt_submit.json465 B
  • scripts/metrics_updater.py7.9 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.