@dug-21/unimatrix 0.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/unimatrix.js +62 -0
- package/lib/init.js +267 -0
- package/lib/merge-settings.js +188 -0
- package/lib/resolve-binary.js +69 -0
- package/package.json +32 -0
- package/postinstall.js +61 -0
- package/skills/knowledge-lookup/SKILL.md +120 -0
- package/skills/knowledge-search/SKILL.md +113 -0
- package/skills/query-patterns/SKILL.md +110 -0
- package/skills/record-outcome/SKILL.md +96 -0
- package/skills/retro/SKILL.md +296 -0
- package/skills/review-pr/SKILL.md +128 -0
- package/skills/store-adr/SKILL.md +142 -0
- package/skills/store-lesson/SKILL.md +109 -0
- package/skills/store-pattern/SKILL.md +124 -0
- package/skills/store-procedure/SKILL.md +114 -0
- package/skills/uni-git/SKILL.md +117 -0
- package/skills/uni-init/SKILL.md +169 -0
- package/skills/uni-knowledge-lookup/SKILL.md +120 -0
- package/skills/uni-knowledge-search/SKILL.md +113 -0
- package/skills/uni-query-patterns/SKILL.md +110 -0
- package/skills/uni-record-outcome/SKILL.md +96 -0
- package/skills/uni-release/SKILL.md +210 -0
- package/skills/uni-retro/SKILL.md +296 -0
- package/skills/uni-review-pr/SKILL.md +128 -0
- package/skills/uni-seed/SKILL.md +271 -0
- package/skills/uni-store-adr/SKILL.md +142 -0
- package/skills/uni-store-lesson/SKILL.md +109 -0
- package/skills/uni-store-pattern/SKILL.md +124 -0
- package/skills/uni-store-procedure/SKILL.md +114 -0
- package/skills/unimatrix-init/SKILL.md +171 -0
- package/skills/unimatrix-seed/SKILL.md +271 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: "store-pattern"
|
|
3
|
+
description: "Store a reusable implementation pattern in Unimatrix. Use when you discover a gotcha, trap, or reusable solution that future agents should know."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Store Pattern — Implementation Knowledge
|
|
7
|
+
|
|
8
|
+
## What This Skill Does
|
|
9
|
+
|
|
10
|
+
Stores a reusable pattern in Unimatrix. Patterns capture implementation gotchas, traps, and solutions — knowledge invisible in source code that you only learn by hitting it. They surface in future `/query-patterns` results so the next agent doesn't repeat the discovery.
|
|
11
|
+
|
|
12
|
+
**Use when:** you discover something that compiles but breaks at runtime, a non-obvious integration requirement, a crate-specific trap, or a reusable solution to a recurring problem.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Pattern vs Lesson vs Procedure
|
|
17
|
+
|
|
18
|
+
| Type | When to use | Example |
|
|
19
|
+
|------|------------|---------|
|
|
20
|
+
| **Pattern** (`/store-pattern`) | Reusable solution or gotcha applicable regardless of failure context | "Don't hold lock_conn() across await — deadlocks under concurrent requests" |
|
|
21
|
+
| **Lesson** (`/store-lesson`) | Triggered by a specific failure; takeaway is preventive | "Gate 3b failed because rust-dev didn't read ADR before implementing" |
|
|
22
|
+
| **Procedure** (`/store-procedure`) | Ordered steps to accomplish a task | "How to add a new MCP tool: step 1, 2, 3..." |
|
|
23
|
+
|
|
24
|
+
**Decision rule:** If the knowledge was triggered by a specific failure and the takeaway is "don't do X," use `/store-lesson`. If the knowledge is a reusable solution applicable regardless of failure context — "when doing X, use approach Y because Z" — use `/store-pattern`.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## How to Store
|
|
29
|
+
|
|
30
|
+
### Step 1: Check for existing patterns in the same area
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
mcp__unimatrix__context_search(
|
|
34
|
+
query: "{what the pattern is about}",
|
|
35
|
+
category: "pattern",
|
|
36
|
+
k: 3
|
|
37
|
+
)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
If a matching pattern already exists, go to Step 2b (supersede) instead of creating a duplicate.
|
|
41
|
+
|
|
42
|
+
### Step 2a: Store NEW pattern (no prior exists)
|
|
43
|
+
|
|
44
|
+
Assemble the content from three required fields:
|
|
45
|
+
|
|
46
|
+
- **What**: The pattern in one sentence (max 200 chars). What to do or not do.
|
|
47
|
+
- **Why**: What goes wrong without it (min 10 chars). The consequence that makes this worth knowing.
|
|
48
|
+
- **Scope**: Where it applies — crate name, module, or context.
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
mcp__unimatrix__context_store(
|
|
52
|
+
title: "{concise what statement}",
|
|
53
|
+
content: "What: {what}\nWhy: {why}\nScope: {scope}",
|
|
54
|
+
topic: "{crate name or module — e.g., 'unimatrix-store'}",
|
|
55
|
+
category: "pattern",
|
|
56
|
+
tags: ["{domain}", "{feature_cycle if known}"],
|
|
57
|
+
agent_id: "{your role name, e.g. uni-rust-dev}"
|
|
58
|
+
)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Step 2b: Supersede EXISTING pattern (prior exists but is incomplete or outdated)
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
mcp__unimatrix__context_correct(
|
|
65
|
+
original_id: {old entry ID},
|
|
66
|
+
content: "What: {updated what}\nWhy: {updated why}\nScope: {updated scope}",
|
|
67
|
+
reason: "Updated: {what changed and why}"
|
|
68
|
+
)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
This deprecates the old pattern and creates a corrected version with a supersession chain.
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Quality Rules
|
|
76
|
+
|
|
77
|
+
**Reject if:**
|
|
78
|
+
- `why` is missing or under 10 characters — no motivation, no value
|
|
79
|
+
- `what` exceeds 200 characters — not concise enough
|
|
80
|
+
- Content is API documentation, not a gotcha — "Store has a lock_conn() method" is docs, not a pattern
|
|
81
|
+
|
|
82
|
+
**Good patterns:**
|
|
83
|
+
```
|
|
84
|
+
What: Don't hold lock_conn() across await points
|
|
85
|
+
Why: Deadlocks under concurrent MCP requests — the Store mutex is not async-aware
|
|
86
|
+
Scope: unimatrix-store, any async caller
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
What: Use #[serde(default)] on all new EntryRecord fields
|
|
91
|
+
Why: Existing serialized records lack the field; deserialization panics without default
|
|
92
|
+
Scope: unimatrix-core EntryRecord, any schema evolution
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
**Bad patterns:**
|
|
96
|
+
```
|
|
97
|
+
What: I used Arc::clone for shared ownership
|
|
98
|
+
Why: It works
|
|
99
|
+
```
|
|
100
|
+
(No gotcha. No consequence. This is just Rust basics.)
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## Tagging Conventions
|
|
105
|
+
|
|
106
|
+
| Tag type | Examples |
|
|
107
|
+
|----------|----------|
|
|
108
|
+
| Crate | `store`, `server`, `vector`, `core`, `embed`, `engine` |
|
|
109
|
+
| Domain | `async`, `serialization`, `migration`, `mcp`, `confidence` |
|
|
110
|
+
| Feature cycle | `vnc-009`, `crt-005` (for retro traceability) |
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## Who Stores Patterns
|
|
115
|
+
|
|
116
|
+
| Agent | When |
|
|
117
|
+
|-------|------|
|
|
118
|
+
| uni-rust-dev | Implementation gotchas discovered while coding |
|
|
119
|
+
| uni-tester | Test infrastructure patterns, fixture usage discoveries |
|
|
120
|
+
| uni-risk-strategist | Risk patterns that recur across features |
|
|
121
|
+
| uni-researcher | Technical landscape patterns from problem space exploration |
|
|
122
|
+
| uni-vision-guardian | Recurring alignment variance patterns across features |
|
|
123
|
+
| uni-validator | Quality patterns (cross-feature, not gate-specific) |
|
|
124
|
+
| Retrospective agents | Patterns extracted from shipped feature analysis |
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: "store-procedure"
|
|
3
|
+
description: "Store or update a technical procedure (how-to) in Unimatrix. Use during retrospectives when a technique has evolved or been discovered."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Store Procedure — Technical How-To Knowledge
|
|
7
|
+
|
|
8
|
+
## What This Skill Does
|
|
9
|
+
|
|
10
|
+
Stores a step-by-step technical procedure in Unimatrix. Procedures describe HOW to accomplish specific tasks in this project. They evolve as the project evolves.
|
|
11
|
+
|
|
12
|
+
**Use during retrospectives** — not while implementing. Procedures are extracted from evidence, not guessed mid-session.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Procedure vs Convention vs Pattern
|
|
17
|
+
|
|
18
|
+
| Type | What it is | Example |
|
|
19
|
+
|------|-----------|---------|
|
|
20
|
+
| **Procedure** | Ordered steps to accomplish a task | "How to add a new MCP tool: step 1, 2, 3..." |
|
|
21
|
+
| **Convention** | A rule or standard | "No .unwrap() in non-test code" |
|
|
22
|
+
| **Pattern** | A reusable solution to a recurring problem | "Fresh context for unbiased review" |
|
|
23
|
+
|
|
24
|
+
If it has **numbered steps**, it's a procedure. If it's a **rule**, it's a convention. If it's a **when/why/how solution**, it's a pattern.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## How to Store a New Procedure
|
|
29
|
+
|
|
30
|
+
### Step 1: Check for existing procedure
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
mcp__unimatrix__context_search(
|
|
34
|
+
query: "{what the procedure covers}",
|
|
35
|
+
category: "procedure",
|
|
36
|
+
k: 3
|
|
37
|
+
)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
If an existing procedure covers the same task, use Step 2 (Update) instead.
|
|
41
|
+
|
|
42
|
+
### Step 2a: Store NEW procedure
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
mcp__unimatrix__context_store(
|
|
46
|
+
title: "How to {task description}",
|
|
47
|
+
content: "{step-by-step content}",
|
|
48
|
+
topic: "{crate or area — e.g., 'unimatrix-server'}",
|
|
49
|
+
category: "procedure",
|
|
50
|
+
tags: ["{domain}", "{consuming-roles}"],
|
|
51
|
+
agent_id: "{your role name, e.g. uni-architect}"
|
|
52
|
+
)
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Step 2b: UPDATE existing procedure (supersedes old version)
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
mcp__unimatrix__context_correct(
|
|
59
|
+
original_id: {old entry ID},
|
|
60
|
+
content: "{updated step-by-step content}",
|
|
61
|
+
reason: "Updated: {what changed and why}"
|
|
62
|
+
)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
This deprecates the old entry and creates a new one with a supersession chain. Agents querying later will get the latest version.
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## Content Format
|
|
70
|
+
|
|
71
|
+
Procedures should be **concise and actionable** (200-500 chars):
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
How to add a new MCP tool:
|
|
75
|
+
1. Add validate_{tool}_params fn in validation.rs (pure, no I/O)
|
|
76
|
+
2. Add format_{tool}_success fn in response.rs (summary + markdown + json)
|
|
77
|
+
3. Add handler block in tools.rs match arm
|
|
78
|
+
4. Add AuditEvent variant in audit.rs
|
|
79
|
+
5. Add tool schema in server registration
|
|
80
|
+
6. Add integration test in product/test/infra-001/
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
NOT:
|
|
84
|
+
```
|
|
85
|
+
When you want to add a new MCP tool to the server, you should first consider
|
|
86
|
+
the validation requirements. The validation module in validation.rs contains
|
|
87
|
+
pure functions that validate input parameters...
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Tagging Conventions
|
|
93
|
+
|
|
94
|
+
| Tag type | Examples |
|
|
95
|
+
|----------|----------|
|
|
96
|
+
| Crate/area | `server`, `store`, `vector`, `core`, `embed` |
|
|
97
|
+
| Consuming roles | `rust-dev`, `pseudocode`, `architect` |
|
|
98
|
+
| Domain | `mcp-tool`, `schema`, `testing`, `integration` |
|
|
99
|
+
|
|
100
|
+
Always include at least one consuming-role tag so `/query-patterns` can filter by who needs it.
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## When to Store vs When to Skip
|
|
105
|
+
|
|
106
|
+
**Store when:**
|
|
107
|
+
- A multi-step technique was used across 2+ features
|
|
108
|
+
- An existing procedure was wrong and needed correction
|
|
109
|
+
- A developer had to figure out steps that should have been documented
|
|
110
|
+
|
|
111
|
+
**Skip when:**
|
|
112
|
+
- The technique was used once and may not recur
|
|
113
|
+
- The steps are obvious to any Rust developer (not project-specific)
|
|
114
|
+
- The procedure is workflow choreography (that stays in coordinator agent defs)
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# uni-git — Git Conventions for Unimatrix
|
|
2
|
+
|
|
3
|
+
## Branch-First Workflow
|
|
4
|
+
|
|
5
|
+
All workflows produce PRs. No workflow commits directly to main.
|
|
6
|
+
|
|
7
|
+
### Branch Naming
|
|
8
|
+
|
|
9
|
+
| Context | Pattern | Example | Creator |
|
|
10
|
+
|---------|---------|---------|---------|
|
|
11
|
+
| Feature (design + delivery) | `feature/{phase}-{NNN}` | `feature/crt-009` | uni-scrum-master (Session 1 creates, Session 2 continues) |
|
|
12
|
+
| Bug fix | `bugfix/{issue}-{desc}` | `bugfix/52-embed-retry` | uni-scrum-master (bugfix session) |
|
|
13
|
+
| Ad-hoc docs/config | `docs/{short-desc}` | `docs/update-vision` | Human or primary agent |
|
|
14
|
+
| Workflow/process | `workflow/{desc}` | `workflow/base-002` | Human or primary agent |
|
|
15
|
+
|
|
16
|
+
### Branch Lifecycle
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# Session 1 (Design): create feature branch, commit artifacts, open DRAFT PR
|
|
20
|
+
git checkout -b feature/{phase}-{NNN}
|
|
21
|
+
git add <files> && git commit -m "design: {description} (#{issue})"
|
|
22
|
+
git push -u origin feature/{phase}-{NNN}
|
|
23
|
+
gh pr create --draft --title "[{feature-id}] {title}" --body "..."
|
|
24
|
+
|
|
25
|
+
# Session 2 (Implementation): continue on same branch, convert draft to ready
|
|
26
|
+
git checkout feature/{phase}-{NNN} # if not already on it
|
|
27
|
+
git add <files> && git commit -m "{prefix}: {description} (#{issue})"
|
|
28
|
+
git push -u origin feature/{phase}-{NNN}
|
|
29
|
+
gh pr ready {pr-number} # convert draft → ready for review
|
|
30
|
+
|
|
31
|
+
# After merge: branch auto-deletes (repo setting enabled)
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Commit Format
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
{prefix}: {description} (#{issue})
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
| Prefix | When |
|
|
41
|
+
|--------|------|
|
|
42
|
+
| `design:` | Design docs (Session 1) |
|
|
43
|
+
| `pseudocode:` | Stage 3a artifacts |
|
|
44
|
+
| `impl({component}):` | Component implementation |
|
|
45
|
+
| `test:` | Test execution |
|
|
46
|
+
| `fix({gate}):` | Gate rework |
|
|
47
|
+
| `fix:` | Bug fix |
|
|
48
|
+
| `docs:` | Standalone documentation changes |
|
|
49
|
+
|
|
50
|
+
## PR Merge Strategy
|
|
51
|
+
|
|
52
|
+
**Rebase-only** (`gh pr merge --rebase`). Squash acceptable for single-commit PRs. Merge commits are disabled at repo level.
|
|
53
|
+
|
|
54
|
+
## PR Template
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
gh pr create \
|
|
58
|
+
--title "[{feature-id}] {short description}" \
|
|
59
|
+
--body "$(cat <<'EOF'
|
|
60
|
+
## Summary
|
|
61
|
+
Implements {feature-id} per approved design.
|
|
62
|
+
|
|
63
|
+
## Source Documents
|
|
64
|
+
- Architecture: product/features/{id}/architecture/ARCHITECTURE.md
|
|
65
|
+
- Specification: product/features/{id}/specification/SPECIFICATION.md
|
|
66
|
+
- Risk Strategy: product/features/{id}/RISK-TEST-STRATEGY.md
|
|
67
|
+
|
|
68
|
+
## Gate Results
|
|
69
|
+
- Gate 3a (Design Review): PASS
|
|
70
|
+
- Gate 3b (Code Review): PASS
|
|
71
|
+
- Gate 3c (Risk Validation): PASS
|
|
72
|
+
|
|
73
|
+
## GH Issue
|
|
74
|
+
Closes #{N}
|
|
75
|
+
EOF
|
|
76
|
+
)"
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Worktree Isolation
|
|
80
|
+
|
|
81
|
+
Coordinators use Claude Code's native `isolation: "worktree"` parameter when spawning worker agents. Claude Code automatically creates worktrees at `.claude/worktrees/agent-{id}/` and cleans up afterward.
|
|
82
|
+
|
|
83
|
+
**Coordinator responsibilities:**
|
|
84
|
+
- Spawn agents with `isolation: "worktree"` for parallel workstreams
|
|
85
|
+
- Clean up **worker** worktrees after their code is committed to the feature branch (after each gate pass)
|
|
86
|
+
- Do NOT remove the session's own worktree — it must persist until PR merge
|
|
87
|
+
- If removal fails (dirty state): warn human, do NOT force-remove
|
|
88
|
+
|
|
89
|
+
**Mandatory cleanup after each gate pass:**
|
|
90
|
+
```bash
|
|
91
|
+
# Remove worker worktrees whose code has been committed
|
|
92
|
+
git worktree remove .claude/worktrees/{agent-id}/ 2>/dev/null
|
|
93
|
+
# Prune stale entries
|
|
94
|
+
git worktree prune
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Each worktree contains a full `target/` build directory (~1-2GB). Failing to clean up causes disk exhaustion during parallel development.
|
|
98
|
+
|
|
99
|
+
**Stale worktree recovery:** `git worktree prune` removes entries for deleted directories. Human can `git worktree remove --force` if needed.
|
|
100
|
+
|
|
101
|
+
## Build Artifact Isolation
|
|
102
|
+
|
|
103
|
+
| Binary | Location | Used by |
|
|
104
|
+
|--------|----------|---------|
|
|
105
|
+
| Installed | `~/.local/bin/unimatrix-server` | Hooks, MCP server |
|
|
106
|
+
| Build artifact | `target/release/unimatrix-server` | Integration tests |
|
|
107
|
+
|
|
108
|
+
- `cargo build --release` in a worktree does NOT affect `~/.local/bin/` or other worktrees (each worktree has its own `target/`)
|
|
109
|
+
- To update the installed binary: `cargo install --path crates/unimatrix-server`
|
|
110
|
+
- Integration tests in worktrees: set `UNIMATRIX_BINARY` to the worktree's own `target/release/unimatrix-server`
|
|
111
|
+
|
|
112
|
+
## Rules
|
|
113
|
+
|
|
114
|
+
- Never force-push to main
|
|
115
|
+
- Never commit `.env`, credentials, or build artifacts
|
|
116
|
+
- Never skip pre-commit hooks (`--no-verify`)
|
|
117
|
+
- Feature branches auto-delete after merge
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: "uni-init"
|
|
3
|
+
description: "Initialize Unimatrix in a repository: append knowledge block to CLAUDE.md and produce agent orientation recommendations."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# /uni-init — Repository Initialization
|
|
7
|
+
|
|
8
|
+
## Prerequisites
|
|
9
|
+
|
|
10
|
+
Before running this skill:
|
|
11
|
+
|
|
12
|
+
1. **Skill files installed**: Both `uni-init/SKILL.md` and `uni-seed/SKILL.md` must be present in `.claude/skills/` in the target repository.
|
|
13
|
+
2. **MCP server wired** (for `/uni-seed`): The Unimatrix MCP server (`unimatrix-server`) must be running and configured in your Claude Code `settings.json`. This skill (`/uni-init`) does not require MCP, but `/uni-seed` does.
|
|
14
|
+
|
|
15
|
+
If you need to install the Unimatrix server or wire MCP, consult the installation documentation.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## What This Skill Does
|
|
20
|
+
|
|
21
|
+
Sets up Unimatrix awareness in a repository by:
|
|
22
|
+
1. Checking if Unimatrix is already initialized (idempotency guard)
|
|
23
|
+
2. Scanning agent definitions for orientation gaps (read-only)
|
|
24
|
+
3. Appending a self-contained Unimatrix knowledge block to CLAUDE.md
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Arguments
|
|
29
|
+
|
|
30
|
+
- **No arguments**: Run the full initialization (sentinel check, agent scan, CLAUDE.md append).
|
|
31
|
+
- **`--dry-run`**: Print what would happen without modifying any files.
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Execution Steps
|
|
36
|
+
|
|
37
|
+
Follow these phases in strict order. Do not skip or reorder.
|
|
38
|
+
|
|
39
|
+
### Phase 1: Pre-flight — Idempotency Check
|
|
40
|
+
|
|
41
|
+
**Check for `--dry-run` argument first.** If the user invoked `/uni-init --dry-run`, set dry-run mode. In dry-run mode, no files will be created or modified — only terminal output.
|
|
42
|
+
|
|
43
|
+
1. Check if `CLAUDE.md` exists in the repository root.
|
|
44
|
+
|
|
45
|
+
2. **If CLAUDE.md exists**, read the entire file and search for this exact sentinel string:
|
|
46
|
+
```
|
|
47
|
+
<!-- uni-init v1: DO NOT REMOVE THIS LINE -->
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
3. **Head-check fallback for large files**: If `CLAUDE.md` has more than 200 lines, also explicitly read the last 30 lines of the file and check for the sentinel there. This catches cases where the sentinel is at the end of a large file.
|
|
51
|
+
|
|
52
|
+
4. **If the sentinel is found** (in either check): Print the following and stop immediately. Do not proceed to Phase 2 or Phase 3.
|
|
53
|
+
```
|
|
54
|
+
Already initialized. Unimatrix block found in CLAUDE.md.
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
5. **If CLAUDE.md does not exist**: Note this — CLAUDE.md will be created in Phase 3. Continue to Phase 2.
|
|
58
|
+
|
|
59
|
+
6. **If CLAUDE.md exists but sentinel is not found**: Continue to Phase 2.
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
### Phase 2: Agent Scan (Read-Only)
|
|
64
|
+
|
|
65
|
+
This phase produces a terminal-only recommendation report. **Do not write any files. Do not modify any agent files.**
|
|
66
|
+
|
|
67
|
+
1. Glob for agent definition files: `.claude/agents/**/*.md`
|
|
68
|
+
|
|
69
|
+
2. **If no agent files are found**: Print the following and continue to Phase 3.
|
|
70
|
+
```
|
|
71
|
+
No agent files found at .claude/agents/. Skipping agent scan.
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
3. **For each agent file found**, read its content and check for the presence of these three patterns:
|
|
75
|
+
|
|
76
|
+
- **context_briefing**: Does the file contain `context_briefing`? (This indicates the agent calls the Unimatrix briefing tool at session start.)
|
|
77
|
+
- **Outcome reporting**: Does the file contain `/uni-record-outcome` or reference `context_store` with `category: "outcome"`? (This indicates the agent records session outcomes.)
|
|
78
|
+
- **uni-\* skill reference**: Does the file contain any reference to `uni-` prefixed skills (e.g., `/uni-init`, `/uni-seed`)?
|
|
79
|
+
|
|
80
|
+
4. **Print the Agent Orientation Report** to the terminal:
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
Agent Orientation Report
|
|
84
|
+
========================
|
|
85
|
+
Agent | Missing | Suggested Addition
|
|
86
|
+
-------------------------------|----------------------------------|------------------------------------------
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
For each agent file, print a row:
|
|
90
|
+
- **Agent**: the filename (without path prefix)
|
|
91
|
+
- **Missing**: which of the three patterns are absent
|
|
92
|
+
- **Suggested Addition**: concrete, skill-level recommendation. Examples:
|
|
93
|
+
- Missing context_briefing: "Add orientation section: call context_briefing at session start for relevant knowledge"
|
|
94
|
+
- Missing outcome reporting: "Add session end: invoke /uni-record-outcome to capture what was learned"
|
|
95
|
+
- Missing uni-* skills: "Reference /uni-init and /uni-seed for onboarding new repos"
|
|
96
|
+
- All present: "fully wired" / "none"
|
|
97
|
+
|
|
98
|
+
5. **If all agents have all three patterns**: Print after the table:
|
|
99
|
+
```
|
|
100
|
+
All agents fully wired.
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
### Phase 3: CLAUDE.md Append
|
|
106
|
+
|
|
107
|
+
**If in dry-run mode**: Print the following, then print the full Unimatrix block content below, and stop. Do not create or modify any files.
|
|
108
|
+
```
|
|
109
|
+
DRY RUN -- the following block would be appended to CLAUDE.md:
|
|
110
|
+
```
|
|
111
|
+
Print the block, then:
|
|
112
|
+
```
|
|
113
|
+
No files were modified.
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
**If NOT in dry-run mode**:
|
|
117
|
+
|
|
118
|
+
The exact block to append is:
|
|
119
|
+
|
|
120
|
+
```markdown
|
|
121
|
+
|
|
122
|
+
<!-- uni-init v1: DO NOT REMOVE THIS LINE -->
|
|
123
|
+
## Unimatrix
|
|
124
|
+
|
|
125
|
+
Knowledge engine (MCP server). Makes agent expertise searchable, trustworthy, and self-improving.
|
|
126
|
+
|
|
127
|
+
### Available Skills
|
|
128
|
+
|
|
129
|
+
| Skill | When to Use |
|
|
130
|
+
|-------|-------------|
|
|
131
|
+
| `/uni-init` | First-time setup: wire CLAUDE.md and get agent recommendations |
|
|
132
|
+
| `/uni-seed` | Populate Unimatrix with foundational repo knowledge |
|
|
133
|
+
|
|
134
|
+
### Knowledge Categories
|
|
135
|
+
|
|
136
|
+
| Category | What Goes Here |
|
|
137
|
+
|----------|---------------|
|
|
138
|
+
| `decision` | Architectural decisions (ADRs) — use `/uni-store-adr` |
|
|
139
|
+
| `pattern` | Reusable implementation patterns — use `/uni-store-pattern` |
|
|
140
|
+
| `procedure` | Step-by-step workflows — use `/uni-store-procedure` |
|
|
141
|
+
| `convention` | Project-wide coding/process standards |
|
|
142
|
+
| `lesson-learned` | Post-failure takeaways — use `/uni-store-lesson` |
|
|
143
|
+
|
|
144
|
+
### When to Invoke
|
|
145
|
+
|
|
146
|
+
- Before implementing anything new → search knowledge base
|
|
147
|
+
- After each architectural decision → store ADR
|
|
148
|
+
- After each shipped feature → run retrospective
|
|
149
|
+
- When a technique evolves → update procedure
|
|
150
|
+
<!-- end uni-init v1 -->
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
**If CLAUDE.md exists**: Append the block to the end of the existing file. Use Edit/append semantics — do NOT overwrite the file. Preserve all existing content. Add a blank line before the block if the file does not already end with a blank line.
|
|
154
|
+
|
|
155
|
+
**If CLAUDE.md does not exist**: Create CLAUDE.md with the block as its only content (without the leading blank line).
|
|
156
|
+
|
|
157
|
+
After writing, confirm:
|
|
158
|
+
```
|
|
159
|
+
Unimatrix block appended to CLAUDE.md.
|
|
160
|
+
```
|
|
161
|
+
Or if created:
|
|
162
|
+
```
|
|
163
|
+
Created CLAUDE.md with Unimatrix block.
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Finally, print:
|
|
167
|
+
```
|
|
168
|
+
Initialization complete. Run /uni-seed next to populate the knowledge base.
|
|
169
|
+
```
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: "uni-knowledge-lookup"
|
|
3
|
+
description: "Deterministic lookup of Unimatrix knowledge by exact filters. Use when you know what you want — a specific feature, category, entry ID, or status."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Knowledge Lookup — Deterministic Query Against Unimatrix
|
|
7
|
+
|
|
8
|
+
## What This Skill Does
|
|
9
|
+
|
|
10
|
+
Retrieves Unimatrix entries by exact filters — topic, category, tags, status, or entry ID. Returns all matching entries without semantic ranking. Use when you know precisely what you're looking for.
|
|
11
|
+
|
|
12
|
+
**Use this when you KNOW what you want** — a specific feature's ADRs, entries with a particular status, or a known entry by ID.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## How to Look Up
|
|
17
|
+
|
|
18
|
+
Call the `mcp__unimatrix__context_lookup` MCP tool:
|
|
19
|
+
|
|
20
|
+
| Parameter | Required | Description |
|
|
21
|
+
|-----------|----------|-------------|
|
|
22
|
+
| `topic` | No* | Exact feature ID match (e.g., `"nxs-001"`) |
|
|
23
|
+
| `category` | No* | Exact category match (e.g., `"decision"`) |
|
|
24
|
+
| `tags` | No* | All specified tags must match |
|
|
25
|
+
| `status` | No | `"active"` (default), `"deprecated"`, `"proposed"` |
|
|
26
|
+
| `id` | No* | Specific entry ID (returns exactly one entry) |
|
|
27
|
+
| `limit` | No | Max results (default: 10) |
|
|
28
|
+
| `format` | No | `"summary"` (default), `"markdown"` (full content), `"json"` |
|
|
29
|
+
| `agent_id` | No | Your role name (e.g. `uni-architect`) |
|
|
30
|
+
|
|
31
|
+
*At least one filter parameter is required (topic, category, tags, or id).
|
|
32
|
+
|
|
33
|
+
### Examples
|
|
34
|
+
|
|
35
|
+
**Get all ADRs for a specific feature:**
|
|
36
|
+
```
|
|
37
|
+
mcp__unimatrix__context_lookup(topic: "nxs-002", category: "decision")
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**Get a specific entry by ID (full content):**
|
|
41
|
+
```
|
|
42
|
+
mcp__unimatrix__context_lookup(id: 42, format: "markdown")
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**Find all deprecated decisions:**
|
|
46
|
+
```
|
|
47
|
+
mcp__unimatrix__context_lookup(category: "decision", status: "deprecated")
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Find entries tagged with a specific domain:**
|
|
51
|
+
```
|
|
52
|
+
mcp__unimatrix__context_lookup(category: "decision", tags: ["adr", "serialization"])
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
**Get all knowledge for a feature (any category):**
|
|
56
|
+
```
|
|
57
|
+
mcp__unimatrix__context_lookup(topic: "vnc-001")
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Single Entry Retrieval
|
|
63
|
+
|
|
64
|
+
If you already have an entry ID (from a prior search or lookup result), use `context_get` for direct retrieval:
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
mcp__unimatrix__context_get(id: 42, format: "markdown")
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
This is faster than a lookup with an ID filter and always returns full content.
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## When to Use This vs /uni-knowledge-search
|
|
75
|
+
|
|
76
|
+
| Use `/uni-knowledge-lookup` when | Use `/uni-knowledge-search` when |
|
|
77
|
+
|------------------------------|------------------------------|
|
|
78
|
+
| You know the exact feature/category | Exploring a concept |
|
|
79
|
+
| "Give me all ADRs for nxs-002" | "What do we know about X?" |
|
|
80
|
+
| Retrieving a specific entry by ID | Finding related decisions |
|
|
81
|
+
| Filtering by exact status or tags | Discovering unknown patterns |
|
|
82
|
+
| Checking what exists before storing | Broad exploration |
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## Common Workflows
|
|
87
|
+
|
|
88
|
+
**Before writing a new ADR (architect):**
|
|
89
|
+
```
|
|
90
|
+
1. mcp__unimatrix__context_lookup(topic: "{feature-id}", category: "decision")
|
|
91
|
+
→ See what ADRs already exist for this feature
|
|
92
|
+
2. mcp__unimatrix__context_lookup(category: "decision", tags: ["adr", "{domain}"])
|
|
93
|
+
→ See ADRs across features in the same domain
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**Before implementing a component (developer):**
|
|
97
|
+
```
|
|
98
|
+
1. mcp__unimatrix__context_lookup(topic: "{feature-id}", category: "decision", format: "markdown")
|
|
99
|
+
→ Read all architectural decisions for this feature
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**Checking for deprecated knowledge:**
|
|
103
|
+
```
|
|
104
|
+
mcp__unimatrix__context_lookup(category: "decision", status: "deprecated", topic: "{feature-id}")
|
|
105
|
+
→ See what decisions have been superseded
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## When You Find Stale or Wrong Knowledge
|
|
111
|
+
|
|
112
|
+
Lookup may surface entries that are outdated or incorrect. Fix them:
|
|
113
|
+
|
|
114
|
+
| Situation | Action |
|
|
115
|
+
|-----------|--------|
|
|
116
|
+
| Entry is **wrong** | `mcp__unimatrix__context_correct(original_id: {id}, content: "{corrected version}", reason: "{why}")` — supersedes with chain link |
|
|
117
|
+
| Entry is **outdated** | `mcp__unimatrix__context_deprecate(id: {id}, reason: "{why}")` |
|
|
118
|
+
| Entry is **suspicious** | `mcp__unimatrix__context_quarantine(id: {id}, reason: "{concern}")` — Admin only |
|
|
119
|
+
|
|
120
|
+
Every agent shares responsibility for knowledge quality. Don't leave wrong entries for the next agent to trip over.
|