9thlevelsoftware/legion/memory-manager

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Stores and retrieves task outcomes and agent performance across sessions via .planning/memory/OUTCOMES.md, scores recalled entries by recency and importance, and degrades gracefully when memory files are absent. Use when the user references past sessions, asks to recall previous results, records lessons learned, or is working within a Legion multi-agent workflow.

Install

npx vskill@latest install 9thlevelsoftware/legion/memory-manager

SKILL.md

Memory Manager

Cross-session memory layer for Legion. Tracks agent performance and task outcomes, provides pattern recall with recency-based decay, and degrades gracefully when memory is not present. All memory operations are explicit calls from workflows — no hooks, no background processes.

References:

  • State File Locations from workflow-common.md (memory paths at .planning/memory/)
  • Memory Conventions from workflow-common.md (lifecycle, paths, integration points)
  • Execution Tracker Section 2 from execution-tracker.md (plan completion flow where memory recording is triggered)
  • .planning/memory/OUTCOMES.md — the single memory file read and written by this skill

Section 1: Memory Principles

Core rules governing all memory operations:

  1. Passive and opt-in — memory operations are called explicitly by workflows. No hooks, no background processes, no automatic triggers. A workflow must choose to store or recall.
  2. Human-readable markdown — all memory is stored as structured markdown tables, consistent with PROJECT.md, STATE.md, and all other Legion state files. No JSON, no binary, no databases.
  3. Graceful degradation — every caller checks for memory availability before using it. If memory files don't exist, the workflow proceeds identically to how it worked before Phase 9. Memory is an enhancement, never a requirement.
  4. Append-only with opt-in pruning — outcome records are added, never modified or deleted automatically. Decay happens at recall time through scoring, not through deletion. When memory.auto_prune is enabled, records exceeding the threshold are archived (moved to ARCHIVE.md), never deleted.
  5. Supplement, not override — memory boosts agent recommendations but cannot override mandatory roles, division alignment, or the core recommendation algorithm in agent-registry.md.
  6. Minimal footprint — one directory (.planning/memory/), four files (OUTCOMES.md, PATTERNS.md, ERRORS.md, PREFERENCES.md). Each file has a distinct schema and purpose — no duplication across files.
  7. Strict project scope — memory recall and scoring are project-local by default. Agent outcomes from one project MUST NOT be used to boost or penalize recommendations in another project unless an explicit future opt-in feature is added.

Section 2: Memory File Format

Memory lives in a single file:

Path: .planning/memory/OUTCOMES.md
Created: on first store operation (not during project initialization)

File structure:

markdown
# Memory — Outcome Log
Records agent performance and task outcomes for cross-session learning.
Managed by memory-manager skill. Do not edit manually unless pruning old records.
## Records
| ID | Date | Branch | Phase | Plan | Agent | Task Type | Outcome | Importance | Tags | Summary |
|----|------|--------|-------|------|-------|-----------|---------|------------|------|---------|
| O-001 | 2026-03-01 | main | 5 | 05-01 | testing-qa-verification-specialist | quality-review | success | 3 | review, testing, workflow | Review-loop skill approved in 2 cycles |
| O-002 | 2026-03-01 | main | 5 | 05-02 | autonomous | workflow | success | 2 | review, command, status | /legion:review command implemented |

Field definitions:

FieldFormatDescription
IDO-{NNN}Sequential, zero-padded to 3 digits. Next ID = count of existing records + 1
DateYYYY-MM-DDWhen the outcome was recorded
BranchGit branch nameCurrent branch at record time (via git branch --show-current). Existing records without Branch are treated as default branch
PhaseIntegerPhase number where the outcome occurred
PlanNN-PPPlan ID (e.g., 05-01)
AgentAgent ID or autonomousThe agent that executed the work
Task TypeTag from agent-registryPrimary task type category (e.g., workflow, frontend, quality-review)
Outcomesuccess / partial / failedHow the plan or review resolved
Importance1 through 5Significance score (see Importance Scoring below)
TagsComma-separatedSearchable keywords: phase slug, agent division, technology, domain
SummaryFree text (one line)Brief description of what happened

Importance scoring:

Base ScoreCondition
5Plan failed — critical learning signal
4Review escalated (3 cycles exhausted)
3Plan partial or review needed 2+ cycles
2Standard success — plan completed, review passed
1Trivial or expected outcome (autonomous config changes)

Adjustment modifiers (add to base, cap at 5):

  • First time an agent handles this task type: +1
  • Cross-division work (agent from different division than task type): +1
  • Review found 3+ blockers before passing: +1

Section 3: Store Operation

How to add outcome records. Called by build.md (after plan execution) and review.md (after review cycle completes).

