xtrm-tools 2.1.6 → 2.1.7
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 +31 -8
- package/cli/dist/index.cjs.map +1 -1
- package/cli/package.json +4 -1
- package/config/hooks.json +5 -0
- package/hooks/README.md +19 -0
- package/hooks/beads-stop-gate.mjs +1 -0
- package/hooks/main-guard-post-push.mjs +71 -0
- package/package.json +11 -4
- package/project-skills/{py-quality-gate → quality-gates}/.claude/settings.json +10 -0
- package/project-skills/quality-gates/.claude/skills/using-quality-gates/SKILL.md +254 -0
- package/project-skills/quality-gates/README.md +109 -0
- package/project-skills/quality-gates/evals/evals.json +181 -0
- package/project-skills/quality-gates/workspace/iteration-1/FINAL-EVAL-SUMMARY.md +75 -0
- package/project-skills/quality-gates/workspace/iteration-1/edge-case-auto-fix-verification/with_skill/outputs/response.md +59 -0
- package/project-skills/quality-gates/workspace/iteration-1/edge-case-mixed-language-project/with_skill/outputs/response.md +60 -0
- package/project-skills/quality-gates/workspace/iteration-1/eval-summary.md +105 -0
- package/project-skills/quality-gates/workspace/iteration-1/partial-install-python-only/with_skill/outputs/response.md +93 -0
- package/project-skills/quality-gates/workspace/iteration-1/python-refactor-request/with_skill/outputs/response.md +104 -0
- package/project-skills/quality-gates/workspace/iteration-1/quality-gate-error-fix/with_skill/outputs/response.md +74 -0
- package/project-skills/quality-gates/workspace/iteration-1/should-not-trigger-general-chat/with_skill/outputs/response.md +18 -0
- package/project-skills/quality-gates/workspace/iteration-1/should-not-trigger-math-question/with_skill/outputs/response.md +18 -0
- package/project-skills/quality-gates/workspace/iteration-1/should-not-trigger-unrelated-coding/with_skill/outputs/response.md +56 -0
- package/project-skills/quality-gates/workspace/iteration-1/tdd-guard-blocking-confusion/with_skill/outputs/response.md +67 -0
- package/project-skills/quality-gates/workspace/iteration-1/typescript-feature-with-tests/with_skill/outputs/response.md +97 -0
- package/project-skills/tdd-guard/.claude/hooks/tdd-guard-pretool-bridge.cjs +0 -1
- package/hooks/__pycache__/agent_context.cpython-314.pyc +0 -0
- package/project-skills/py-quality-gate/.claude/skills/using-py-quality-gate/SKILL.md +0 -112
- package/project-skills/py-quality-gate/README.md +0 -147
- package/project-skills/service-skills-set/.claude/git-hooks/__pycache__/doc_reminder.cpython-314.pyc +0 -0
- package/project-skills/service-skills-set/.claude/git-hooks/__pycache__/skill_staleness.cpython-314.pyc +0 -0
- package/project-skills/service-skills-set/.claude/skills/creating-service-skills/scripts/__pycache__/bootstrap.cpython-314.pyc +0 -0
- package/project-skills/service-skills-set/.claude/skills/updating-service-skills/scripts/__pycache__/drift_detector.cpython-314.pyc +0 -0
- package/project-skills/service-skills-set/.claude/skills/using-service-skills/scripts/__pycache__/cataloger.cpython-314.pyc +0 -0
- package/project-skills/service-skills-set/.claude/skills/using-service-skills/scripts/__pycache__/skill_activator.cpython-314.pyc +0 -0
- package/project-skills/service-skills-set/.claude/skills/using-service-skills/scripts/__pycache__/test_skill_activator.cpython-314-pytest-9.0.2.pyc +0 -0
- package/project-skills/service-skills-set/.claude/skills/using-service-skills/scripts/test_skill_activator.py +0 -58
- package/project-skills/service-skills-set/__pycache__/install-service-skills.cpython-314.pyc +0 -0
- package/project-skills/ts-quality-gate/.claude/settings.json +0 -16
- package/project-skills/ts-quality-gate/.claude/skills/using-ts-quality-gate/SKILL.md +0 -81
- package/project-skills/ts-quality-gate/README.md +0 -115
- package/skills/documenting/scripts/__pycache__/drift_detector.cpython-314.pyc +0 -0
- package/skills/documenting/scripts/__pycache__/orchestrator.cpython-314.pyc +0 -0
- package/skills/documenting/scripts/__pycache__/validate_metadata.cpython-314.pyc +0 -0
- package/skills/documenting/scripts/changelog/__pycache__/__init__.cpython-314.pyc +0 -0
- package/skills/documenting/scripts/changelog/__pycache__/add_entry.cpython-314.pyc +0 -0
- package/skills/documenting/scripts/changelog/__pycache__/bump_release.cpython-314.pyc +0 -0
- package/skills/documenting/scripts/changelog/__pycache__/validate_changelog.cpython-314.pyc +0 -0
- package/skills/documenting/tests/__pycache__/test_changelog.cpython-314-pytest-9.0.2.pyc +0 -0
- package/skills/documenting/tests/__pycache__/test_drift_detector.cpython-314-pytest-9.0.2.pyc +0 -0
- package/skills/documenting/tests/__pycache__/test_orchestrator.cpython-314-pytest-9.0.2.pyc +0 -0
- package/skills/documenting/tests/__pycache__/test_validate_metadata.cpython-314-pytest-9.0.2.pyc +0 -0
- package/skills/documenting/tests/integration_test.sh +0 -70
- package/skills/documenting/tests/test_changelog.py +0 -201
- package/skills/documenting/tests/test_drift_detector.py +0 -80
- package/skills/documenting/tests/test_orchestrator.py +0 -52
- package/skills/documenting/tests/test_validate_metadata.py +0 -64
- /package/project-skills/{ts-quality-gate → quality-gates}/.claude/hooks/hook-config.json +0 -0
- /package/project-skills/{ts-quality-gate → quality-gates}/.claude/hooks/quality-check.cjs +0 -0
- /package/project-skills/{py-quality-gate → quality-gates}/.claude/hooks/quality-check.py +0 -0
package/cli/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xtrm-cli",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.7",
|
|
4
4
|
"description": "Claude Code tools installer (skills, hooks, MCP servers)",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -39,5 +39,8 @@
|
|
|
39
39
|
"tsx": "^4.21.0",
|
|
40
40
|
"typescript": "^5.9.3",
|
|
41
41
|
"vitest": "^4.0.18"
|
|
42
|
+
},
|
|
43
|
+
"engines": {
|
|
44
|
+
"node": ">=20.0.0"
|
|
42
45
|
}
|
|
43
46
|
}
|
package/config/hooks.json
CHANGED
package/hooks/README.md
CHANGED
|
@@ -168,6 +168,25 @@ Installed globally to `~/.claude/hooks/` by `xtrm install`. Require Node.js.
|
|
|
168
168
|
|
|
169
169
|
---
|
|
170
170
|
|
|
171
|
+
### main-guard-post-push.mjs
|
|
172
|
+
|
|
173
|
+
**Purpose**: After a successful `git push` from a non-protected branch, injects a reminder for the next PR workflow steps.
|
|
174
|
+
|
|
175
|
+
**Trigger**: PostToolUse (`Bash`) — only fires when command matches `git push` and appears successful.
|
|
176
|
+
|
|
177
|
+
**Behavior**:
|
|
178
|
+
- No blocking (informational only)
|
|
179
|
+
- Skips protected branches (`main`/`master`)
|
|
180
|
+
- Skips explicit pushes targeting protected branches
|
|
181
|
+
|
|
182
|
+
**Guidance injected**:
|
|
183
|
+
- `gh pr create --fill`
|
|
184
|
+
- `gh pr merge --squash`
|
|
185
|
+
- `git checkout main && git pull --ff-only`
|
|
186
|
+
- Reminder to keep beads issue state updated
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
171
190
|
### beads-gate-utils.mjs
|
|
172
191
|
|
|
173
192
|
**Purpose**: Shared utility module imported by all beads gate hooks. Not registered as a hook itself.
|
|
@@ -39,6 +39,7 @@ withSafeBdContext(() => {
|
|
|
39
39
|
if (!claimed) process.exit(0); // no active claim for this session
|
|
40
40
|
|
|
41
41
|
const ip = getInProgress(cwd);
|
|
42
|
+
if (ip === null || ip.count === 0) process.exit(0); // claim is stale — allow stop
|
|
42
43
|
const summary = ip?.summary ?? ` Claimed: ${claimed}`;
|
|
43
44
|
|
|
44
45
|
process.stderr.write(
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Claude Code PostToolUse hook — after successful feature-branch push,
|
|
3
|
+
// inject next-step PR workflow guidance.
|
|
4
|
+
// Exit 0 in all paths (informational only).
|
|
5
|
+
//
|
|
6
|
+
// Installed by: xtrm install
|
|
7
|
+
|
|
8
|
+
import { execSync } from 'node:child_process';
|
|
9
|
+
import { readFileSync } from 'node:fs';
|
|
10
|
+
|
|
11
|
+
let input;
|
|
12
|
+
try {
|
|
13
|
+
input = JSON.parse(readFileSync(0, 'utf8'));
|
|
14
|
+
} catch {
|
|
15
|
+
process.exit(0);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if ((input.tool_name ?? '') !== 'Bash') process.exit(0);
|
|
19
|
+
const cmd = (input.tool_input?.command ?? '').trim().replace(/\s+/g, ' ');
|
|
20
|
+
if (!/^git\s+push\b/.test(cmd)) process.exit(0);
|
|
21
|
+
|
|
22
|
+
function commandSucceeded(payload) {
|
|
23
|
+
const tr = payload?.tool_response ?? payload?.tool_result ?? payload?.result;
|
|
24
|
+
if (!tr || typeof tr !== 'object') return true;
|
|
25
|
+
|
|
26
|
+
if (tr.success === false) return false;
|
|
27
|
+
if (tr.error) return false;
|
|
28
|
+
|
|
29
|
+
const numeric = [tr.exit_code, tr.exitCode, tr.status, tr.returncode]
|
|
30
|
+
.find((v) => Number.isInteger(v));
|
|
31
|
+
if (typeof numeric === 'number' && numeric !== 0) return false;
|
|
32
|
+
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (!commandSucceeded(input)) process.exit(0);
|
|
37
|
+
|
|
38
|
+
const cwd = input.cwd || process.cwd();
|
|
39
|
+
let branch = '';
|
|
40
|
+
try {
|
|
41
|
+
branch = execSync('git branch --show-current', {
|
|
42
|
+
cwd,
|
|
43
|
+
encoding: 'utf8',
|
|
44
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
45
|
+
}).trim();
|
|
46
|
+
} catch {
|
|
47
|
+
process.exit(0);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const protectedBranches = process.env.MAIN_GUARD_PROTECTED_BRANCHES
|
|
51
|
+
? process.env.MAIN_GUARD_PROTECTED_BRANCHES.split(',').map((b) => b.trim()).filter(Boolean)
|
|
52
|
+
: ['main', 'master'];
|
|
53
|
+
|
|
54
|
+
if (!branch || protectedBranches.includes(branch)) process.exit(0);
|
|
55
|
+
|
|
56
|
+
const tokens = cmd.split(' ');
|
|
57
|
+
const lastToken = tokens[tokens.length - 1] ?? '';
|
|
58
|
+
const explicitlyProtectedTarget = protectedBranches
|
|
59
|
+
.some((b) => lastToken === b || lastToken.endsWith(`:${b}`));
|
|
60
|
+
if (explicitlyProtectedTarget) process.exit(0);
|
|
61
|
+
|
|
62
|
+
process.stdout.write(JSON.stringify({
|
|
63
|
+
systemMessage:
|
|
64
|
+
`✅ Pushed '${branch}'. Next workflow steps:\n\n` +
|
|
65
|
+
' 1. gh pr create --fill\n' +
|
|
66
|
+
' 2. gh pr merge --squash\n' +
|
|
67
|
+
' 3. git checkout main && git pull --ff-only\n\n' +
|
|
68
|
+
'Before/after merge, ensure beads state is updated (e.g. bd close <id>).',
|
|
69
|
+
}));
|
|
70
|
+
process.stdout.write('\n');
|
|
71
|
+
process.exit(0);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xtrm-tools",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.7",
|
|
4
4
|
"description": "Claude Code tools installer (skills, hooks, MCP servers)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -18,7 +18,11 @@
|
|
|
18
18
|
"config",
|
|
19
19
|
"hooks",
|
|
20
20
|
"skills",
|
|
21
|
-
"project-skills"
|
|
21
|
+
"project-skills",
|
|
22
|
+
"!**/__pycache__/**",
|
|
23
|
+
"!**/*.pyc",
|
|
24
|
+
"!project-skills/service-skills-set/.claude/skills/using-service-skills/scripts/test_*.py",
|
|
25
|
+
"!skills/documenting/tests/**"
|
|
22
26
|
],
|
|
23
27
|
"publishConfig": {
|
|
24
28
|
"access": "public"
|
|
@@ -32,15 +36,18 @@
|
|
|
32
36
|
"url": "https://github.com/Jaggerxtrm/xtrm-tools/issues"
|
|
33
37
|
},
|
|
34
38
|
"scripts": {
|
|
39
|
+
"sync:cli-version": "node scripts/sync-cli-version.mjs",
|
|
40
|
+
"prebuild": "npm run sync:cli-version",
|
|
35
41
|
"build": "npm run build --workspace cli",
|
|
36
42
|
"typecheck": "npm run typecheck --workspace cli",
|
|
37
43
|
"start": "node cli/dist/index.cjs",
|
|
38
44
|
"lint": "echo 'No linting configured'",
|
|
39
45
|
"test": "npm test --workspace cli",
|
|
40
|
-
"
|
|
46
|
+
"version": "npm run sync:cli-version && git add cli/package.json",
|
|
47
|
+
"prepublishOnly": "npm run sync:cli-version && npm run build"
|
|
41
48
|
},
|
|
42
49
|
"engines": {
|
|
43
|
-
"node": ">=
|
|
50
|
+
"node": ">=20.0.0"
|
|
44
51
|
},
|
|
45
52
|
"dependencies": {
|
|
46
53
|
"comment-json": "^4.2.3",
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"hooks": {
|
|
3
3
|
"PostToolUse": [
|
|
4
|
+
{
|
|
5
|
+
"matcher": "Write|Edit|MultiEdit|mcp__serena__rename_symbol|mcp__serena__replace_symbol_body|mcp__serena__insert_after_symbol|mcp__serena__insert_before_symbol",
|
|
6
|
+
"hooks": [
|
|
7
|
+
{
|
|
8
|
+
"type": "command",
|
|
9
|
+
"command": "node \"$CLAUDE_PROJECT_DIR/.claude/hooks/quality-check.cjs\"",
|
|
10
|
+
"timeout": 30
|
|
11
|
+
}
|
|
12
|
+
]
|
|
13
|
+
},
|
|
4
14
|
{
|
|
5
15
|
"matcher": "Write|Edit|MultiEdit|mcp__serena__rename_symbol|mcp__serena__replace_symbol_body|mcp__serena__insert_after_symbol|mcp__serena__insert_before_symbol",
|
|
6
16
|
"hooks": [
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: using-quality-gates
|
|
3
|
+
description: 'Quality Gates workflow for Claude Code. Use when editing code in projects with quality enforcement. Covers the full cycle: TDD guard (write failing test first) → implement → auto-lint/typecheck. Activates on code edits, quality issues, or when user asks about testing/linting workflow.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Using Quality Gates
|
|
7
|
+
|
|
8
|
+
**Quality Gates** provides automated code quality enforcement through PostToolUse hooks:
|
|
9
|
+
|
|
10
|
+
1. **TypeScript Quality Gate** — Runs after TS/JS edits: TypeScript + ESLint + Prettier
|
|
11
|
+
2. **Python Quality Gate** — Runs after Python edits: Ruff + Mypy
|
|
12
|
+
|
|
13
|
+
**Separate Installation Required for TDD:**
|
|
14
|
+
- **TDD Guard** is a separate tool (not included) — See "TDD Guard Setup" below
|
|
15
|
+
|
|
16
|
+
## Architecture Overview
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
20
|
+
│ QUALITY GATES (this skill) │
|
|
21
|
+
│ ───────────────────────────── │
|
|
22
|
+
│ PostToolUse Hooks (installed by this skill): │
|
|
23
|
+
│ • .claude/hooks/quality-check.cjs → TS/JS files │
|
|
24
|
+
│ • .claude/hooks/quality-check.py → Python files │
|
|
25
|
+
│ • .claude/settings.json → Hook registration │
|
|
26
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
27
|
+
|
|
28
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
29
|
+
│ TDD GUARD (separate installation) │
|
|
30
|
+
│ ─────────────────────────────────── │
|
|
31
|
+
│ PreToolUse Hook (requires xtrm install project tdd-guard): │
|
|
32
|
+
│ • Global CLI: npm install -g tdd-guard │
|
|
33
|
+
│ • Test reporter: tdd-guard-vitest / tdd-guard-pytest / etc. │
|
|
34
|
+
│ • Hook: .claude/hooks/tdd-guard-pretool-bridge.cjs │
|
|
35
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
|
|
40
|
+
### Step 1: Install This Skill
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
xtrm install project quality-gates
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
This installs:
|
|
47
|
+
- `.claude/hooks/quality-check.cjs` — TypeScript/JavaScript checks
|
|
48
|
+
- `.claude/hooks/quality-check.py` — Python checks
|
|
49
|
+
- `.claude/settings.json` — PostToolUse hook registration
|
|
50
|
+
- `.claude/skills/using-quality-gates/` — This documentation
|
|
51
|
+
|
|
52
|
+
### Step 2: Install Language Dependencies
|
|
53
|
+
|
|
54
|
+
**TypeScript Projects:**
|
|
55
|
+
```bash
|
|
56
|
+
npm install --save-dev typescript eslint prettier
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**Python Projects:**
|
|
60
|
+
```bash
|
|
61
|
+
pip install ruff mypy
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Step 3: (Optional) Install TDD Guard
|
|
65
|
+
|
|
66
|
+
For test-first enforcement, install TDD Guard separately:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
# 1. Install global CLI
|
|
70
|
+
npm install -g tdd-guard
|
|
71
|
+
|
|
72
|
+
# 2. Install project-skill for hook wiring
|
|
73
|
+
xtrm install project tdd-guard
|
|
74
|
+
|
|
75
|
+
# 3. Install test reporter (choose one)
|
|
76
|
+
npm install --save-dev tdd-guard-vitest # Vitest
|
|
77
|
+
npm install --save-dev tdd-guard-jest # Jest
|
|
78
|
+
pip install tdd-guard-pytest # pytest
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**Configure test reporter** (see https://github.com/nizos/tdd-guard):
|
|
82
|
+
|
|
83
|
+
**Vitest:**
|
|
84
|
+
```typescript
|
|
85
|
+
// vitest.config.ts
|
|
86
|
+
import { defineConfig } from 'vitest/config'
|
|
87
|
+
import { VitestReporter } from 'tdd-guard-vitest'
|
|
88
|
+
|
|
89
|
+
export default defineConfig({
|
|
90
|
+
test: {
|
|
91
|
+
reporters: ['default', new VitestReporter('/path/to/project')],
|
|
92
|
+
},
|
|
93
|
+
})
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**pytest:**
|
|
97
|
+
```toml
|
|
98
|
+
# pyproject.toml
|
|
99
|
+
[tool.pytest.ini_options]
|
|
100
|
+
tdd_guard_project_root = "/path/to/project"
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## How Quality Gates Work
|
|
104
|
+
|
|
105
|
+
### TypeScript Quality Gate (PostToolUse)
|
|
106
|
+
|
|
107
|
+
**Runs after:** Every `.ts`, `.tsx`, `.js`, `.jsx` file edit
|
|
108
|
+
|
|
109
|
+
**Checks:**
|
|
110
|
+
1. TypeScript compilation (type errors)
|
|
111
|
+
2. ESLint validation (style, best practices)
|
|
112
|
+
3. Prettier formatting (consistency)
|
|
113
|
+
|
|
114
|
+
**Configuration** (`.claude/hooks/hook-config.json`):
|
|
115
|
+
```json
|
|
116
|
+
{
|
|
117
|
+
"typescript": { "enabled": true, "showDependencyErrors": false },
|
|
118
|
+
"eslint": { "enabled": true, "autofix": true },
|
|
119
|
+
"prettier": { "enabled": true, "autofix": true },
|
|
120
|
+
"general": { "autofixSilent": true }
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Python Quality Gate (PostToolUse)
|
|
125
|
+
|
|
126
|
+
**Runs after:** Every `.py` file edit
|
|
127
|
+
|
|
128
|
+
**Checks:**
|
|
129
|
+
1. Ruff linting (errors, style, best practices)
|
|
130
|
+
2. Ruff formatting (Black-compatible)
|
|
131
|
+
3. Mypy type checking (static types)
|
|
132
|
+
|
|
133
|
+
**Configuration** (environment variables):
|
|
134
|
+
```bash
|
|
135
|
+
CLAUDE_HOOKS_RUFF_ENABLED=true
|
|
136
|
+
CLAUDE_HOOKS_MYPY_ENABLED=true
|
|
137
|
+
CLAUDE_HOOKS_AUTOFIX=true
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Exit Codes
|
|
141
|
+
|
|
142
|
+
| Code | Meaning | Action |
|
|
143
|
+
|------|---------|--------|
|
|
144
|
+
| 0 | All checks passed | Continue |
|
|
145
|
+
| 1 | Fatal error (missing deps) | Install missing tool |
|
|
146
|
+
| 2 | Blocking errors | Claude must fix |
|
|
147
|
+
|
|
148
|
+
## Handling Quality Gate Errors
|
|
149
|
+
|
|
150
|
+
When blocked with exit code 2:
|
|
151
|
+
|
|
152
|
+
1. **Read the error output** — Specific issues listed
|
|
153
|
+
2. **Auto-fix applies automatically** — ESLint/Prettier/Ruff fix what they can
|
|
154
|
+
3. **Fix remaining issues manually** — Type errors, complex violations
|
|
155
|
+
4. **Gate re-runs on next edit** — No manual trigger needed
|
|
156
|
+
|
|
157
|
+
**Example:**
|
|
158
|
+
```
|
|
159
|
+
[ERROR] TypeScript compilation failed:
|
|
160
|
+
src/auth.ts:42:5 - error TS2322: Type 'string' is not assignable to type 'number'
|
|
161
|
+
|
|
162
|
+
[WARN] Auto-fix applied: 2 issues fixed
|
|
163
|
+
[BLOCK] 1 issue remains - fix before continuing
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## TDD Guard Integration
|
|
167
|
+
|
|
168
|
+
When TDD Guard is installed alongside Quality Gates:
|
|
169
|
+
|
|
170
|
+
```
|
|
171
|
+
User Request: "Add feature X"
|
|
172
|
+
↓
|
|
173
|
+
┌───────────────────────────────────┐
|
|
174
|
+
│ TDD Guard (PreToolUse) │
|
|
175
|
+
│ Checks: Failing test exists? │
|
|
176
|
+
│ • NO → BLOCK: "Write test first" │
|
|
177
|
+
│ • YES → Allow implementation │
|
|
178
|
+
└───────────────────────────────────┘
|
|
179
|
+
↓
|
|
180
|
+
Implementation (Write/Edit)
|
|
181
|
+
↓
|
|
182
|
+
┌───────────────────────────────────┐
|
|
183
|
+
│ Quality Gates (PostToolUse) │
|
|
184
|
+
│ Runs: Lint + Typecheck + Format │
|
|
185
|
+
│ • Errors → BLOCK, fix issues │
|
|
186
|
+
│ • Pass → Continue │
|
|
187
|
+
└───────────────────────────────────┘
|
|
188
|
+
↓
|
|
189
|
+
Tests pass → Commit
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## Troubleshooting
|
|
193
|
+
|
|
194
|
+
**"ESLint not found" / "Prettier not found"**
|
|
195
|
+
```bash
|
|
196
|
+
npm install --save-dev eslint prettier
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
**"Ruff not found" / "Mypy not found"**
|
|
200
|
+
```bash
|
|
201
|
+
pip install ruff mypy
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
**"tdd-guard: command not found"**
|
|
205
|
+
```bash
|
|
206
|
+
npm install -g tdd-guard
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
**"TDD Guard: No failing test found"**
|
|
210
|
+
- Write a failing test first
|
|
211
|
+
- Ensure test reporter is configured
|
|
212
|
+
- Run tests to generate reporter JSON
|
|
213
|
+
|
|
214
|
+
**Hook not running**
|
|
215
|
+
- Verify `.claude/settings.json` exists
|
|
216
|
+
- Check hook script paths are correct
|
|
217
|
+
- Ensure file extension matches (`.ts`/`.py`)
|
|
218
|
+
|
|
219
|
+
## When This Skill Activates
|
|
220
|
+
|
|
221
|
+
**Triggers:**
|
|
222
|
+
- Quality gate reports errors
|
|
223
|
+
- User asks about linting, type checking, or quality workflow
|
|
224
|
+
- Session starts in a project with quality gates installed
|
|
225
|
+
|
|
226
|
+
**Response Modes:**
|
|
227
|
+
|
|
228
|
+
**Full Workflow Mode** (user mentions quality/testing, blocked by gate errors):
|
|
229
|
+
- Explain complete quality pipeline
|
|
230
|
+
- Provide troubleshooting guidance
|
|
231
|
+
|
|
232
|
+
**Minimal Mode** (general coding tasks without quality context):
|
|
233
|
+
- Complete the task directly
|
|
234
|
+
- Brief note: "Consider adding tests. If TDD Guard is installed, write failing test first."
|
|
235
|
+
|
|
236
|
+
## Files Installed
|
|
237
|
+
|
|
238
|
+
```
|
|
239
|
+
.claude/
|
|
240
|
+
├── settings.json # PostToolUse hook registration
|
|
241
|
+
├── hooks/
|
|
242
|
+
│ ├── quality-check.cjs # TypeScript/JavaScript checks
|
|
243
|
+
│ ├── quality-check.py # Python checks
|
|
244
|
+
│ └── hook-config.json # TS hook configuration
|
|
245
|
+
├── skills/
|
|
246
|
+
│ └── using-quality-gates/ # This skill
|
|
247
|
+
└── docs/
|
|
248
|
+
└── quality-gates-readme.md
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
## Related
|
|
252
|
+
|
|
253
|
+
- **TDD Guard**: https://github.com/nizos/tdd-guard
|
|
254
|
+
- **xtrm install project tdd-guard**: Install TDD Guard hooks
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# Quality Gates
|
|
2
|
+
|
|
3
|
+
**PostToolUse code quality hooks** for Claude Code. Runs automatically after file edits to enforce linting, type checking, and formatting standards.
|
|
4
|
+
|
|
5
|
+
## What This Installs
|
|
6
|
+
|
|
7
|
+
**TypeScript Quality Gate** (`.ts`, `.tsx`, `.js`, `.jsx`):
|
|
8
|
+
- TypeScript compilation check
|
|
9
|
+
- ESLint validation + auto-fix
|
|
10
|
+
- Prettier formatting + auto-fix
|
|
11
|
+
|
|
12
|
+
**Python Quality Gate** (`.py`):
|
|
13
|
+
- Ruff linting + auto-fix
|
|
14
|
+
- Ruff formatting + auto-fix
|
|
15
|
+
- Mypy type checking
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# 1. Install this skill
|
|
21
|
+
xtrm install project quality-gates
|
|
22
|
+
|
|
23
|
+
# 2. Install language dependencies
|
|
24
|
+
npm install --save-dev typescript eslint prettier # TypeScript
|
|
25
|
+
pip install ruff mypy # Python
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## What Gets Installed
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
.claude/
|
|
32
|
+
├── settings.json # PostToolUse hook registration
|
|
33
|
+
├── hooks/
|
|
34
|
+
│ ├── quality-check.cjs # TypeScript/JavaScript checks
|
|
35
|
+
│ ├── quality-check.py # Python checks
|
|
36
|
+
│ └── hook-config.json # TS hook configuration
|
|
37
|
+
├── skills/
|
|
38
|
+
│ └── using-quality-gates/ # Skill documentation
|
|
39
|
+
└── docs/
|
|
40
|
+
└── quality-gates-readme.md
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## How It Works
|
|
44
|
+
|
|
45
|
+
After every file edit:
|
|
46
|
+
1. Hook detects file type (TS/JS or Python)
|
|
47
|
+
2. Runs appropriate quality checks
|
|
48
|
+
3. Auto-fixes issues when possible
|
|
49
|
+
4. Returns exit code:
|
|
50
|
+
- `0` = All checks passed
|
|
51
|
+
- `2` = Blocking errors (Claude must fix)
|
|
52
|
+
|
|
53
|
+
## Configuration
|
|
54
|
+
|
|
55
|
+
### TypeScript
|
|
56
|
+
|
|
57
|
+
Edit `.claude/hooks/hook-config.json`:
|
|
58
|
+
|
|
59
|
+
```json
|
|
60
|
+
{
|
|
61
|
+
"typescript": { "enabled": true, "showDependencyErrors": false },
|
|
62
|
+
"eslint": { "enabled": true, "autofix": true },
|
|
63
|
+
"prettier": { "enabled": true, "autofix": true }
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Python
|
|
68
|
+
|
|
69
|
+
Set environment variables:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
export CLAUDE_HOOKS_RUFF_ENABLED=true
|
|
73
|
+
export CLAUDE_HOOKS_MYPY_ENABLED=true
|
|
74
|
+
export CLAUDE_HOOKS_AUTOFIX=true
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## TDD Guard (Separate Installation)
|
|
78
|
+
|
|
79
|
+
For test-first enforcement, install TDD Guard separately:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# 1. Global CLI
|
|
83
|
+
npm install -g tdd-guard
|
|
84
|
+
|
|
85
|
+
# 2. Project skill for hooks
|
|
86
|
+
xtrm install project tdd-guard
|
|
87
|
+
|
|
88
|
+
# 3. Test reporter (choose one)
|
|
89
|
+
npm install --save-dev tdd-guard-vitest # Vitest
|
|
90
|
+
npm install --save-dev tdd-guard-jest # Jest
|
|
91
|
+
pip install tdd-guard-pytest # pytest
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
See: https://github.com/nizos/tdd-guard
|
|
95
|
+
|
|
96
|
+
## Troubleshooting
|
|
97
|
+
|
|
98
|
+
| Error | Fix |
|
|
99
|
+
|-------|-----|
|
|
100
|
+
| "ESLint not found" | `npm install --save-dev eslint prettier` |
|
|
101
|
+
| "Ruff not found" | `pip install ruff mypy` |
|
|
102
|
+
| "tdd-guard: command not found" | `npm install -g tdd-guard` |
|
|
103
|
+
| Hook not running | Check `.claude/settings.json` exists |
|
|
104
|
+
|
|
105
|
+
## Related
|
|
106
|
+
|
|
107
|
+
- **TDD Guard**: https://github.com/nizos/tdd-guard
|
|
108
|
+
- **Ruff**: https://docs.astral.sh/ruff/
|
|
109
|
+
- **Mypy**: https://mypy.readthedocs.io/
|