crux-skill-memory-extract
Skill8 starsChanged 2 months agoMITView on GitHub
Analyse execution artifacts from completed units of work, compare with existing memories, detect conflicts, and propose ranked candidate facts for memory creation. Use after a spec (or configured unitOfWork) completes to extract learnings, patterns, red flags, ideas, and goals.
In this repository35 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .cursor/rules/crux-memories-integration.crux.mdcCursor rule
- .cursor/rules/crux-memories-integration.mdCursor rule
- .cursor/rules/_CRUX-RULE.mdcCursor rule
- .cursor/rules/docs-sync.crux.mdCursor rule
- .cursor/rules/docs-sync.crux.mdcCursor rule
- .cursor/rules/docs-sync.mdCursor rule
- .cursor/rules/example/coding-standards-demo.crux.mdcCursor rule
- .cursor/rules/example/coding-standards-demo.mdCursor rule
- .cursor/rules/ignore-example-rules.crux.mdCursor rule
- .cursor/rules/ignore-example-rules.crux.mdcCursor rule
- .cursor/rules/ignore-example-rules.mdCursor rule
- .cursor/rules/skill-and-agent-references.mdcCursor rule
- .cursor/rules/spec-agent-allocation.crux.mdCursor rule
- .cursor/rules/spec-agent-allocation.crux.mdcCursor rule
- .cursor/rules/spec-agent-allocation.mdCursor rule
- .cursor/rules/spec-implementation-hygiene.mdcCursor rule
- .cursor/rules/version-bump.crux.mdCursor rule
- .cursor/rules/version-bump.crux.mdcCursor rule
- .cursor/rules/version-bump.mdCursor rule
- .cursor/rules/zip-contents-protection.crux.mdCursor rule
- .cursor/rules/zip-contents-protection.crux.mdcCursor rule
- .cursor/rules/zip-contents-protection.mdCursor rule
- crux-skill-memory-compressSkill
- crux-skill-memory-crudSkill
- crux-skill-memory-indexSkill
- crux-skill-memory-meditation-coordinationSkill
- crux-skill-memory-meditation-ensembleSkill
- crux-skill-memory-meditation-quickSkill
- crux-skill-memory-meditation-reportSkill
- crux-skill-memory-meditation-researchSkill
- crux-skill-memory-meditation-reviewSkill
- crux-skill-memory-rebalanceSkill
- crux-skill-memory-reference-trackerSkill
- crux-utilsSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
31 rules. About 0 are common, 21 are distinctive, and 10 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈21
Distinctive · estimate
This author's own choices. Worth a look.
10
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 12
Use this skill when:
- Very specific: line 22
Guard check: If flags.enableMemories is not "true", refuse all operations and inform the caller that memories are disabled.
- Very specific: line 36
Verify the work item directory exists within the configured workDir.
- Very specific: line 37
Look for the configured stateFile (default _execution-state.yml) inside the work item directory
- Very specific: line 39
If status is not complete (or equivalent success state), report the current status and abort extraction — incomplete work items should not …
- Very specific: line 40
If no state file exists, return a needs_user_input response asking whether to proceed anyway (the work item may have been executed outside …
- Distinctive: line 50
If the state file contains a start commit hash or timestamp, use it as the diff baseline
- Distinctive: line 54
If the count exceeds the threshold:
- Distinctive: line 57
If within threshold, report the count and continue
- Distinctive: line 63
Read all available execution artifacts and identify candidate facts.
- Distinctive: line 86
Look for explicit statements of insight ("we learned that...", "this approach worked because...", "avoid doing X because...")
- Distinctive: line 87
Look for measurable outcomes (performance numbers, error rate changes, time savings)
- Distinctive: line 88
Look for recurring patterns across subtasks (if multiple subtasks hit the same issue, it is likely a strong candidate)
- Distinctive: line 89
Look for workarounds or non-obvious solutions (these often make the best memories)
- Distinctive: line 90
Look for agent-identified recommendations in work logs
- Distinctive: line 100
Read the frontmatter of each existing memory (title, description, type, tags)
- Distinctive: line 105
Novel: No existing memory covers this territory → keep the candidate
- Distinctive: line 106
Remove exact duplicates from the candidate list
- Very specific: line 155
When classification is ambiguous, prefer the lower-priority type (e.g.
- Distinctive: line 172
When in doubt, place in base — general-purpose learnings benefit all agents.
- Distinctive: line 192
If more candidates remain beyond the limit, note how many were excluded and offer to show them
- Distinctive: line 208
Still active: No evidence of resolution — skip, do not present to the user
- Distinctive: line 209
Only present redflags classified as "likely resolved" or "possibly resolved"
- Distinctive: line 215
Check if the redflag's "Solution" or "Prevention" section describes an approach that now appears in the codebase
- Distinctive: line 216
Check if the specific file, function, or pattern named in the redflag body was modified
- Distinctive: line 217
When in doubt, classify as "possibly resolved" rather than "likely resolved" — the user makes the final call
- Very specific: line 231
All fields are required. confidence is likely or possibly.
- Very specific: line 250
All fields required except conflicts and related_memories.
- Distinctive: line 277
If resolved bugs were detected, include them in a separate section:
- Very specific: line 299
After the user accepts candidates (all or individually), delegate to crux-skill-memory-crud for actual file creation.
- Very specific: line 301
After the user confirms resolved bugs for deletion, delegate to crux-skill-memory-crud Delete operation.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CRUX Skill: Memory Extract
Analyses execution artifacts from a completed unit of work, compares candidates against existing memories for novelty and conflicts, and presents ranked candidate facts for the user to accept, modify, or reject.
When to Use
Use this skill when:
- A unit of work (e.g. spec) has completed execution and you want to extract memories from it
- The
/crux-dreamcommand is invoked for a specific completed work item - The
crux-memory-dreamagent orchestrates a dream workflow
Prerequisites
Before any operation:
- Read config: Load
.crux/crux-memories.json. This skill needsflags.enableMemories,cruxMemories.unitOfWork,cruxMemories.dream.*(maxCandidateFacts,maxUnrelatedChanges,stateFile,workDir),cruxMemories.storage.memoriesDir/agentMemoriesDir, andcruxMemories.typePriority. Defaults and full key descriptions live in.cursor/skills/_memory-shared.md#config-referenceand.crux/crux-memories.json(authoritative). - Guard check: If
flags.enableMemoriesis not"true", refuse all operations and inform the caller that memories are disabled.
Operations
1. Verify Execution
Confirm the unit of work completed successfully before extracting memories.
Input: Path to the work item directory (e.g. specs/20260403-crux-memories/)
Path validation — CRITICAL: The work item directory MUST be a subdirectory of the configured workDir (cruxMemories.dream.workDir, default specs). If the provided path points to a directory outside workDir, abort with an error listing the available specs from workDir. Do not search .ai-ignored/specs/, .ai-ignored/executed/, or other directories.
Steps:
- Verify the work item directory exists within the configured
workDir; if not, abort and list available specs - Look for the configured
stateFile(default_execution-state.yml) inside the work item directory - Parse the state file and check the
statusfield - If status is not
complete(or equivalent success state), report the current status and abort extraction — incomplete work items should not produce memories - If no state file exists, return a
needs_user_inputresponse asking whether to proceed anyway (the work item may have been executed outside the standard workflow) — the calling agent will ask the user and resume you with the decision - Record the execution start date from the state file for use in diff analysis
2. Diff Analysis
Assess the scope of repository changes since the work item started to determine if extraction is meaningful.
Steps:
- Determine the change boundary:
- If the state file contains a start commit hash or timestamp, use it as the diff baseline
- Otherwise, use the work item directory's creation date or earliest file modification as an approximation
- Count the number of changed files in the repository since the baseline
- Compare the count against
maxUnrelatedChanges(default50) - If the count exceeds the threshold:
- Return a
needs_user_inputresponse with the warning: "Found {count} changed files since {unitOfWork} start (threshold: {maxUnrelatedChanges}). Many changes may be unrelated to this {unitOfWork}, which could reduce extraction quality." - Include options: proceed anyway, increase threshold, or abort — the calling agent will present these to the user and resume you with the decision
- Return a
- If within threshold, report the count and continue
The purpose of this check is to avoid extracting noise from unrelated work that happened concurrently.
3. Analyse Artifacts
Read all available execution artifacts and identify candidate facts.
Artifacts to examine (in the work item directory):
| Artifact | What to look for |
| Spec document | Goals, requirements, constraints, architectural decisions |
| Subtask files | Individual task outcomes, blockers encountered, workarounds applied |
| Execution state file | Completion status per subtask, timing, error counts |
| Dream summaries (prior) | Previously extracted memories from this or related work items — avoid duplicating |
| Agent work logs | Patterns agents discovered, red flags encountered, techniques that worked or failed |
| Code changes (diff) | New patterns introduced, anti-patterns fixed, performance improvements measured |
What to extract:
- Learnings: techniques, approaches, or insights that worked
- Red flags: bugs, anti-patterns, pitfalls, or mistakes discovered
- Goals: performance targets achieved or set, quality metrics established
- Ideas: speculative improvements, future work, or experiments suggested
- Core patterns: fundamental approaches that should always be followed
Extraction heuristics:
- Look for explicit statements of insight ("we learned that...", "this approach worked because...", "avoid doing X because...")
- Look for measurable outcomes (performance numbers, error rate changes, time savings)
- Look for recurring patterns across subtasks (if multiple subtasks hit the same issue, it is likely a strong candidate)
- Look for workarounds or non-obvious solutions (these often make the best memories)
- Look for agent-identified recommendations in work logs
- Ignore trivial or mechanical observations (e.g. "we created a file" or "we ran tests")
4. Compare with Existing Memories
Load existing memories and filter candidates for novelty.
Steps:
- Scan configured
memoriesDirandagentMemoriesDirrecursively for all*.memory.mdand*.memory.crux.mdfiles - Read the frontmatter of each existing memory (title, description, type, tags)
- For each candidate fact from step 3, compare against existing memories:
- Exact duplicate: A memory with the same core insight already exists → discard the candidate
- Near duplicate: A memory covers a very similar topic but with different details → flag for potential merge or update rather than creating a new memory
- Related but distinct: Existing memories touch the same domain but this candidate adds genuinely new information → keep the candidate, note the related memories
- Novel: No existing memory covers this territory → keep the candidate
- Remove exact duplicates from the candidate list
- Annotate near-duplicates with the existing memory they overlap and a suggested action (merge, update, or keep both)
5. Conflict Detection
Identify candidates that contradict existing memories.
Steps:
- For each remaining candidate, check whether it directly contradicts an existing memory. Contradiction means the candidate and existing memory give opposing guidance on the same topic. Examples:
- Candidate says "always use approach X" while existing memory says "avoid approach X"
- Candidate reports a pattern works well while existing memory flags the same pattern as a red flag
- Candidate sets a performance target that conflicts with an existing goal
- For each detected conflict, prepare a conflict report:
⚠️ Conflict detected:
Candidate: [candidate title]
[candidate description]
Conflicts with existing memory:
File: [path to existing memory]
Title: [existing memory title]
[existing memory description]
Resolution options:
1. Keep existing — discard the candidate
2. Replace — update the existing memory with the candidate's insight
3. Merge — combine both perspectives into a single memory
4. Keep both — retain both with disambiguation notes explaining when each applies- Conflicts always require user input — they are never auto-resolved, even in
--yolomode
6. Classify Type
Assign each candidate a memory type based on content analysis.
Classification heuristics:
| Type | Indicators |
core | Fundamental patterns, architectural invariants, rules that should always be followed. Language: "always", "never", "must", "fundamental" |
redflag | Bugs found, anti-patterns identified, pitfalls discovered, mistakes made. Language: "avoid", "don't", "causes", "breaks", "bug", "anti-pattern" |
goal | Performance targets (achieved or set), quality metrics, SLAs, acceptance criteria with numbers. Language: "target", "achieved", "benchmark", "metric" |
learning | Techniques, approaches, insights, best practices discovered through execution. Language: "works well", "effective", "technique", "approach", "discovered" |
idea | Speculative improvements, future work, experiments to try, optimisations to explore. Language: "could", "might", "explore", "consider", "future", "experiment" |
When classification is ambiguous, prefer the lower-priority type (e.g. prefer learning over core). The memory can be promoted later through strength and reference tracking.
Validate the assigned type against typePriority from config. Do not assign archived — that type is only set through the rebalance workflow.
7. Agent Scoping
Determine whether each candidate should be a base memory or an agent-scoped memory.
Steps:
- Examine the work item's execution artifacts for agent identification:
- Subtask assignments that name specific agents (e.g. "Assigned Subagent: code-reviewer")
- Work logs from specific agent personas
- Changes made by specific agent types
- For each candidate, determine if the insight is agent-specific:
- Agent-specific: The insight relates to a specific agent's domain (e.g. review patterns for a code-reviewer, test strategies for a test-generator). Mark for placement in
memories/agents/{agent-id}/{type}/ - General-purpose: The insight applies broadly regardless of which agent is working. Place in the base
memories/{type}/directory
- Agent-specific: The insight relates to a specific agent's domain (e.g. review patterns for a code-reviewer, test strategies for a test-generator). Mark for placement in
- When in doubt, place in base — general-purpose learnings benefit all agents. Only scope to an agent when the memory is clearly specific to that agent's concerns
- Record the target scope in the candidate metadata
8. Rank Candidates
Order candidates by estimated value and present the top N.
Ranking criteria (in priority order):
- Type priority: Higher-priority types rank first (per
typePriorityconfig:core>redflag>goal>learning>idea) - Measurability: Candidates with quantitative evidence (performance numbers, error rates, time savings) rank higher than qualitative observations
- Recurrence: Patterns that appeared multiple times across subtasks rank higher
- Actionability: Insights that give clear, specific guidance rank higher than vague observations
- Novelty: Candidates that cover genuinely new territory (no near-duplicates) rank higher
Steps:
- Score each candidate using the criteria above
- Sort by score descending
- Take the top
maxCandidateFactscandidates (default5) - If more candidates remain beyond the limit, note how many were excluded and offer to show them
9. Resolved Bug Detection
Identify existing redflag memories whose bugs or anti-patterns appear to have been fixed by the completed work.
Steps:
- From the existing memories loaded in step 4, filter to those with
type: redflag - For each redflag memory, compare its described bug/anti-pattern against:
- Code changes: Does the diff show changes that directly address the issue described in the redflag? (e.g. the anti-pattern was refactored away, the bug-causing code was rewritten)
- Subtask outcomes: Did any subtask explicitly mention fixing, resolving, or addressing this specific issue?
- Pattern removal: Was the problematic pattern described by the redflag removed or replaced with the recommended approach?
- Classify each redflag into one of:
- Likely resolved: Strong evidence — the diff contains changes that directly fix the described bug or remove the anti-pattern, or a subtask explicitly states the issue was resolved
- Possibly resolved: Partial evidence — related code was changed but it is not conclusive whether the specific issue was fully addressed
- Still active: No evidence of resolution — skip, do not present to the user
- Only present redflags classified as "likely resolved" or "possibly resolved"
- For each, prepare a resolution report (see Resolved Bug Format below)
Heuristics for matching redflags to changes:
- Compare the redflag's tags against changed file paths and content (e.g. a redflag tagged
[testing, fixtures]matching changes in test files) - Check if the redflag's "Solution" or "Prevention" section describes an approach that now appears in the codebase
- Check if the specific file, function, or pattern named in the redflag body was modified
- When in doubt, classify as "possibly resolved" rather than "likely resolved" — the user makes the final call
Resolved Bug Format
Each potentially-resolved redflag is presented with these fields:
memory_path: "memories/redflag/example-bug.memory.md"
title: "Example bug title from the memory"
confidence: "likely" # or "possibly"
evidence: "The diff shows refactoring of X to use the recommended approach described in this memory's Solution section."
recommendation: "forget" # always "forget" — user decidesAll fields are required. confidence is likely or possibly; recommendation is always forget (user decides).
Candidate Fact Format
Each candidate is presented with these fields:
rank: 1
type: "learning"
title: "React.memo on list items reduced re-render time from 480ms to 12ms"
description: "Wrapping list item components in React.memo with a custom comparator that checks item ID and version (not deep-equal) reduced re-render time by 97% on a 500-item list."
tags: [react, performance, rendering, memoization]
scope: "base" # or "agents/{agent-id}"
rationale: "Quantitative performance improvement discovered during component library subtask. Recurred across 3 subtasks involving list rendering."
conflicts: [] # or list of conflict reports
related_memories: [] # existing memories on similar topics
source: "20260401-component-library" # work item identifierAll fields required except conflicts and related_memories. type must be one of the typePriority values (never archived). scope is "base" or "agents/{agent-id}". source mirrors the work-directory slug.
Response Format
This skill follows Pattern B — perform analysis and ranking first, then return results for the calling agent to present. Do NOT call AskQuestion; the calling agent handles all user interaction (see .cursor/skills/_memory-shared.md#user-input-escalation). Include the following structure in your response:
Analysing {unitOfWork} "{work-item-id}"...
✅ Execution verified: {subtask-count} subtasks complete
📊 {change-count} repo changes since start (within threshold)
Comparing with {existing-count} existing memories...
Top {N} candidate facts:
1. [{type}] {title}
{description}
Tags: {tags}
Scope: {scope}
Rationale: {rationale}
2. [{type}] {title}
...
{conflict reports, if any}If resolved bugs were detected, include them in a separate section:
🐛 Resolved bugs detected — {count} redflag memories may no longer be needed:
1. [{confidence}] {title}
File: {memory_path}
Evidence: {evidence}
2. [{confidence}] {title}
...The calling agent will use AskQuestion to collect the user's accept/skip decisions for both candidates and resolved bugs, then pass those decisions back to you.
Each resolved bug the user confirms is deleted via crux-skill-memory-crud Delete operation (memory file and its reference tracker are both removed).
In --yolo mode:
- Auto-accept all new candidates except those with conflicts (conflicts always require user input)
- Auto-forget redflags classified as "likely" resolved
- Present "possibly" resolved redflags for user confirmation (insufficient confidence for auto-deletion)
After the user accepts candidates (all or individually), delegate to crux-skill-memory-crud for actual file creation. Pass the candidate's type, title, description, tags, source, and scope (agent-id if agent-scoped) directly to the CRUD skill's Create operation.
After the user confirms resolved bugs for deletion, delegate to crux-skill-memory-crud Delete operation. The memory file and its reference tracker are both removed.
Error Handling
| Condition | Action |
enableMemories is not "true" | Abort, inform caller memories are disabled |
| State file missing | Return needs_user_input asking the calling agent to confirm whether to proceed |
| State file shows incomplete execution | Report status, abort extraction |
Changed file count exceeds maxUnrelatedChanges | Return needs_user_input with options (proceed, adjust threshold, abort) |
| No artifacts found in work item directory | Report that no analyzable artifacts were found, abort |
| Zero candidates after comparison filtering | Report that all potential insights are already captured in existing memories |
| Conflict detected with existing memory | Present conflict report, require user resolution (never auto-resolve) |
| Config file missing or malformed | Report error with path and expected structure |
Out-of-scope and cross-skill delegation: see
.cursor/skills/_memory-shared.md#cross-skill-boundariesand the agent table inAGENTS.md.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

