xtrm-tools 2.1.13 → 2.1.14
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/cli/dist/index.cjs +8 -0
- package/cli/dist/index.cjs.map +1 -1
- package/cli/package.json +1 -1
- package/config/mcp_servers.json +11 -0
- package/hooks/main-guard.mjs +20 -0
- package/package.json +1 -1
- package/skills/using-xtrm/SKILL.md +271 -0
package/cli/package.json
CHANGED
package/config/mcp_servers.json
CHANGED
|
@@ -41,6 +41,17 @@
|
|
|
41
41
|
"deepwiki": {
|
|
42
42
|
"type": "http",
|
|
43
43
|
"url": "https://mcp.deepwiki.com/mcp"
|
|
44
|
+
},
|
|
45
|
+
"gitnexus": {
|
|
46
|
+
"type": "stdio",
|
|
47
|
+
"command": "npx",
|
|
48
|
+
"args": ["-y", "gitnexus", "mcp"],
|
|
49
|
+
"env": {},
|
|
50
|
+
"_notes": {
|
|
51
|
+
"description": "Code intelligence MCP - provides graph queries for impact analysis, execution flows, symbol context",
|
|
52
|
+
"prerequisite": "Run 'gitnexus analyze' in the project first to build the index",
|
|
53
|
+
"auto_index": "xtrm project init runs gitnexus analyze automatically"
|
|
54
|
+
}
|
|
44
55
|
}
|
|
45
56
|
}
|
|
46
57
|
}
|
package/hooks/main-guard.mjs
CHANGED
|
@@ -86,6 +86,26 @@ if (tool === 'Bash') {
|
|
|
86
86
|
process.exit(0);
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
+
// Enforce squash-only PR merges for linear history
|
|
90
|
+
// Must check BEFORE the gh allowlist pattern
|
|
91
|
+
if (/^gh\s+pr\s+merge\b/.test(cmd)) {
|
|
92
|
+
if (!/--squash\b/.test(cmd)) {
|
|
93
|
+
deny(
|
|
94
|
+
`\u26D4 Only squash merges are allowed — use 'gh pr merge --squash'\n\n` +
|
|
95
|
+
'Why squash?\n' +
|
|
96
|
+
' - Keeps history linear and easy to read\n' +
|
|
97
|
+
' - One commit per PR = easy to revert\n' +
|
|
98
|
+
' - Matches the workflow documented in AGENTS.md\n\n' +
|
|
99
|
+
'Correct usage:\n' +
|
|
100
|
+
' gh pr merge --squash\n\n' +
|
|
101
|
+
'If you really need a merge commit, use:\n' +
|
|
102
|
+
' MAIN_GUARD_ALLOW_BASH=1 gh pr merge --merge\n'
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
// --squash present — allow
|
|
106
|
+
process.exit(0);
|
|
107
|
+
}
|
|
108
|
+
|
|
89
109
|
// Safe allowlist — non-mutating commands + explicit branch-exit paths.
|
|
90
110
|
// Important: do not allow generic checkout/switch forms, which include
|
|
91
111
|
// mutating variants such as `git checkout -- <path>`.
|
package/package.json
CHANGED
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: using-xtrm
|
|
3
|
+
description: >
|
|
4
|
+
Operating manual for an xtrm-equipped Claude Code session. Activates automatically at
|
|
5
|
+
session start to orient the agent on how to work within the xtrm stack: when to apply
|
|
6
|
+
prompt improvement, how the beads issue-tracking gate works, which hooks enforce workflows,
|
|
7
|
+
and how to compose the full toolset (gitnexus, Serena, TDD guard, quality gates, delegation).
|
|
8
|
+
Use this skill whenever a new session begins in an xtrm-tools-installed environment, or
|
|
9
|
+
when the user asks how to work with the xtrm stack, what tools are available, or how any
|
|
10
|
+
xtrm workflow operates.
|
|
11
|
+
priority: high
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# Using xtrm — Session Operating Manual
|
|
15
|
+
|
|
16
|
+
You are in an **xtrm-equipped Claude Code environment**. This skill orients you on *how to work*
|
|
17
|
+
within this stack. Read it at session start and refer back when uncertain about a workflow.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Stack at a Glance
|
|
22
|
+
|
|
23
|
+
| Layer | What it provides |
|
|
24
|
+
|---|---|
|
|
25
|
+
| **Skills** | Domain expertise loaded on demand |
|
|
26
|
+
| **Hooks** | Automated lifecycle enforcement (gates, suggestions, reminders) |
|
|
27
|
+
| **Project Skills** | Per-project quality enforcement (tdd-guard, quality-gates, service-skills-set) |
|
|
28
|
+
| **MCP Servers** | Semantic tools: Serena (code), gitnexus (graph), context7 (docs), deepwiki |
|
|
29
|
+
| **CLI** | `xtrm install / status / reset / help` — sync and install tooling |
|
|
30
|
+
| **beads (bd)** | Git-backed issue tracker with session gate enforcement |
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Core Principle: Prompt First, Then Work
|
|
35
|
+
|
|
36
|
+
Before executing any non-trivial task, improve the prompt mentally using XML structure.
|
|
37
|
+
Apply this silently — the user sees your improved execution, not the meta-work.
|
|
38
|
+
|
|
39
|
+
### Prompt Classification
|
|
40
|
+
|
|
41
|
+
Scan the user's message for task type:
|
|
42
|
+
|
|
43
|
+
| Type | Keywords | Enhancement |
|
|
44
|
+
|---|---|---|
|
|
45
|
+
| **ANALYSIS** | analyze, investigate, research, explain, why | Add `<thinking>` block, structure `<outputs>` |
|
|
46
|
+
| **DEV** | implement, create, build, add, fix, feature | Add 1-2 `<example>` blocks, define `<constraints>` |
|
|
47
|
+
| **REFACTOR** | refactor, improve, optimize, clean, simplify | Add `<constraints>` (preserve behavior, tests pass) + `<current_state>` |
|
|
48
|
+
|
|
49
|
+
### XML Prompt Structure
|
|
50
|
+
|
|
51
|
+
```xml
|
|
52
|
+
<task_name>
|
|
53
|
+
<description>What needs to be done and why</description>
|
|
54
|
+
<parameters>Relevant context: files, symbols, constraints</parameters>
|
|
55
|
+
<instructions>
|
|
56
|
+
Step-by-step approach
|
|
57
|
+
</instructions>
|
|
58
|
+
<!-- ANALYSIS tasks: -->
|
|
59
|
+
<thinking>Work through hypotheses before concluding</thinking>
|
|
60
|
+
<outputs>Expected result format</outputs>
|
|
61
|
+
<!-- DEV tasks: -->
|
|
62
|
+
<example>Concrete pattern to follow</example>
|
|
63
|
+
<!-- REFACTOR tasks: -->
|
|
64
|
+
<constraints>Must not break X, tests must pass, preserve API surface</constraints>
|
|
65
|
+
</task_name>
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
When a prompt is vague (under 8 words, no specifics), ask one clarifying question before
|
|
69
|
+
proceeding. Don't ask about things you can reasonably infer.
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Beads Gate — Session Protocol
|
|
74
|
+
|
|
75
|
+
This environment enforces a **beads session gate**. You cannot edit files or stop the session
|
|
76
|
+
without an active issue claim. Follow this protocol exactly:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
# 1. Find or create an issue before any edit
|
|
80
|
+
bd list --status=open # see what exists
|
|
81
|
+
bd create --title="..." --type=task --priority=2
|
|
82
|
+
bd update <id> --status=in_progress
|
|
83
|
+
bd kv set "claimed:<session_id>" "<id>"
|
|
84
|
+
|
|
85
|
+
# 2. Work freely (hooks allow edits when claim is set)
|
|
86
|
+
|
|
87
|
+
# 3. Close when done — hook auto-clears claim
|
|
88
|
+
bd close <id>
|
|
89
|
+
|
|
90
|
+
# 4. Session close protocol
|
|
91
|
+
git add <files> && git commit -m "..."
|
|
92
|
+
git push -u origin <feature-branch>
|
|
93
|
+
gh pr create --fill
|
|
94
|
+
gh pr merge --squash
|
|
95
|
+
git checkout main && git reset --hard origin/main
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**Key rules:**
|
|
99
|
+
- One active claim per session
|
|
100
|
+
- Always work on a **feature branch**, never directly on `main`/`master`
|
|
101
|
+
- `main-guard.mjs` blocks all file edits on protected branches
|
|
102
|
+
- `beads-stop-gate.mjs` blocks session end until the claim is closed
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Code Editing — Serena LSP Workflow
|
|
107
|
+
|
|
108
|
+
Always use semantic tools. Never read entire large files or use generic Edit unless forced.
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
get_symbols_overview(file) → map the file structure first
|
|
112
|
+
find_symbol(name, include_body=true) → read only what you need
|
|
113
|
+
find_referencing_symbols(name) → check callers before changing signatures
|
|
114
|
+
replace_symbol_body(name, body) → atomic symbol-level edit
|
|
115
|
+
insert_after_symbol / insert_before_symbol → add new code precisely
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
**Activate project first** (required once per session):
|
|
119
|
+
```
|
|
120
|
+
mcp__serena__activate_project("<project-name>")
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**Fallback**: Use `Edit` only for non-code files or when a symbol can't be located.
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## Code Intelligence — gitnexus Workflow
|
|
128
|
+
|
|
129
|
+
Before editing any function, class, or method — always run impact analysis.
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
# 1. Before editing
|
|
133
|
+
npx gitnexus impact <symbolName> --direction upstream
|
|
134
|
+
|
|
135
|
+
# 2. Understand a symbol fully
|
|
136
|
+
gitnexus_context({name: "symbolName"})
|
|
137
|
+
|
|
138
|
+
# 3. Find code by concept (instead of grepping)
|
|
139
|
+
gitnexus_query({query: "concept"})
|
|
140
|
+
|
|
141
|
+
# 4. Before committing — verify scope
|
|
142
|
+
gitnexus_detect_changes({scope: "staged"})
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
**Risk levels**: d=1 = WILL BREAK (must fix), d=2 = likely affected (should test), d=3 = transitive (test if critical).
|
|
146
|
+
|
|
147
|
+
If index is stale: `npx gitnexus analyze` before using MCP tools.
|
|
148
|
+
|
|
149
|
+
> **Note**: gitnexus MCP server and CLI share an exclusive DB lock — they cannot run concurrently.
|
|
150
|
+
> Use CLI (`npx gitnexus ...`) when MCP is active, or stop MCP first.
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## TDD Guard — Test-First Enforcement
|
|
155
|
+
|
|
156
|
+
This project enforces TDD via `tdd-guard`. It **blocks implementation** until a failing test exists.
|
|
157
|
+
|
|
158
|
+
**The cycle:**
|
|
159
|
+
1. Write a failing test first — use `sed` or `Bash` to append (not `Write`/`Edit`, which the guard intercepts)
|
|
160
|
+
2. Run `npx vitest run <test-file>` to register the failure in `.claude/tdd-guard/data/test.json`
|
|
161
|
+
3. Implement the minimum code to make it pass
|
|
162
|
+
4. Run tests again — guard clears when tests pass
|
|
163
|
+
|
|
164
|
+
Never skip the failing test step. Over-implementation is also flagged — write a stub first, then build up.
|
|
165
|
+
|
|
166
|
+
> **Needs configuration**: tdd-guard is a project skill installed per-project:
|
|
167
|
+
> ```bash
|
|
168
|
+
> xtrm install project tdd-guard
|
|
169
|
+
> ```
|
|
170
|
+
> Requires vitest in the project. After install, verify `.claude/settings.json` includes the
|
|
171
|
+
> PreToolUse and UserPromptSubmit hook entries for tdd-guard.
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
## Quality Gates — Automatic on Every Edit
|
|
176
|
+
|
|
177
|
+
After each file edit, quality-gates hooks run automatically:
|
|
178
|
+
- **TypeScript**: ESLint + tsc type check
|
|
179
|
+
- **Python**: Ruff lint + mypy type check
|
|
180
|
+
|
|
181
|
+
You do not invoke these manually — they fire via PostToolUse hooks. If a gate fails, fix the
|
|
182
|
+
lint/type error before continuing. Do not suppress errors with `// eslint-disable` or `# type: ignore`
|
|
183
|
+
unless there is a genuine reason.
|
|
184
|
+
|
|
185
|
+
> **Needs configuration**: quality-gates is a project skill installed per-project:
|
|
186
|
+
> ```bash
|
|
187
|
+
> xtrm install project quality-gates
|
|
188
|
+
> ```
|
|
189
|
+
> After install, verify `.claude/settings.json` includes PostToolUse hooks, and that the project
|
|
190
|
+
> has `eslint.config.*` (TS) or `pyproject.toml` / `ruff.toml` (Python) configured.
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
## Skill Routing — When to Use What
|
|
195
|
+
|
|
196
|
+
| Situation | Use |
|
|
197
|
+
|---|---|
|
|
198
|
+
| Short/vague user prompt | Apply XML structure silently (this skill) or `/prompt-improving` |
|
|
199
|
+
| Simple task (tests, docs, typo fix) | `/delegating` → cost-optimized agent |
|
|
200
|
+
| Complex task needing second opinion | `/orchestrate adversarial "task"` |
|
|
201
|
+
| Reading/editing code | `using-serena-lsp` (Serena MCP) |
|
|
202
|
+
| Understanding code architecture | `gitnexus-exploring` |
|
|
203
|
+
| Tracing a bug | `gitnexus-debugging` |
|
|
204
|
+
| Changing a function | `gitnexus-impact-analysis` first, then Serena edit |
|
|
205
|
+
| Safe rename/refactor | `gitnexus-refactoring` |
|
|
206
|
+
| Docker service project | `using-service-skills` → activate expert persona |
|
|
207
|
+
| Writing new feature | TDD cycle first, quality gates auto-run after |
|
|
208
|
+
| Maintaining docs | `/documenting` (Serena SSOT drift detection) |
|
|
209
|
+
| Building/improving a skill | `skill-creator` |
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## Available Skills (Full Catalog)
|
|
214
|
+
|
|
215
|
+
**Workflow:**
|
|
216
|
+
`prompt-improving`, `delegating`, `orchestrating-agents`, `using-serena-lsp`, `documenting`,
|
|
217
|
+
`using-xtrm` (this skill), `skill-creator`, `find-skills`
|
|
218
|
+
|
|
219
|
+
**Code Intelligence:**
|
|
220
|
+
`gitnexus-exploring`, `gitnexus-debugging`, `gitnexus-impact-analysis`, `gitnexus-refactoring`
|
|
221
|
+
|
|
222
|
+
**Domain Experts:**
|
|
223
|
+
`senior-backend`, `senior-devops`, `senior-security`, `senior-data-scientist`,
|
|
224
|
+
`docker-expert`, `python-testing`, `clean-code`
|
|
225
|
+
|
|
226
|
+
**Integrations:**
|
|
227
|
+
`obsidian-cli`, `hook-development`, `claude-api`
|
|
228
|
+
|
|
229
|
+
**Project Skills** (install per-project with `xtrm install project <name>`):
|
|
230
|
+
`tdd-guard`, `quality-gates`, `service-skills-set`
|
|
231
|
+
|
|
232
|
+
---
|
|
233
|
+
|
|
234
|
+
## Hook Enforcement Summary
|
|
235
|
+
|
|
236
|
+
These hooks run automatically — you cannot disable them mid-session:
|
|
237
|
+
|
|
238
|
+
| Hook | Trigger | Effect |
|
|
239
|
+
|---|---|---|
|
|
240
|
+
| `main-guard.mjs` | PreToolUse (Edit/Write/Serena) | Blocks edits on `main`/`master` |
|
|
241
|
+
| `beads-edit-gate.mjs` | PreToolUse (Edit/Write/Serena) | Blocks edits without active claim |
|
|
242
|
+
| `beads-commit-gate.mjs` | PreToolUse (Bash: git commit) | Blocks commit with unclosed claim |
|
|
243
|
+
| `beads-stop-gate.mjs` | Stop | Blocks session end with open claim |
|
|
244
|
+
| `gitnexus-impact-reminder.py` | UserPromptSubmit (edit-intent keywords) | Injects impact analysis reminder |
|
|
245
|
+
| `serena-workflow-reminder.py` | SessionStart + PreToolUse (Edit) | Enforces Serena LSP over raw Edit |
|
|
246
|
+
| `skill-suggestion.py` | UserPromptSubmit | Suggests relevant skill if detected |
|
|
247
|
+
| `tdd-guard` hooks | PreToolUse (Edit/Write) | Blocks implementation without failing test |
|
|
248
|
+
| `quality-gates` hooks | PostToolUse (Edit/Write) | Runs lint + type checks automatically |
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
## MCP Servers
|
|
253
|
+
|
|
254
|
+
| Server | Use for | Setup |
|
|
255
|
+
|---|---|---|
|
|
256
|
+
| `serena` | Semantic code reading/editing | Auto-detected; activate project per session |
|
|
257
|
+
| `gitnexus` | Knowledge graph, impact analysis | `npm install -g gitnexus` + `npx gitnexus analyze` per project |
|
|
258
|
+
| `context7` | Library documentation lookup | Requires `CONTEXT7_API_KEY` in `~/.config/xtrm-tools/.env` |
|
|
259
|
+
| `deepwiki` | Technical docs for GitHub repos | No setup needed |
|
|
260
|
+
| `github-grep` | Code search across GitHub | No setup needed |
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
## Checklist Before Finishing Any Task
|
|
265
|
+
|
|
266
|
+
1. `gitnexus_detect_changes({scope: "staged"})` — confirms only expected files changed
|
|
267
|
+
2. All d=1 dependents updated (if any signal from impact analysis)
|
|
268
|
+
3. Tests pass: `npx vitest run`
|
|
269
|
+
4. Beads issue closed: `bd close <id>`
|
|
270
|
+
5. Feature branch pushed, PR created and merged
|
|
271
|
+
6. Back on `main`: `git checkout main && git reset --hard origin/main`
|