xtrm-tools 2.1.5 → 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.
Files changed (74) hide show
  1. package/README.md +9 -3
  2. package/cli/dist/index.cjs +991 -908
  3. package/cli/dist/index.cjs.map +1 -1
  4. package/cli/package.json +4 -1
  5. package/config/hooks.json +5 -0
  6. package/hooks/README.md +19 -0
  7. package/hooks/beads-stop-gate.mjs +1 -0
  8. package/hooks/main-guard-post-push.mjs +71 -0
  9. package/hooks/main-guard.mjs +10 -1
  10. package/package.json +17 -5
  11. package/project-skills/{ts-quality-gate → quality-gates}/.claude/hooks/quality-check.cjs +36 -1
  12. package/project-skills/{py-quality-gate → quality-gates}/.claude/hooks/quality-check.py +15 -2
  13. package/project-skills/{py-quality-gate → quality-gates}/.claude/settings.json +10 -0
  14. package/project-skills/quality-gates/.claude/skills/using-quality-gates/SKILL.md +254 -0
  15. package/project-skills/quality-gates/README.md +109 -0
  16. package/project-skills/quality-gates/evals/evals.json +181 -0
  17. package/project-skills/quality-gates/workspace/iteration-1/FINAL-EVAL-SUMMARY.md +75 -0
  18. package/project-skills/quality-gates/workspace/iteration-1/edge-case-auto-fix-verification/with_skill/outputs/response.md +59 -0
  19. package/project-skills/quality-gates/workspace/iteration-1/edge-case-mixed-language-project/with_skill/outputs/response.md +60 -0
  20. package/project-skills/quality-gates/workspace/iteration-1/eval-summary.md +105 -0
  21. package/project-skills/quality-gates/workspace/iteration-1/partial-install-python-only/with_skill/outputs/response.md +93 -0
  22. package/project-skills/quality-gates/workspace/iteration-1/python-refactor-request/with_skill/outputs/response.md +104 -0
  23. package/project-skills/quality-gates/workspace/iteration-1/quality-gate-error-fix/with_skill/outputs/response.md +74 -0
  24. package/project-skills/quality-gates/workspace/iteration-1/should-not-trigger-general-chat/with_skill/outputs/response.md +18 -0
  25. package/project-skills/quality-gates/workspace/iteration-1/should-not-trigger-math-question/with_skill/outputs/response.md +18 -0
  26. package/project-skills/quality-gates/workspace/iteration-1/should-not-trigger-unrelated-coding/with_skill/outputs/response.md +56 -0
  27. package/project-skills/quality-gates/workspace/iteration-1/tdd-guard-blocking-confusion/with_skill/outputs/response.md +67 -0
  28. package/project-skills/quality-gates/workspace/iteration-1/typescript-feature-with-tests/with_skill/outputs/response.md +97 -0
  29. package/project-skills/service-skills-set/install-service-skills.py +41 -11
  30. package/project-skills/tdd-guard/.claude/hooks/tdd-guard-pretool-bridge.cjs +0 -1
  31. package/project-skills/tdd-guard/reporters/jest/src/JestReporter.test-data.ts +199 -0
  32. package/project-skills/tdd-guard/reporters/jest/src/JestReporter.test.ts +302 -0
  33. package/project-skills/tdd-guard/reporters/jest/src/JestReporter.ts +201 -0
  34. package/project-skills/tdd-guard/reporters/jest/src/index.ts +4 -0
  35. package/project-skills/tdd-guard/reporters/jest/src/types.ts +42 -0
  36. package/project-skills/tdd-guard/reporters/jest/tsconfig.json +11 -0
  37. package/project-skills/tdd-guard/reporters/vitest/src/VitestReporter.test-data.ts +85 -0
  38. package/project-skills/tdd-guard/reporters/vitest/src/VitestReporter.test.ts +446 -0
  39. package/project-skills/tdd-guard/reporters/vitest/src/VitestReporter.ts +110 -0
  40. package/project-skills/tdd-guard/reporters/vitest/src/index.ts +4 -0
  41. package/project-skills/tdd-guard/reporters/vitest/src/types.ts +39 -0
  42. package/project-skills/tdd-guard/reporters/vitest/tsconfig.json +11 -0
  43. package/hooks/__pycache__/agent_context.cpython-314.pyc +0 -0
  44. package/project-skills/py-quality-gate/.claude/skills/using-py-quality-gate/SKILL.md +0 -112
  45. package/project-skills/py-quality-gate/README.md +0 -147
  46. package/project-skills/service-skills-set/.claude/git-hooks/__pycache__/doc_reminder.cpython-314.pyc +0 -0
  47. package/project-skills/service-skills-set/.claude/git-hooks/__pycache__/skill_staleness.cpython-314.pyc +0 -0
  48. package/project-skills/service-skills-set/.claude/skills/creating-service-skills/scripts/__pycache__/bootstrap.cpython-314.pyc +0 -0
  49. package/project-skills/service-skills-set/.claude/skills/updating-service-skills/scripts/__pycache__/drift_detector.cpython-314.pyc +0 -0
  50. package/project-skills/service-skills-set/.claude/skills/using-service-skills/scripts/__pycache__/cataloger.cpython-314.pyc +0 -0
  51. package/project-skills/service-skills-set/.claude/skills/using-service-skills/scripts/__pycache__/skill_activator.cpython-314.pyc +0 -0
  52. 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
  53. package/project-skills/service-skills-set/.claude/skills/using-service-skills/scripts/test_skill_activator.py +0 -58
  54. package/project-skills/service-skills-set/__pycache__/install-service-skills.cpython-314.pyc +0 -0
  55. package/project-skills/ts-quality-gate/.claude/settings.json +0 -16
  56. package/project-skills/ts-quality-gate/.claude/skills/using-ts-quality-gate/SKILL.md +0 -81
  57. package/project-skills/ts-quality-gate/README.md +0 -115
  58. package/skills/documenting/scripts/__pycache__/drift_detector.cpython-314.pyc +0 -0
  59. package/skills/documenting/scripts/__pycache__/orchestrator.cpython-314.pyc +0 -0
  60. package/skills/documenting/scripts/__pycache__/validate_metadata.cpython-314.pyc +0 -0
  61. package/skills/documenting/scripts/changelog/__pycache__/__init__.cpython-314.pyc +0 -0
  62. package/skills/documenting/scripts/changelog/__pycache__/add_entry.cpython-314.pyc +0 -0
  63. package/skills/documenting/scripts/changelog/__pycache__/bump_release.cpython-314.pyc +0 -0
  64. package/skills/documenting/scripts/changelog/__pycache__/validate_changelog.cpython-314.pyc +0 -0
  65. package/skills/documenting/tests/__pycache__/test_changelog.cpython-314-pytest-9.0.2.pyc +0 -0
  66. package/skills/documenting/tests/__pycache__/test_drift_detector.cpython-314-pytest-9.0.2.pyc +0 -0
  67. package/skills/documenting/tests/__pycache__/test_orchestrator.cpython-314-pytest-9.0.2.pyc +0 -0
  68. package/skills/documenting/tests/__pycache__/test_validate_metadata.cpython-314-pytest-9.0.2.pyc +0 -0
  69. package/skills/documenting/tests/integration_test.sh +0 -70
  70. package/skills/documenting/tests/test_changelog.py +0 -201
  71. package/skills/documenting/tests/test_drift_detector.py +0 -80
  72. package/skills/documenting/tests/test_orchestrator.py +0 -52
  73. package/skills/documenting/tests/test_validate_metadata.py +0 -64
  74. /package/project-skills/{ts-quality-gate → quality-gates}/.claude/hooks/hook-config.json +0 -0
