bama
BAMA: 모든 Mac 앱을 만들 수 있습니다
Compress verbose LLM rules while retaining self-contained meaning and intent.
저장소 README에서 가져옴
README 전체를 불러오는 중입니다. 아래는 저장된 발췌입니다.
Website: compress.md
Repository: github.com/zotoio/CRUX-Compress
• The Problem
• The Approach
• Demonstration
• Etymology
• Quick Install
• Install Options
• What Gets Installed
• Upgrading
• How They Work Together
• Compression Flow
• Installation in Another Project
• CRUX Components
• 1. CRUX.md - The Specification
• 2. AGENTS.md - Agent Awareness
• 3. _CRUX-RULE.mdc - Always-Applied Rule
• 4. crux-cursor-rule-manager.md - The Subagent
• 5. crux-compress.md - The Command
• 6. crux-detect-changes.py - The Hook
• 7.README 전문 보기 ↗Website: compress.md Repository: github.com/zotoio/CRUX-Compress
Recent update: The memory agent has been split into five mode-scoped thin agents (
crux-memory-dream,crux-memory-rem,crux-memory-recall,crux-memory-remember,crux-memory-forget), reducing per-spawn context load by 52–80% depending on the operation. Primitives loaded unconditionally are now lazy-loaded, cutting context overhead by ~57% across common workflows. Seeanalysis/context-token-reduction-report.mdfor the full analysis.
AI coding assistants like Cursor rely on context windows to understand your project. When you add natural language markdown rules to guide agent behavior, those rules consume valuable context tokens—often thousands of tokens per rule file. As your rule library grows, context window usage balloons, leaving less room for actual code and conversation.
Users want to manage their rules in readable, natural language markdown. But LLMs don't need the verbose prose—they just need the actionable information.
CRUX extracts the essential meaning from natural language markdown rules and compresses it into a logic-based Domain Specific Language (DSL) that all LLMs understand without additional instructions.
CRUX compression works for more than just rules, but this is the current focus.
How it works:
CRUX can compress markdown rules, source code, images, and even public webpages. URL sources are automatically saved to .crux/out/ for easy access.
The result: your context window stays lean while your rules remain powerful.
┌───────────────────────────────────────────────────────────┐
│ │
│ ████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 82% SAVED │
│ │
│ BEFORE: ~625 tokens → AFTER: ~112 tokens │
│ │
└───────────────────────────────────────────────────────────┘
Team Development Standards
Key Definitions
Abbreviation Meaning fn function cls class cmp component pr pull request Style Rules
Indentation & Formatting
- Use 2 spaces for indentation
- Never use tabs! This is strictly enforced
- Lines must not exceed 100 characters
Naming Conventions
Element Convention Examples Functions camelCase getUserData,processOrderClasses PascalCase UserService,OrderProcessorConstants UPPER_SNAKE_CASE MAX_RETRIES,API_BASE_URLQuality Rules
Size Limits
- Functions must be 50 lines or fewer
- Classes must be 300 lines or fewer
Documentation & Testing
- All exported members must have test coverage of at least 80%
- All functions must include JSDoc comments documenting:
- Parameters
- Return value
Complexity
- Cyclomatic complexity must not exceed 10
Code Review Process
- All pull requests require:
- At least 1 approval from a reviewer
- CI pipeline must pass
- If a change is 500 lines or more, you must split it into smaller PRs!
Patterns to Avoid
Anti-Pattern Guidance anytypeStrictly forbidden! Always use proper types console.log
Try this Copy and paste into Claude, ChatGPT, Gemini, or any LLM:
Explain this: ⟦CRUX:coding-standards.md;Ρ{team dev standards};Κ{fn=function;cls=class;cmp=component;pr=pull request};R.style{indent=2sp;¬tabs!;line≤100ch;naming{fn=camelCase;cls=PascalCase;const=UPPER_SNAKE}};R.quality{fn.len≤50;cls.len≤300;∀export→test.cov≥80%;∀fn→jsdoc[params+return];cyclomatic≤10};Λ.review{pr→≥1approval+CI.pass;Δ≥500lines→split!};P.avoid{¬any!;¬console.log[prod];¬magic.num→use.const};E{⊤:err→try/catch→log+handle;⊥:catch(e){/*ignore*/}};Ω{quality≻speed;readable≻clever}⟧
Explain this:
⟦CRUX:coding-standards.md
Ρ{team dev standards}
Κ{fn=function; cls=class; cmp=component; pr=pull request}
R.style{
indent=2sp; ¬tabs!; line≤100ch
naming{fn=camelCase; cls=PascalCase; const=UPPER_SNAKE}
}
R.quality{
fn.len≤50; cls.len≤300; ∀export→test.cov≥80%
∀fn→jsdoc[params+return]; cyclomatic≤10
}
Λ.review{pr→≥1approval+CI.pass; Δ≥500lines→split!}
P.avoid{¬any!; ¬console.log[prod]; ¬magic.num→use.const}
E{⊤:err→try/catch→log+handle; ⊥:catch(e){/*ignore*/}}
Ω{quality≻speed; readable≻clever}
⟧
Note: Larger source documents typically achieve higher compression percentages. A 500-word markdown file might compress to 15% of its original tokens, while a 100-word file might only reach 40%. CRUX helps most dealing with verbose rules.
CRUX = Context Reduction Using X-encoding
The "X" is intentionally flexible:
The name also serves as a backronym for "crux" — the decisive or most important point — which is exactly what the compression preserves while stripping everything else.
The easiest way to install CRUX is to let your AI agent do it. In Cursor, paste this into chat:
Fetch
https://raw.githubusercontent.com/zotoio/CRUX-Compress/main/install.crux.md, read it, and follow its instructions to install CRUX Compress into this project.
The agent will decompress the CRUX installer spec and execute the installation — no python3 or curl required on your system. The spec includes language fallback logic so the agent can implement the installer in whatever runtime is available.
Tip: If your agent can't fetch URLs, save
install.crux.mdto your project and reference it, or paste its contents directly into chat.
If you prefer a traditional install, run:
curl -fsSL https://raw.githubusercontent.com/zotoio/CRUX-Compress/main/install.py | python3 -
If GitHub is blocked in your environment, use the jsDelivr CDN mirror:
curl -fsSL https://cdn.jsdelivr.net/gh/zotoio/CRUX-Compress@main/install.py | python3 -
The installer automatically falls back to jsDelivr for version checks and file downloads when GitHub is unreachable.
Tip: You can also copy
install.pylocally and run it directly withpython3 install.py-- it works the same way.
Prerequisites (script install only): curl and python3.
# With backup of existing files
curl -fsSL .../install.py | python3 - --backup
# Verbose output
curl -fsSL .../install.py | python3 - --verbose
# Scaffold optional memory system components
curl -fsSL .../install.py | python3 - --with-memories
# Install standalone MCP memory server (user-level, all projects)
curl -fsSL .../install.py | python3 - --with-mcp-server
# Show help
curl -fsSL .../install.py | python3 - --help
The installer creates/updates these files in your project:
| File | Purpose |
|---|---|
CRUX.md | Specification (READONLY) |
AGENTS.md | Agent awareness notice |
install.crux.md | Installer spec (update reference) |
.crux/crux.json | Installed CRUX version |
.crux/crux-release-files.json | Release manifest |
.cursor/hooks.json | Hook configuration |
.cursor/hooks/crux-detect-changes.py | File change detection |
.cursor/hooks/crux-session-start.py | Session start hook |
.cursor/agents/crux/crux-cursor-rule-manager.md | Compression subagent |
.cursor/commands/crux/crux-compress.md | Compression command |
.cursor/rules/crux/_CRUX-RULE.mdc | Always-applied rule |
.cursor/skills/crux/crux-utils/ | Utility skill |
Ask your agent to read install.crux.md in your project root and follow the Γ.bootstrap_upgrade instructions. It will detect the installed version, download the latest release, clean up deprecated files from older versions, and update everything.
Alternatively, use the script directly:
# If update.py exists (installed by previous CRUX versions)
python3 .crux/update.py --backup
# Or re-run the installer from source
curl -fsSL https://raw.githubusercontent.com/zotoio/CRUX-Compress/main/install.py | python3 - --backup
The upgrade process automatically migrates existing CRUX primitives into .cursor/<type>/crux/, removes stale files from older versions (e.g., renamed hooks and skills), and cleans deprecated commands from hooks.json.
The CRUX system consists of 6 interconnected components:
flowchart TB
subgraph "CRUX System Architecture"
CRUX["CRUX.md<br/>(Specification)<br/>READONLY"]
AGENTS["AGENTS.md<br/><CRUX> block<br/>(High-visibility notice)"]
RULE["_CRUX-RULE.mdc<br/>(Always-Applied Rule)<br/>.cursor/rules/crux/"]
MANAGER["crux-cursor-rule-manager.md<br/>(Subagent - ΣCRUX)<br/>.cursor/agents/crux/"]
COMMAND["crux-compress.md<br/>(Cursor Command)<br/>.cursor/commands/crux/"]
HOOK["crux-detect-changes.py<br/>(File Edit Hook)<br/>.cursor/hooks/"]
AGENTS -->|"References"| CRUX
RULE -->|"Points to spec"| CRUX
MANAGER -->|"Loads spec"| CRUX
COMMAND -->|"Spawns"| MANAGER
RULE -->|"Delegates compression"| MANAGER
HOOK -->|"Queues files for"| COMMAND
end
subgraph "I/O"
INPUT["*.md / *.sh / *.ts / *.png files"]
OUTPUT["*.crux.md files (universal)"]
CURSOR["*.crux.mdc (Cursor adapter)"]
INPUT -->|"Compression"| OUTPUT
OUTPUT -->|"If .cursor/rules/"| CURSOR
end
CRUX.md - The Specification (Project Root)Purpose: The authoritative specification defining CRUX notation syntax, encoding symbols, and compression rules.
Key Contents:
Ρ, E, Λ, Π, Κ, R, P, Γ, M, Φ, Ω)Critical Rules:
<CRUX> Block in AGENTS.md (Project Root)Purpose: High-visibility notice ensuring ALL agents are aware of CRUX notation before they begin work.
Location: Near the top of AGENTS.md, the first file agents read.
Key Contents:
<CRUX agents="always">
## CRITICAL: CRUX Notation
...
### Foundational CRUX Rules (MUST FOLLOW)
1. NEVER EDIT `CRUX.md`
2. DO NOT LOAD SOURCE FILES when CRUX exists
3. SURGICAL DIFF UPDATES on source changes
4. ABORT IF NO SIGNIFICANT REDUCTION
5. IGNORE EXAMPLE RULES - `.cursor/rules/example/*` are demos only
</CRUX>
Why It Matters: This ensures agents know to:
CRUX.md to understand compression symbols_CRUX-RULE.mdc - Always-Applied Rule (.cursor/rules/crux/)Purpose: A Cursor rule that is always loaded into context, providing agents with instructions for handling CRUX notation.
Key Functions:
CRUX.md and AGENTS.md from the project rootcrux-cursor-rule-manager subagentKey Instructions:
CRUX.md to understand and adhere to the rulescrux-cursor-rule-manager subagentcrux-cursor-rule-manager.md - The Subagent (.cursor/agents/crux/)Purpose: A specialized AI subagent (ΣCRUX) that performs compression and decompression tasks.
Capabilities:
Workflow:
CRUX.md specification (required first step)crux-utils skillsourceChecksum matches → skip if unchangedcrux-utils skill → abort if <50% reductionconfidence: XX%Output Format:
---
generated: YYYY-MM-DD HH:MM
sourceChecksum: "1234567890"
beforeTokens: 2500
afterTokens: 400
reducedBy: 84%
confidence: 92%
alwaysApply: true
---
> [!IMPORTANT]
> Generated file - do not edit!
crux-compress.md - The Command (.cursor/commands/crux/)Purpose: A Cursor command that orchestrates CRUX compression tasks.
Usage:
/crux-compress ALL - Compress all eligible rules
/crux-compress @path/to/file.md - Compress a specific file
/crux-compress @file1.md @file2.md - Compress multiple files
/crux-compress @script.sh - Compress a code file
/crux-compress @image.png - Compress an image
/crux-compress https://example.com/ - Compress a public webpage (outputs to .crux/out/)
/crux-compress ALL --force - Force recompression (delete existing CRUX files first)
/crux-compress @file.md --minified - Compress with single-line output (note that LLMs take more effort to parse and understand this format)
/crux-compress @file.md --plugin=frontmatter-tagger - Run a plugin while compressing
Flags:
| Flag | Description |
|---|---|
--minified | Single-line output, no spaces, max compression |
--force | Delete existing CRUX output files before compression (bypasses checksum skip) |
--plugin <name> / --plugin=<name> | Enable a named plugin from .crux/plugins/registry.json |
--no-plugin <name> | Disable a specific default-enabled plugin |
Key Features:
crux-cursor-rule-manager subagents in parallel--force to bypass)sourceUrl instead of sourceChecksum (outputs to .crux/out/).crux/out/.crux.md + Cursor adapter .crux.mdc (when source is in .cursor/rules/)crux: true frontmatter; code/images need explicit file referencebeforeFetch, beforeCompress, afterCompress, afterValidate) can be enabled via command paramenabledByDefault: true load automatically when no --plugin flags are specified. Use --no-plugin <name> to opt out of a default plugin.Plugin Registry:
Plugins are declared in .crux/plugins/registry.json:
{
"plugins": {
"compression-level": {
"description": "Enforce compression ratio targets and generate token metrics.",
"hooks": ["beforeCompress", "afterCompress"],
"failClosed": false,
"enabledByDefault": true
},
"frontmatter-tagger": {
"description": "Add standardized metadata after compression.",
"hooks": ["afterCompress"],
"failClosed": false,
"enabledByDefault": false
},
"quality-gate": {
"description": "Apply additional policy checks after validation.",
"hooks": ["afterValidate"],
"failClosed": false,
"enabledByDefault": false
},
"release-notes": {
"description": "Collect per-file reduction metrics for release summaries.",
"hooks": ["afterCompress", "afterValidate"],
"failClosed": false,
"enabledByDefault": false
}
}
}
Plugin Loading Modes:
--plugin flags: Default-enabled plugins (e.g. compression-level) load automatically. Use --no-plugin compression-level to opt out.--plugin flags: Only the named plugins load. Defaults are not implicitly added. To get defaults plus extras: --plugin compression-level --plugin frontmatter-taggerThe compression-level plugin is the reference default plugin. It enforces compression ratio targets and injects token metrics (beforeTokens, afterTokens, reducedBy) into output frontmatter. See .crux/plugins/compression-level.md for full specification.
File Convention:
| Type | Extension | Example |
|---|---|---|
| Source (human-readable) | .md | core-tenets.md |
| Compressed (universal, IDE-agnostic) | .crux.md | core-tenets.crux.md |
| Cursor adapter (derived) | .crux.mdc | core-tenets.crux.mdc |
| Compressed code | .crux.md | install.crux.md |
| Compressed image | .crux.md | diagram.crux.md |
| Compressed webpage (URL) | .crux.md | .crux/out/page.crux.md |
crux-detect-changes.py - The Hook (.cursor/hooks/)Purpose: A Cursor hook that automatically detects when source files with crux: true are modified and queues them for compression.
How It Works:
afterFileEdit Cursor hook.cursor/rules/ with .md extension (not .crux.mdc)crux: true in its frontmatter.crux/pending-compression.json for later compressionHook Configuration (.cursor/hooks.json):
{
"version": 1,
"hooks": {
"sessionStart": [
{
"command": "python3 .cursor/hooks/crux-session-start.py",
"description": "Display pending CRUX compressions at session start"
}
],
"afterFileEdit": [
{
"command": "python3 .cursor/hooks/crux-detect-changes.py",
"description": "Queue modified source files for CRUX compression"
}
]
}
}
Benefits:
/crux-compress command workflowcrux-utils - The Skill (.cursor/skills/crux/)Purpose: Multi-purpose utility for CRUX compression workflows.
Modes:
| Mode | Purpose |
|---|---|
--token-count <file> | Estimate tokens for a file |
--token-count --ratio <src> <crux> | Compare source vs CRUX, calculate compression ratio |
--token-count --ratio <src> <crux> --target <n> | Compare with custom target percentage (default 25) |
--cksum <file> | Get checksum formatted for sourceChecksum frontmatter |
Token Estimation Method:
| Content Type | Chars/Token | Notes |
|---|---|---|
| Prose | 4.0 | Markdown text, headers, lists |
| Code blocks | 3.5 | More symbols, shorter identifiers |
| Special chars | 1.0 | CRUX Unicode symbols (→, ⊳, «, etc.) |
Benefits:
crux-cursor-rule-manager for frontmatter metricsSee .cursor/skills/crux/crux-utils/SKILL.md for detailed usage.
CRUX Memories is an optional learning system that lets agents extract, store, and recall knowledge across sessions. Memories persist as structured markdown files and are automatically surfaced to agents based on relevance.
The memory lifecycle has four phases:
Memories are disabled by default. To scaffold the memory system during install:
curl -fsSL .../install.py | python3 - --with-memories
Or enable manually by editing .crux/crux-memories.json and setting enableMemories to "true":
{
"flags": [
{ "enableMemories": "true" }
]
}
Memories are stored in the memories/ directory, organized by type:
| Type | Directory | Purpose |
|---|---|---|
| Core | memories/core/ | Proven, high-value knowledge |
| Red Flag | memories/redflag/ | Pitfalls, anti-patterns, things to avoid |
| Goal | memories/goal/ | Aspirational targets and objectives |
| Learning | memories/learning/ | Patterns and insights from completed work |
| Idea | memories/idea/ | Speculative thoughts for future consideration |
Agent-scoped memories live under memories/agents/{agent-id}/ and are isolated per agent.
| Command | Purpose |
|---|---|
/crux-dream <spec-name> | Extract memories from a completed spec |
/crux-dream --rem | Run REM sleep (rebalance all memories) |
/crux-dream --rem --yolo | REM sleep with auto-apply for non-conflict changes |
/crux-recall | Show contextually relevant memories |
/crux-recall "query" | Search memories by keyword |
/crux-recall <spec-name> | Show memories from a specific spec |
/crux-recall --total | Visualize the entire memory system as an interactive canvas |
/crux-forget <memory-id> | Forget a specific memory by ID |
/crux-forget "query" | Search and select memories to forget |
/crux-remember | Interactively create a new ad-hoc memory |
/crux-remember "insight" | Create a memory from provided text |
/crux-remember "insight" --type learning | Create with a specific type |
/crux-meditate | Deep research exploration of current context — Research mode (default) with citations, peer review, adversarial review, and a paired HTML + PDF report. A merged invocation gate offers richness levels compact / default / detailed / exhaustive (default preselected). A post-consolidation finalisation-enhancement gate (K10, multi-select 0–5) refines the report before adversarial review. |
/crux-meditate "topic" | Same for a specific theme — e.g. /crux-meditate "should we adopt event sourcing for the auth service" |
/crux-meditate --quick "topic" | Faster parallel fan-out (no peer review); citations still required but enforced warn-only |
/crux-meditate --random-model "topic" | Single tree, model randomly picked from cruxMemories.meditate.modelPool; same agent count as default |
/crux-meditate --model-per-branch "topic" | Single tree, each top-level facet branch assigned a distinct model from the pool (descendants inherit); same agent count as default; per-branch model attribution recorded in the report |
/crux-meditate is the heaviest command in the suite — it spawns a recursive research tree of subagents that mine memories, files, and chat history, then delivers a paired HTML + PDF report under meditations/{yyyymmdd}-{topic-slug}/ with infographics, Chart.js / D3 visualisations, an in-page table of contents, a citations index, and a mandatory adversarial review pass over every output file. Reach for it on high-stakes problems you'd otherwise spend a day researching by hand: architecture trade-offs, technology selection, strategic investments.
A meditation is controlled by two orthogonal axes: recursion mode (Research vs Quick) and model strategy (how cruxMemories.meditate.modelPool is used, if at all).
| Mode | Flag | Best for |
|---|---|---|
| Research (default) | none | Depth-first serial recursion with globally unique facets, mandatory inline citations, and branch peer review. Pick this when the output will be cited, persisted, or drive downstream work. |
| Quick | --quick | Fast parallel fan-out (legacy shape). Same report contract and visualisation requirements, no peer review, warn-only citation enforcement. Use for breadth-first early scoping. |
| Strategy | Flag | Trees | Agent count | Best for |
|---|---|---|---|---|
| Single (default) | none | 1, on the caller's model | baseline | Standard runs. |
| Random model | --random-model | 1, on a randomly-picked pool entry | same as baseline | Cheap diversity sampling across multiple invocations. |
| Model per branch | --model-per-branch | 1, each top-level facet branch assigned a distinct pool model (descendants inherit; sampling without replacement when poolSize ≥ branchCount, otherwise round-robin) | same as baseline | Comparing how different models explore different facets without paying the full Ensemble Max cost. Peer reviewer and adversarial reviewer run on the caller's model for a unified cross-branch evaluation. |
| Ensemble (max) | --ensemble | N parallel trees + cross-model aggregator | ~N × baseline + 1 | Maximum-confidence analysis where convergence / divergence between every pool model is the deliverable. Combinable with --quick. |
--random-model, --model-per-branch, and --ensemble are mutually exclusive. The cost-and-richness gate also lets you swap between strategies in place (only the swaps satisfied by the configured modelPool size are offered).
Before the tree spawns, four mandatory pre-spawn gates protect you from runaway cost (depth-3 Research is ~45 agents):
Q-Depth-Selection) — 1 / 2 / 3, default 3.Q-Cost-Acknowledgment) — surfaces the agent count for the selected mode and lets you swap to Quick or Ensemble, or cancel.Q-Confirm-1 and Q-Confirm-2) — you approve the three top-level facets before any branches spawn, and opt in to deep-facet confirmation if desired.If the adversarial review can't reach PASS in ≤3 iterations, the report is not generated and you receive the review iterations plus a structured summary of unresolved findings instead.
Use /crux-amnesia when you want a clean chat session without ambient memory recall, annotations, or reference tracking. This override only affects the current chat session and spawned subagents for ordinary work; it never edits .crux/crux-memories.json and does not block explicit memory-management commands like /crux-dream, /crux-recall, /crux-forget, /crux-remember, or /crux-meditate.
Six specialized skills power the memory system:
| Skill | Purpose |
|---|---|
crux-skill-memory-crud | Create, read, update, delete memory files with frontmatter management |
crux-skill-memory-extract | Analyse completed work and propose ranked candidate facts |
crux-skill-memory-rebalance | Consolidate, promote, demote, and archive memories during REM sleep |
crux-skill-memory-compress | CRUX-compress memory file bodies with adaptive sizing |
crux-skill-memory-index | Build a prioritised memory index from all memory files |
crux-skill-memory-reference-tracker | Track memory references in agent output and sync strength counters |
Six dedicated skills power the crux-cursor-meditation-guide agent:
| Skill | Purpose |
|---|---|
crux-skill-memory-meditation-research | Research-mode Phases A–G depth-first recursion protocol |
crux-skill-memory-meditation-quick | Quick-mode 6-step parallel fan-out protocol |
crux-skill-memory-meditation-ensemble | Ensemble Aggregation cross-model synthesis |
crux-skill-memory-meditation-review | 13-dimension adversarial review-and-fix cycle |
crux-skill-memory-meditation-report | Mandatory paired HTML+PDF report generation |
crux-skill-memory-meditation-coordination | File-based coordination primitives and artefact filename grammar |
Memories gain strength through reference tracking — each time an agent uses a memory, its reference count increments. When a memory reaches a promotion threshold, it transitions to a higher type:
Memories unreferenced for 90 days are demoted; after 180 days they are archived. Memories with very high reference counts (30+) may be promoted to permanent Cursor rules.
Memory bodies can be CRUX-compressed to save storage and context tokens, with the original source archived for rollback.
The CRUX MCP server provides semantic search over the memory corpus via the Model Context Protocol. Agents with MCP access can search memories more effectively than linear index scanning.
The MCP server is distributed as a standalone zip and installed independently of any project. It runs at the user level so all your Cursor projects can use it:
# Install via the CRUX installer
curl -fsSL https://raw.githubusercontent.com/zotoio/CRUX-Compress/main/install.py | python3 - --with-mcp-server
# Or add it to an existing CRUX installation
python3 .crux/update.py --with-mcp-server
This will:
~/.crux-mcp-server/ (or a directory you choose)fastmcp, pyyaml, watchdog)~/.cursor/mcp.json so the server is available across all projectsThe installer configures ~/.cursor/mcp.json automatically:
{
"mcpServers": {
"crux-memories": {
"command": "python3",
"args": ["-m", "crux_mcp_server", "-t", "stdio"],
"cwd": "~/.crux-mcp-server"
}
}
}
Each project still needs its own .crux/crux-memories.json (created by --with-memories) with memory paths pointing to that project's memory directory.
The server can also run in HTTP mode for external integrations:
cd ~/.crux-mcp-server
python3 -m crux_mcp_server -t http --port 8742
See crux_mcp_server/README.md for full options and tool documentation.
The memory system and MCP server require Python >= 3.10. Dependencies are installed automatically by the installer. For manual or dev setup:
# MCP server (installed automatically by --with-mcp-server)
pip install -r crux_mcp_server/requirements.txt
# Eval tests
pip install -r evals/requirements.txt
To use CRUX in your project, see Quick Install.
| File | Purpose |
|---|---|
CRUX.md | Specification (READONLY) |
AGENTS.md | Agent awareness notice (or add the <CRUX> block to your existing AGENTS.md) |
install.crux.md | Installer spec (update reference) |
.crux/crux.json | Installed CRUX version |
.crux/crux-release-files.json | Release manifest with per-version checksums |
.cursor/hooks.json | Hook configuration |
.cursor/hooks/crux-detect-changes.py | File change detection hook |
.cursor/hooks/crux-detect-memory-changes.py | Memory change detection hook |
.cursor/hooks/crux-session-start.py | Session start hook |
.cursor/agents/crux/crux-cursor-rule-manager.md | Compression subagent |
.cursor/agents/crux/crux-cursor-memory-manager.md | Memory lifecycle dispatcher (deprecated — see thin agents below) |
.cursor/agents/crux/crux-memory-dream.md | Dream mode agent (memory extraction) |
.cursor/agents/crux/crux-memory-rem.md | REM Sleep mode agent (rebalance) |
.cursor/agents/crux/crux-memory-recall.md | Recall mode agent (query memories) |
.cursor/agents/crux/crux-memory-remember.md | Remember mode agent (ad-hoc creation) |
.cursor/agents/crux/crux-memory-forget.md | Forget mode agent (memory removal) |
.cursor/agents/crux/templates/recall-canvas.tsx.md | Canvas structural template (used by Recall --total) |
.cursor/agents/crux/crux-cursor-meditation-guide.md | Recursive meditation research guide (spawned by /crux-meditate) |
.cursor/commands/crux/crux-compress.md | Compression command |
.cursor/commands/crux/crux-dream.md | Memory extraction command |
Then:
.cursor/hooks.json is recognized by Cursorcrux: true to any rule files you want to compress/crux-compress ALL to compress eligible filesflowchart TD
USER["User: /crux-compress @.cursor/rules/my-rule.md"]
subgraph COMMAND["crux-compress.md (Command)"]
C1["Parse arguments"]
C2["Resolve plugins (--plugin)"]
C3["Spawn subagent(s)"]
C1 --> C2 --> C3
end
subgraph MANAGER["crux-cursor-rule-manager (Subagent)"]
M1["1. Read CRUX.md specification"]
M2["2. Get checksum (crux-utils skill)"]
M3{"3. sourceChecksum matches?"}
M4["4. Read source file"]
M5["5. Estimate tokens (crux-utils skill)"]
M6{"6. Reduction ≥50%?"}
M7["7. Apply compression rules"]
M8["8. Write .crux.md (universal)"]
M9{"9. Source in .cursor/rules/?"}
M10["10. Copy to .crux.mdc + alwaysApply"]
M1 --> M2 --> M3
M3 -->|"Yes"| SKIP["Skip - source unchanged"]
M3 -->|"No"| M4 --> M5 --> M6
M6 -->|"No"| ABORT["Abort - not beneficial"]
M6 -->|"Yes"| M7 --> M8 --> M9
M9 -->|"Yes"| M10
M9 -->|"No"| DONE["Done"]
end
USER --> COMMAND
COMMAND --> MANAGER
flowchart TD
START["Agent loads context"]
subgraph RULE["_CRUX-RULE.mdc (Always Applied)"]
R1["Instructs: interpret CRUX notation"]
R2["Points to CRUX.md for symbols"]
end
subgraph INTERPRET["Agent encounters «CRUX⟨source.md⟩»"]
I1["Uses compressed content directly"]
I2["Does NOT load source.md"]
I3["Interprets symbols per CRUX.md"]
end
START --> RULE
RULE --> INTERPRET
flowchart TD
START["User modifies source.md"]
subgraph RULE["_CRUX-RULE.mdc detects change"]
R1["Triggers: SURGICAL DIFF UPDATES"]
R2["Invokes crux-cursor-rule-manager"]
R1 --> R2
end
subgraph MANAGER["crux-cursor-rule-manager"]
M1["Read existing .crux.md"]
M2["Identify what changed in source"]
M3["Apply minimal targeted edits"]
M4["Update generated timestamp"]
M5["Update sourceChecksum"]
M6["Regenerate .crux.mdc adapter (if applicable)"]
M1 --> M2 --> M3 --> M4 --> M5 --> M6
end
START --> RULE
RULE --> MANAGER
These rules are defined in CRUX.md (numbered 0-4) and enforced by all CRUX components:
CRUX.md - The specification is read-only unless explicitly asked by the user«CRUX⟨...⟩» content directly| Component | Path | Purpose |
|---|---|---|
| Specification | CRUX.md | Defines notation syntax |
| Agent Notice | AGENTS.md (CRUX block) | High-visibility awareness |
| Version Metadata | .crux/crux.json | Installed CRUX version |
| Release Manifest | .crux/crux-release-files.json | File checksums for backup |
| Always-Applied Rule | .cursor/rules/crux/_CRUX-RULE.mdc | Runtime instructions |
| Subagent | .cursor/agents/crux/crux-cursor-rule-manager.md | Compression executor |
| Compress Command | .cursor/commands/crux/crux-compress.md | Compression interface |
| Test Command | .cursor/commands/crux-test.md | Pytest command-suite shim |
| Hook | .cursor/hooks/crux-detect-changes.py | Auto-detect file changes |
| Session Hook | .cursor/hooks/crux-session-start.py | Show pending compressions |
| Hook Config | .cursor/hooks.json | Hook configuration |
| Utility Skill | .cursor/skills/crux/crux-utils/ | Token estimation, checksums |
| Install Script | install.py | Curl-pipe installer (Python) |
| Zip Builder | scripts/create-crux-zip.py | Build distribution zip |
| Tests | evals/*.py | Pytest test suite |
| CI Workflows | .github/workflows/ | Automated testing and releases |
| Dev Rules | .cursor/rules/*.mdc | Development workflow rules |
| Plugin Registry | .crux/plugins/registry.json | Plugin declarations and hook bindings |
| Plugin Spec | .crux/plugins/compression-level.md | Default compression-level plugin spec |
/crux-compress @.cursor/rules/my-rule.md
Add to frontmatter:
---
crux: true
---
Note: Both .md and .mdc files with crux: true are eligible. For .mdc files, the compression workflow will:
.md (preserving the source).crux.md (universal output).cursor/rules/, also produce .crux.mdc (Cursor adapter with alwaysApply)Compressed files include metrics in frontmatter:
beforeTokens: 2500 # Original
afterTokens: 400 # Compressed (16% of original)
reducedBy: 84% # Compression percentage
confidence: 92% # Semantic validation score
Confidence Score indicates how well CRUX preserves semantic meaning:
STRUCTURE: «»⟨⟩{}[]().sub
COMPARE: > < ≥ ≤
PRIORITY: ≻ ≺
DATA FLOW: → ←
RELATIONS: ⊳ ⊲ @ : = ∋
LOGIC: | & ⊤ ⊥ ∀ ∃ ¬
CHANGE: Δ + -
QUALIFY: * ? ! #
IMPORTANCE: ⊛ ◊
BLOCKS: Ρ E Λ Π Κ R P Γ M Φ Ω
See CRUX.md for complete specification.
CRUX Compress includes comprehensive test coverage for all scripts.
Tests use pytest:
# Install test dependencies
pip install -r evals/requirements.txt
# Run all tests
pytest evals/ -v
# Run specific test file
pytest evals/test_crux_utils.py -v
# Run with short output
pytest evals/ --tb=short
All shell scripts are validated with shellcheck. Run locally before committing:
# Install shellcheck (if not already installed)
# macOS
brew install shellcheck
# Ubuntu/Debian
sudo apt install shellcheck
# Run all tests
python3 scripts/test.py
| Script | Test File | Coverage |
|---|---|---|
crux-utils.py | test_crux_utils.py | Token counting, checksums, ratios, --target flag, error handling |
scripts/create-crux-zip.py | test_create_zip.py | Zip contents, version embedding, structure |
crux-detect-changes.py | test_detect_hook.py | Frontmatter detection, queue management |
install.py | test_install.py | CLI flags, version comparison, hooks merge, --with-memories, --with-mcp-server, upsert |
registry.json | test_n_plugin_registry.py | Registry schema, enabledByDefault semantics, plugin validation |
| Memory CRUD | test_a_memory_crud.py | Memory create, read, update, delete |
| Dream extraction | test_b_dream_workflow.py | Post-spec memory extraction workflow |
| REM sleep | test_c_rem_sleep.py | Promotion, demotion, archival |
| Reference tracking | test_d_reference_tracking.py | Usage tracking and strength sync |
| Memory index | test_e_memory_index.py | Index building and prioritisation |
| Type transitions | test_f_type_transitions.py | Type transition logic |
| Memory compression | test_g_compression.py | Memory CRUX compression |
| Agent scoping | test_h_agent_scoping.py | Agent memory isolation |
| Scope ranking | test_i_scope_ranking.py | Scope ranking logic |
| Session hook | test_k_session_hook.py | Memory nudge on session start |
| MCP server | test_l_mcp_server.py | MCP server tools |
| Config validation |
The evals/ directory contains pytest-based integration tests for the memory system:
# Install dependencies
pip install -r evals/requirements.txt
# Run eval tests
pytest evals/ -v
The scripts/test.py wrapper runs available automated test suites in sequence and
prints a warning instead of a false success when required tools such as pytest
are not installed.
/crux-test)/crux-test is a thin pytest shim. Cases live in evals/test_r_crux_command_suite.py; LLM-driven scenarios are marked llm_driven and skipped by default in CI.
# All deterministic command-suite tests
python3 scripts/run_crux_command_suite.py
# Fast CI smoke subset
python3 scripts/run_crux_command_suite.py --smoke
# Smoke via pytest directly
python3 -m pytest evals/test_r_crux_command_suite.py -m crux_command_smoke -v
In Cursor, invoke /crux-test to run the same suite. Historical scenario names (compression, validation, etc.) map to pytest classes documented in the /crux-test command.
CRUX Compress uses GitHub Actions for automated testing and releases.
| Workflow | Trigger | Purpose |
|---|---|---|
test.yml | PR, Push | Runs pytest, validates zip, checks scripts |
version-bump.yml | Push to main | Auto-bumps version based on conventional commits |
release.yml | Version change | Creates GitHub Release with zip artifact |
Version bumping follows conventional commits:
| Commit Type | Version Bump | Example |
|---|---|---|
feat: | Minor (1.X.0) | feat: add new compression mode |
fix: | Patch (1.0.X) | fix: handle empty files |
BREAKING CHANGE: | Major (X.0.0) | Body contains "BREAKING CHANGE:" |
| Other | Patch (1.0.X) | docs: update readme |
main with conventional commit messagesversion-bump.yml reads .crux/dist-manifest.json for release-relevant paths, analyzes commits, and updates .crux/crux.jsonrelease.yml detects version change and runs scripts/create-crux-zip.py, which:CRUX-Compress-vX.Y.Z.zip).crux/dist-manifest.json (canonical file list).crux/crux-release-files.jsonvX.X.Z, attaches the zip, and generates release notesgit checkout -b feature/my-featurepytest evals/ -vgit commit -m "feat: add my feature"MIT License - see LICENSE file for details.
| Not allowed in production code |
| Magic numbers | Extract to named constants instead |
When handling errors, use try/catch with proper logging and handling:
try {
await riskyOperation();
} catch (error) {
logger.error('Operation failed', error);
handleError(error);
}
Never silently swallow errors:
try {
await riskyOperation();
} catch (e) {
/* ignore */
}
/crux-meditate --ensemble "topic" | Ensemble max — run the meditation across every model in the pool in parallel, then aggregate into a cross-model synthesis report |
/crux-amnesia | Toggle session-only amnesia mode for ambient memory usage |
/crux-amnesia on|off|status | Disable, restore, or inspect session memory mode without changing repo config |
.cursor/commands/crux/crux-recall.md | Memory retrieval command |
.cursor/commands/crux/crux-forget.md | Memory removal command |
.cursor/commands/crux/crux-remember.md | Ad-hoc memory creation command |
.cursor/commands/crux/crux-meditate.md | Recursive exploration command |
.cursor/rules/crux/_CRUX-RULE.mdc | Always-applied rule |
.cursor/rules/crux/crux-memories-integration.crux.mdc | Memory integration rule |
.cursor/skills/crux/crux-utils/ | Utility skill (token estimation, checksums) |
.cursor/skills/crux/crux-skill-memory-*/ | Memory skills (CRUD, compress, extract, index, rebalance, reference tracking) |
| Memory Config | .crux/crux-memories.json | Memory system configuration |
| Memory Index | .crux/memory-index.yml | Prioritised memory index |
| Memory Manager | .cursor/agents/crux/crux-cursor-memory-manager.md | Dispatcher (deprecated — see thin agents) |
| Memory Dream Agent | .cursor/agents/crux/crux-memory-dream.md | Dream mode (memory extraction) |
| Memory REM Agent | .cursor/agents/crux/crux-memory-rem.md | REM Sleep mode (rebalance) |
| Memory Recall Agent | .cursor/agents/crux/crux-memory-recall.md | Recall mode (query memories) |
| Memory Remember Agent | .cursor/agents/crux/crux-memory-remember.md | Remember mode (ad-hoc creation) |
| Memory Forget Agent | .cursor/agents/crux/crux-memory-forget.md | Forget mode (memory removal) |
| Meditation Guide | .cursor/agents/crux/crux-cursor-meditation-guide.md | Recursive meditation research agent |
| Dream Command | .cursor/commands/crux/crux-dream.md | Memory extraction command |
| Recall Command | .cursor/commands/crux/crux-recall.md | Memory query command |
| Forget Command | .cursor/commands/crux/crux-forget.md | Memory removal interface |
| Remember Command | .cursor/commands/crux/crux-remember.md | Ad-hoc memory creation |
| Meditate Command | .cursor/commands/crux/crux-meditate.md | Recursive memory exploration |
| MCP Server | crux_mcp_server/ | Semantic memory search server (standalone zip) |
| Memory Skills | .cursor/skills/crux/crux-skill-memory-*/ | Memory operation skills |
| Memory Storage | memories/ | Memory file storage |
| Eval Tests | evals/ | Python-based eval test suite |
test_m_config_validation.py| Configuration validation |