Store Outcome:
Step 1: Check memory directory
- If .planning/memory/ does not exist: create it with mkdir -p
- If .planning/memory/OUTCOMES.md does not exist: create it with the header template from Section 2
Step 2: Determine next ID
- Read OUTCOMES.md
- Count rows in the Records table (exclude header row)
- Next ID = O-{count + 1}, zero-padded to 3 digits
Step 3: Calculate importance
- Start with base score from the Importance Scoring table in Section 2
- Apply adjustment modifiers
- Cap at 5
Step 4: Validate and resolve task_type
- task_type MUST be populated for every outcome record (never leave blank)
- Apply the following inference chain in order:
1. Primary: use the task_type passed by the execution-tracker
(the tracker derives this from the plan's task descriptions)
2. Fallback 1: if task_type is missing or empty, look up the executing agent's
entry in CATALOG.md (skills/agent-registry/CATALOG.md) and use the FIRST
value from the agent's Task Types column
3. Fallback 2: if the agent is "autonomous" or not found in CATALOG.md,
use "general"
- Valid task_types: any tag listed in the Task Types column of CATALOG.md
(e.g., "frontend", "backend", "quality-review", "workflow", "branding",
"ci-cd", "user-research", "content-strategy", "sprint-planning")
- The fallback value "general" is always valid even though it does not
appear in CATALOG.md
Examples:
- execution-tracker passes task_type="frontend" → use "frontend"
- execution-tracker passes no task_type, agent is engineering-backend-architect
→ look up CATALOG.md → first Task Type is "backend" → use "backend"
- execution-tracker passes no task_type, agent is "autonomous"
→ no CATALOG.md entry → use "general"
Step 5: Build the record
- Date: current date (YYYY-MM-DD)
- Phase: from the current phase context
- Plan: from the plan ID being tracked
- Agent: agent ID that executed the plan, or "autonomous"
- Task Type: resolved in Step 4 (guaranteed non-empty)
- Outcome: success / partial / failed (from plan execution result)
- Importance: calculated in Step 3
- Tags: phase slug, agent division, task-related keywords
- Summary: one-line description of the outcome
Step 6: Append the record
- Read current OUTCOMES.md
- Append the new row to the Records table
- Write updated OUTCOMES.md
Step 7: Verify
- Confirm the new record appears in OUTCOMES.md
- Confirm Task Type column is non-empty in the new record
- If write failed: output the record as text to the user (never lose data)

Store Decision (embedded in outcome records):

Key decisions are captured in the Summary and Tags fields of outcome records rather than a separate file. For example:

  • "Chose engineering-senior-developer over engineering-rapid-prototyper for production Laravel work" (tags: agent-selection, engineering)
  • "Escalated review after 3 cycles — milestone-tracker had persistent edge case" (tags: escalation, review, milestone)

This keeps the memory layer minimal (one file) while still enabling decision recall for session briefing.


Section 4: Recall Operation

How to query memory. Called by phase-decomposer.md (agent recommendation) and status.md (session briefing).

General Recall:

Recall Outcomes:
Input:
- query_tags: list of tags to filter by (optional, matches any)
- agent_id: specific agent to filter by (optional)
- task_type: specific task type to filter by (optional)
- limit: max records to return (default: 20)
Step 1: Check memory exists
- If .planning/memory/OUTCOMES.md does not exist: return empty results
- Do NOT create the file on recall — only store creates it
Step 2: Read and parse OUTCOMES.md
- Parse the Records table into individual records
- If parse fails (malformed table): log warning, return empty results
Step 3: Filter
- If query_tags provided: keep records where any tag matches any query_tag
- If agent_id provided: keep records where Agent matches agent_id
- If task_type provided: keep records where Task Type matches task_type
- Multiple filters are AND-combined
Step 4: Apply decay scoring
- For each record, calculate:
days_old = (current_date - record_date) in days
recency_weight:
- days_old <= 7: 1.0
- days_old <= 30: 0.7
- days_old <= 90: 0.4
- days_old > 90: 0.1
decay_score = importance × recency_weight
Step 5: Exclude low-signal records
- Remove records where decay_score < 0.2
Step 6: Sort and limit
- Sort by decay_score descending
- Return top {limit} records
Step 7: Pruning suggestion (informational only)
- If total record count exceeds 200:
Output note: "OUTCOMES.md has {count} records. Run `/legion:learn --prune`
to archive old entries, or enable `memory.auto_prune` in settings.json."
- If `memory.auto_prune` is true in settings.json, pruning runs automatically
after store operations when the threshold is exceeded (see Section 7.5).

Recall for Agent Recommendation:

A specialized recall mode used by phase-decomposer.md Section 4 during agent selection.

Recall Agent Scores:
Input:
- task_types: list of task type tags from the current plan analysis
Step 1: Check memory exists
- If .planning/memory/OUTCOMES.md does not exist: return empty map
Step 2: Recall all outcomes matching task_types
- Use general recall with query_tags = task_types
Step 3: Group by agent_id
- For each unique agent in the filtered results:
- total_tasks = count of records for this agent
- successes = count where outcome = "success"
- failures = count where outcome = "failed"
- success_rate = successes / total_tasks
- avg_importance = mean of importance values
- avg_recency_weight = mean of recency_weight values
Step 4: Calculate memory score per agent
- memory_score = (success_rate × 3.0) + (avg_importance × 0.5)
- Apply recency: memory_score = memory_score × avg_recency_weight
- Clamp to range [0, 5]
Step 5: Return agent_id → memory_score mapping
- Only include agents with total_tasks >= 2 (avoid one-off noise)
- Sort by memory_score descending

Recall Archetype Scores:

A specialized recall mode that groups outcomes by task_type to produce archetype-level performance data. Consumed by agent-registry recommendation algorithm for archetype-weighted boosts.

Recall Archetype Scores:
Input:
- task_types: list of task type tags to include (optional; if empty, all task types)
Step 1: Check memory exists
- If .planning/memory/OUTCOMES.md does not exist: return empty map
Step 2: Read and parse all outcomes
- Parse the Records table from OUTCOMES.md
- If task_types provided: filter to records where Task Type matches any value in task_types
- If task_types empty: use all records

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
62
Repository forks
7
7-day trend score
21

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/9thlevelsoftware/legion/memory-manager/badge)](https://verified-skill.com/skills/9thlevelsoftware/legion/memory-manager)

Something wrong with this skill or its page? Tell us.