package/cli/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xtrm-cli",
3
- "version": "2.1.4",
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
@@ -47,6 +47,11 @@
47
47
  }
48
48
  ],
49
49
  "PostToolUse": [
50
+ {
51
+ "matcher": "Bash",
52
+ "script": "main-guard-post-push.mjs",
53
+ "timeout": 5000
54
+ },
50
55
  {
51
56
  "matcher": "Bash",
52
57
  "script": "beads-close-memory-prompt.mjs",
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);
@@ -43,7 +43,16 @@ function deny(reason) {
43
43
  process.exit(2);
44
44
  }
45
45
 
46
- const WRITE_TOOLS = new Set(['Edit', 'Write', 'MultiEdit', 'NotebookEdit']);
46
+ const WRITE_TOOLS = new Set([
47
+ 'Edit',
48
+ 'Write',
49
+ 'MultiEdit',
50
+ 'NotebookEdit',
51
+ 'mcp__serena__rename_symbol',
52
+ 'mcp__serena__replace_symbol_body',
53
+ 'mcp__serena__insert_after_symbol',
54
+ 'mcp__serena__insert_before_symbol',
55
+ ]);
47
56
 
48
57
  if (WRITE_TOOLS.has(tool)) {
49
58
  deny(
package/package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "xtrm-tools",
3
- "version": "2.1.5",
3
+ "version": "2.1.7",
4
4
  "description": "Claude Code tools installer (skills, hooks, MCP servers)",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
+ "workspaces": [
8
+ "cli"
9
+ ],
7
10
  "bin": {
8
11
  "xtrm": "cli/dist/index.cjs"
9
12
  },
@@ -15,7 +18,11 @@
15
18
  "config",
16
19
  "hooks",
17
20
  "skills",
18
- "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/**"
19
26
  ],
20
27
  "publishConfig": {
21
28
  "access": "public"
@@ -29,13 +36,18 @@
29
36
  "url": "https://github.com/Jaggerxtrm/xtrm-tools/issues"
30
37
  },
31
38
  "scripts": {
32
- "build": "npm run build --prefix cli",
39
+ "sync:cli-version": "node scripts/sync-cli-version.mjs",
40
+ "prebuild": "npm run sync:cli-version",
41
+ "build": "npm run build --workspace cli",
42
+ "typecheck": "npm run typecheck --workspace cli",
33
43
  "start": "node cli/dist/index.cjs",
34
44
  "lint": "echo 'No linting configured'",
35
- "test": "echo 'No tests configured'"
45
+ "test": "npm test --workspace cli",
46
+ "version": "npm run sync:cli-version && git add cli/package.json",
47
+ "prepublishOnly": "npm run sync:cli-version && npm run build"
36
48
  },
37
49
  "engines": {
38
- "node": ">=18.0.0"
50
+ "node": ">=20.0.0"
39
51
  },
40
52
  "dependencies": {
41
53
  "comment-json": "^4.2.3",
@@ -861,6 +861,26 @@ class QualityChecker {
861
861
  });
862
862
  }
863
863
 
864
+ // Check for debugger statements
865
+ const debuggerRule = config._fileConfig.rules?.debugger || {};
866
+ if (debuggerRule.enabled !== false) {
867
+ lines.forEach((line, index) => {
868
+ if (/\bdebugger\b/.test(line)) {
869
+ const severity = debuggerRule.severity || 'error';
870
+ const message =
871
+ debuggerRule.message || 'Remove debugger statements before committing';
872
+
873
+ if (severity === 'error') {
874
+ this.errors.push(`Found debugger statement in ${this.filePath} - ${message}`);
875
+ console.error(` Line ${index + 1}: ${line.trim()}`);
876
+ foundIssues = true;
877
+ } else {
878
+ log.warning(`Debugger statement at line ${index + 1}: ${message}`);
879
+ }
880
+ }
881
+ });
882
+ }
883
+
864
884
  // Check for TODO/FIXME comments
865
885
  lines.forEach((line, index) => {
866
886
  if (/TODO|FIXME/.test(line)) {
@@ -1054,7 +1074,21 @@ function extractFilePath(input) {
1054
1074
  return null;
1055
1075
  }
1056
1076
 
1057
- return tool_input.file_path || tool_input.path || tool_input.notebook_path || null;
1077
+ const filePath =
1078
+ tool_input.file_path ||
1079
+ tool_input.path ||
1080
+ tool_input.notebook_path ||
1081
+ tool_input.relative_path ||
1082
+ null;
1083
+ if (!filePath) {
1084
+ return null;
1085
+ }
1086
+
1087
+ if (path.isAbsolute(filePath)) {
1088
+ return filePath;
1089
+ }
1090
+
1091
+ return path.join(projectRoot, filePath);
1058
1092
  }
1059
1093
 
1060
1094
  /**
@@ -1178,6 +1212,7 @@ async function main() {
1178
1212
  e.includes('ESLint found issues') ||
1179
1213
  e.includes('Prettier formatting issues') ||
1180
1214
  e.includes('console statements') ||
1215
+ e.includes('debugger statement') ||
1181
1216
  e.includes("'as any' usage") ||
1182
1217
  e.includes('were auto-fixed'),
1183
1218
  );
@@ -218,9 +218,22 @@ def parse_json_input() -> dict:
218
218
  sys.exit(1)
219
219
 
220
220
  def extract_file_path(input_data: dict) -> str | None:
221
- """Extract file path from tool input"""
221
+ """Extract file path from tool input, including Serena relative_path."""
222
222
  tool_input = input_data.get('tool_input', {})
223
- return tool_input.get('file_path') or tool_input.get('path')
223
+ file_path = (
224
+ tool_input.get('file_path')
225
+ or tool_input.get('path')
226
+ or tool_input.get('relative_path')
227
+ )
228
+ if not file_path:
229
+ return None
230
+
231
+ # Serena tools pass relative_path relative to the project root.
232
+ if not os.path.isabs(file_path):
233
+ project_root = os.environ.get('CLAUDE_PROJECT_DIR') or os.getcwd()
234
+ return str(Path(project_root) / file_path)
235
+
236
+ return file_path
224
237
 
225
238
  def main():
226
239
  """Main entry point"""
@@ -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/