code-auditor-mcp 3.4.18 → 3.6.0

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 (193) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/CHANGELOG.md +99 -0
  3. package/README.md +5 -5
  4. package/dist/analyzers/applicability.d.ts +19 -5
  5. package/dist/analyzers/applicability.d.ts.map +1 -1
  6. package/dist/analyzers/applicability.js +36 -24
  7. package/dist/analyzers/applicability.js.map +1 -1
  8. package/dist/analyzers/cross-language/APIContractAnalyzer.d.ts.map +1 -1
  9. package/dist/analyzers/cross-language/APIContractAnalyzer.js +23 -2
  10. package/dist/analyzers/cross-language/APIContractAnalyzer.js.map +1 -1
  11. package/dist/analyzers/cross-language/DependencyGraphBuilder.d.ts +52 -9
  12. package/dist/analyzers/cross-language/DependencyGraphBuilder.d.ts.map +1 -1
  13. package/dist/analyzers/cross-language/DependencyGraphBuilder.js +228 -55
  14. package/dist/analyzers/cross-language/DependencyGraphBuilder.js.map +1 -1
  15. package/dist/analyzers/cross-language/SchemaValidator.d.ts +19 -12
  16. package/dist/analyzers/cross-language/SchemaValidator.d.ts.map +1 -1
  17. package/dist/analyzers/cross-language/SchemaValidator.js +78 -111
  18. package/dist/analyzers/cross-language/SchemaValidator.js.map +1 -1
  19. package/dist/analyzers/crossDomain/CrossDomainAnalyzer.d.ts +0 -6
  20. package/dist/analyzers/crossDomain/CrossDomainAnalyzer.d.ts.map +1 -1
  21. package/dist/analyzers/crossDomain/CrossDomainAnalyzer.js +85 -73
  22. package/dist/analyzers/crossDomain/CrossDomainAnalyzer.js.map +1 -1
  23. package/dist/analyzers/documentationAnalyzer.js +5 -5
  24. package/dist/analyzers/documentationAnalyzer.js.map +1 -1
  25. package/dist/analyzers/invariantsAnalyzer.d.ts.map +1 -1
  26. package/dist/analyzers/invariantsAnalyzer.js +1 -0
  27. package/dist/analyzers/invariantsAnalyzer.js.map +1 -1
  28. package/dist/analyzers/provenance.d.ts +7 -9
  29. package/dist/analyzers/provenance.d.ts.map +1 -1
  30. package/dist/analyzers/provenance.js +88 -124
  31. package/dist/analyzers/provenance.js.map +1 -1
  32. package/dist/analyzers/reactAnalyzer.d.ts.map +1 -1
  33. package/dist/analyzers/reactAnalyzer.js +120 -21
  34. package/dist/analyzers/reactAnalyzer.js.map +1 -1
  35. package/dist/analyzers/ruleRegistry.d.ts +35 -12
  36. package/dist/analyzers/ruleRegistry.d.ts.map +1 -1
  37. package/dist/analyzers/ruleRegistry.js +66 -108
  38. package/dist/analyzers/ruleRegistry.js.map +1 -1
  39. package/dist/analyzers/ruleTiming.d.ts +2 -2
  40. package/dist/analyzers/ruleTiming.js +2 -2
  41. package/dist/analyzers/universal/UniversalConventionsAnalyzer.d.ts.map +1 -1
  42. package/dist/analyzers/universal/UniversalConventionsAnalyzer.js +60 -24
  43. package/dist/analyzers/universal/UniversalConventionsAnalyzer.js.map +1 -1
  44. package/dist/analyzers/universal/UniversalDRYAnalyzer.d.ts.map +1 -1
  45. package/dist/analyzers/universal/UniversalDRYAnalyzer.js +5 -2
  46. package/dist/analyzers/universal/UniversalDRYAnalyzer.js.map +1 -1
  47. package/dist/analyzers/universal/UniversalDataAccessAnalyzer.d.ts.map +1 -1
  48. package/dist/analyzers/universal/UniversalDataAccessAnalyzer.js +82 -71
  49. package/dist/analyzers/universal/UniversalDataAccessAnalyzer.js.map +1 -1
  50. package/dist/analyzers/universal/UniversalDocumentationAnalyzer.d.ts +2 -1
  51. package/dist/analyzers/universal/UniversalDocumentationAnalyzer.d.ts.map +1 -1
  52. package/dist/analyzers/universal/UniversalDocumentationAnalyzer.js +23 -12
  53. package/dist/analyzers/universal/UniversalDocumentationAnalyzer.js.map +1 -1
  54. package/dist/analyzers/universal/UniversalSOLIDAnalyzer.d.ts +11 -1
  55. package/dist/analyzers/universal/UniversalSOLIDAnalyzer.d.ts.map +1 -1
  56. package/dist/analyzers/universal/UniversalSOLIDAnalyzer.js +60 -22
  57. package/dist/analyzers/universal/UniversalSOLIDAnalyzer.js.map +1 -1
  58. package/dist/analyzers/universal/UniversalSchemaAnalyzer.d.ts.map +1 -1
  59. package/dist/analyzers/universal/UniversalSchemaAnalyzer.js +5 -2
  60. package/dist/analyzers/universal/UniversalSchemaAnalyzer.js.map +1 -1
  61. package/dist/analyzers/universal/UniversalStylesAnalyzer.d.ts +2 -3
  62. package/dist/analyzers/universal/UniversalStylesAnalyzer.d.ts.map +1 -1
  63. package/dist/analyzers/universal/UniversalStylesAnalyzer.js +258 -87
  64. package/dist/analyzers/universal/UniversalStylesAnalyzer.js.map +1 -1
  65. package/dist/analyzers/universal/schema/codeAnalysis.d.ts.map +1 -1
  66. package/dist/analyzers/universal/schema/codeAnalysis.js +7 -1
  67. package/dist/analyzers/universal/schema/codeAnalysis.js.map +1 -1
  68. package/dist/analyzers/universal/schema/discovery.d.ts +29 -1
  69. package/dist/analyzers/universal/schema/discovery.d.ts.map +1 -1
  70. package/dist/analyzers/universal/schema/discovery.js +76 -21
  71. package/dist/analyzers/universal/schema/discovery.js.map +1 -1
  72. package/dist/analyzers/universal/schema/jsonSchema.js +7 -11
  73. package/dist/analyzers/universal/schema/jsonSchema.js.map +1 -1
  74. package/dist/auditRouter.d.ts +41 -0
  75. package/dist/auditRouter.d.ts.map +1 -0
  76. package/dist/auditRouter.js +185 -0
  77. package/dist/auditRouter.js.map +1 -0
  78. package/dist/auditRunner.d.ts.map +1 -1
  79. package/dist/auditRunner.js +93 -84
  80. package/dist/auditRunner.js.map +1 -1
  81. package/dist/cli.js +306 -95
  82. package/dist/cli.js.map +1 -1
  83. package/dist/codeIndexDB.d.ts.map +1 -1
  84. package/dist/codeIndexDB.js +41 -7
  85. package/dist/codeIndexDB.js.map +1 -1
  86. package/dist/componentScanner.d.ts.map +1 -1
  87. package/dist/componentScanner.js +2 -1
  88. package/dist/componentScanner.js.map +1 -1
  89. package/dist/config/configLoader.d.ts +9 -0
  90. package/dist/config/configLoader.d.ts.map +1 -1
  91. package/dist/config/configLoader.js +45 -2
  92. package/dist/config/configLoader.js.map +1 -1
  93. package/dist/config/defaults.d.ts +8 -1
  94. package/dist/config/defaults.d.ts.map +1 -1
  95. package/dist/config/defaults.js +19 -3
  96. package/dist/config/defaults.js.map +1 -1
  97. package/dist/dataPaths.js +18 -1
  98. package/dist/dataPaths.js.map +1 -1
  99. package/dist/enforcement/gate.d.ts +14 -19
  100. package/dist/enforcement/gate.d.ts.map +1 -1
  101. package/dist/enforcement/gate.js +27 -45
  102. package/dist/enforcement/gate.js.map +1 -1
  103. package/dist/functionScanner.d.ts.map +1 -1
  104. package/dist/functionScanner.js +1 -17
  105. package/dist/functionScanner.js.map +1 -1
  106. package/dist/invariants/ruleEngine.d.ts +8 -0
  107. package/dist/invariants/ruleEngine.d.ts.map +1 -1
  108. package/dist/invariants/ruleEngine.js +35 -16
  109. package/dist/invariants/ruleEngine.js.map +1 -1
  110. package/dist/languages/LanguageOrchestrator.d.ts +9 -10
  111. package/dist/languages/LanguageOrchestrator.d.ts.map +1 -1
  112. package/dist/languages/LanguageOrchestrator.js +135 -101
  113. package/dist/languages/LanguageOrchestrator.js.map +1 -1
  114. package/dist/languages/RuntimeManager.d.ts +28 -1
  115. package/dist/languages/RuntimeManager.d.ts.map +1 -1
  116. package/dist/languages/RuntimeManager.js +158 -47
  117. package/dist/languages/RuntimeManager.js.map +1 -1
  118. package/dist/languages/go/GoAdapter.d.ts +2 -0
  119. package/dist/languages/go/GoAdapter.d.ts.map +1 -1
  120. package/dist/languages/go/GoAdapter.js +15 -22
  121. package/dist/languages/go/GoAdapter.js.map +1 -1
  122. package/dist/languages/go/analyzer +0 -0
  123. package/dist/languages/go/analyzer-src/analyzer.go +510 -0
  124. package/dist/languages/go/analyzer-src/go.mod +3 -0
  125. package/dist/languages/go/analyzer-src/indexer.go +268 -0
  126. package/dist/languages/go/analyzer-src/parser.go +461 -0
  127. package/dist/languages/go/analyzer-src/solid.go +395 -0
  128. package/dist/languages/go/analyzer-src/testconventions.go +25 -0
  129. package/dist/languages/go/analyzer-src/types.go +148 -0
  130. package/dist/languages/go/go.mod +7 -0
  131. package/dist/languages/go/main.go +203 -0
  132. package/dist/languages/testConventions.d.ts +35 -0
  133. package/dist/languages/testConventions.d.ts.map +1 -0
  134. package/dist/languages/testConventions.js +51 -0
  135. package/dist/languages/testConventions.js.map +1 -0
  136. package/dist/languages/typescript/TreeSitterTypeScriptAdapter.d.ts +3 -0
  137. package/dist/languages/typescript/TreeSitterTypeScriptAdapter.d.ts.map +1 -1
  138. package/dist/languages/typescript/TreeSitterTypeScriptAdapter.js +25 -18
  139. package/dist/languages/typescript/TreeSitterTypeScriptAdapter.js.map +1 -1
  140. package/dist/mcp-tools/whitelistTools.d.ts +1 -1
  141. package/dist/mcp-tools-shared.d.ts +0 -3
  142. package/dist/mcp-tools-shared.d.ts.map +1 -1
  143. package/dist/mcp-tools-shared.js +8 -117
  144. package/dist/mcp-tools-shared.js.map +1 -1
  145. package/dist/mcp.js +3 -1
  146. package/dist/mcp.js.map +1 -1
  147. package/dist/mcpAuditJobs.d.ts.map +1 -1
  148. package/dist/mcpAuditJobs.js +13 -0
  149. package/dist/mcpAuditJobs.js.map +1 -1
  150. package/dist/nextFile.d.ts +21 -0
  151. package/dist/nextFile.d.ts.map +1 -0
  152. package/dist/nextFile.js +51 -0
  153. package/dist/nextFile.js.map +1 -0
  154. package/dist/nextFileIncremental.d.ts +141 -0
  155. package/dist/nextFileIncremental.d.ts.map +1 -0
  156. package/dist/nextFileIncremental.js +314 -0
  157. package/dist/nextFileIncremental.js.map +1 -0
  158. package/dist/pipeline.d.ts.map +1 -1
  159. package/dist/pipeline.js +43 -3
  160. package/dist/pipeline.js.map +1 -1
  161. package/dist/pipelineAdapters.d.ts +17 -0
  162. package/dist/pipelineAdapters.d.ts.map +1 -1
  163. package/dist/pipelineAdapters.js +791 -40
  164. package/dist/pipelineAdapters.js.map +1 -1
  165. package/dist/reporting/jsonReportGenerator.d.ts.map +1 -1
  166. package/dist/reporting/jsonReportGenerator.js +11 -30
  167. package/dist/reporting/jsonReportGenerator.js.map +1 -1
  168. package/dist/styles/styleExtractor.js +2 -2
  169. package/dist/styles/styleExtractor.js.map +1 -1
  170. package/dist/styles/styleIndexer.d.ts +7 -0
  171. package/dist/styles/styleIndexer.d.ts.map +1 -1
  172. package/dist/styles/styleIndexer.js +51 -67
  173. package/dist/styles/styleIndexer.js.map +1 -1
  174. package/dist/styles/types.d.ts +3 -2
  175. package/dist/styles/types.d.ts.map +1 -1
  176. package/dist/types/crossLanguage.d.ts +1 -0
  177. package/dist/types/crossLanguage.d.ts.map +1 -1
  178. package/dist/types.d.ts +43 -34
  179. package/dist/types.d.ts.map +1 -1
  180. package/dist/types.js.map +1 -1
  181. package/dist/utils/fileDiscovery.d.ts +9 -0
  182. package/dist/utils/fileDiscovery.d.ts.map +1 -1
  183. package/dist/utils/fileDiscovery.js +18 -0
  184. package/dist/utils/fileDiscovery.js.map +1 -1
  185. package/package.json +16 -6
  186. package/plugin/.claude-plugin/plugin.json +1 -1
  187. package/plugin/README.md +11 -9
  188. package/plugin/hooks/hooks.json +4 -0
  189. package/plugin/scripts/hook-audit.sh +20 -30
  190. package/plugin/scripts/hook-common.sh +63 -0
  191. package/plugin/scripts/hook-self-audit.sh +99 -0
  192. package/plugin/skills/code-auditor/SKILL-RULE-KINDS.md +55 -9
  193. package/plugin/skills/code-auditor/SKILL.md +22 -23
@@ -0,0 +1,99 @@
1
+ #!/usr/bin/env bash
2
+ # code-auditor PostToolUse self-audit hook — enforce the self-audit scope
3
+ # (analyzers/ + languages/) at edit time, not just at release (Spec 33 Item 15).
4
+ #
5
+ # Reads the PostToolUse event JSON from stdin, extracts the edited file path,
6
+ # and — only when that file is production source in the self-audit scope — runs
7
+ # `code-audit self-audit` against it. Exit code 2 blocks the edit and feeds the
8
+ # finding JSON back to the agent.
9
+ #
10
+ # This hook is a no-op for every edit outside the self-audit scope (consumer
11
+ # projects, tests, fixtures, and the declarative ruleRegistry table), so it adds
12
+ # no latency to ordinary edits. It runs *in addition to* hook-audit.sh, whose
13
+ # diff-gate enforces invariant rules on every edit.
14
+ #
15
+ # Exit codes:
16
+ # 0 — clean pass or out of scope
17
+ # 2 — a blocking self-audit finding (Claude Code feeds stdout back)
18
+ # 1 — the hook itself broke (binary missing, version mismatch, CLI error) —
19
+ # reported loudly, never a silent no-op.
20
+ set -euo pipefail
21
+
22
+ # Shared resolver + compatibility pinning (see hook-common.sh).
23
+ . "${CLAUDE_PLUGIN_ROOT}/scripts/hook-common.sh"
24
+
25
+ # Read event JSON from stdin
26
+ event="$(cat)"
27
+
28
+ # Extract the file path from the tool input (Write and Edit both use file_path)
29
+ file="$(node -e "
30
+ try {
31
+ var d = JSON.parse(require('fs').readFileSync('/dev/stdin','utf8'));
32
+ process.stdout.write(d.tool_input?.file_path || d.tool_input?.path || '');
33
+ } catch(e) { process.stdout.write(''); }
34
+ " <<< "${event}")"
35
+
36
+ # No file path in the event — nothing to audit
37
+ if [ -z "${file}" ]; then
38
+ exit 0
39
+ fi
40
+
41
+ # Normalize the edited file to an absolute path (absolute paths pass through;
42
+ # relative paths resolve against the current working directory).
43
+ case "${file}" in
44
+ /*) file_abs="${file}" ;;
45
+ *) file_abs="$(cd "$(dirname "${file}")" 2>/dev/null && pwd)/$(basename "${file}")" ;;
46
+ esac
47
+
48
+ # Out-of-repo edit no-op (Spec 35 item 9): an edit outside the audited project
49
+ # must not error the hook.
50
+ if [ -n "${CLAUDE_PROJECT_DIR:-}" ]; then
51
+ project_abs="$(cd "${CLAUDE_PROJECT_DIR}" 2>/dev/null && pwd)" || project_abs="${CLAUDE_PROJECT_DIR%/}"
52
+ case "${file_abs}" in
53
+ "${project_abs}"/*) : ;; # inside the project — continue
54
+ *) exit 0 ;; # outside — nothing to self-audit
55
+ esac
56
+ fi
57
+
58
+ # Self-audit scope gate: only production files under src/analyzers/ or
59
+ # src/languages/ are self-audit targets. Everything else — every file in a
60
+ # consumer repo, plus this repo's tests, specs, fixtures, and the declarative
61
+ # ruleRegistry.ts data table — is a no-op. The `self-audit` command re-checks
62
+ # this scope on the reported finding paths, so this is only a cheap pre-filter
63
+ # to keep the hook off the hot path for ordinary edits.
64
+ case "${file_abs}" in
65
+ *"/src/analyzers/"*|*"/src/languages/"*) : ;;
66
+ *) exit 0 ;;
67
+ esac
68
+ case "${file_abs}" in
69
+ *"__tests__"*|*".test."*|*".spec."*|*"fixtures"*|*"ruleRegistry.ts"*) exit 0 ;;
70
+ esac
71
+
72
+ CODE_AUDIT_BIN="$(resolve_code_audit)"
73
+
74
+ # Pin the plugin to a compatible CLI version — fail loudly on mismatch.
75
+ assert_compatible "${CODE_AUDIT_BIN}" || exit 1
76
+
77
+ # Run the self-audit on the edited file. stdout/stderr feed back to the agent.
78
+ set +e
79
+ if [ -n "${CLAUDE_PROJECT_DIR:-}" ]; then
80
+ echo "${file_abs}" | ${CODE_AUDIT_BIN} self-audit --stdin --json -p "${CLAUDE_PROJECT_DIR}"
81
+ else
82
+ echo "${file_abs}" | ${CODE_AUDIT_BIN} self-audit --stdin --json
83
+ fi
84
+ exit_code=$?
85
+ set -e
86
+
87
+ # Exit 2 = a blocking self-audit finding; propagate so Claude Code feeds it back.
88
+ if [ ${exit_code} -eq 2 ]; then
89
+ exit 2
90
+ fi
91
+
92
+ # Any other non-zero exit is the hook breaking, not a clean pass. Report loudly
93
+ # and fail — a silent no-op here is exactly the failure mode this guards.
94
+ if [ ${exit_code} -ne 0 ]; then
95
+ echo "[code-auditor] HOOK BROKEN: self-audit exited ${exit_code} (neither clean nor a finding). Fix the install — do not treat this as a clean pass." >&2
96
+ exit 1
97
+ fi
98
+
99
+ exit 0
@@ -1,6 +1,6 @@
1
1
  # Invariant Rule Kinds
2
2
 
3
- Five rule kinds are available in `.codeauditor.json`. Rules are validated at startup — bad configs fail the audit, not silently skipped.
3
+ Seven rule kinds are available in `.codeauditor.json`. Rules are validated at startup — bad configs fail the audit, not silently skipped.
4
4
 
5
5
  ## Rule Kinds
6
6
 
@@ -139,15 +139,61 @@ With language and path constraints:
139
139
 
140
140
  `$$$` matches zero or more nodes (like `...` in rest patterns). `$$$ARGS` is a named meta-variable. See the [ast-grep pattern guide](https://ast-grep.github.io/guide/pattern-syntax.html) for full syntax.
141
141
 
142
- ## Severity Levels
142
+ ### `style-mechanism`
143
+
144
+ Enforce which styling mechanisms are allowed in files matching an optional `path` glob. A style declaration using an unapproved mechanism is flagged.
145
+
146
+ ```json
147
+ {
148
+ "id": "tailwind-only-in-components",
149
+ "kind": "style-mechanism",
150
+ "severity": "warning",
151
+ "allow": ["tailwind"],
152
+ "path": "src/components/**",
153
+ "message": "Only Tailwind utilities in src/components/ — use the project's CSS modules elsewhere"
154
+ }
155
+ ```
156
+
157
+ `allow` lists the permitted mechanisms (`tailwind`, `css-modules`, `styled-components`, `inline`, `css`). `path` is optional — omit it to apply the rule to every file.
158
+
159
+ ### `no-raw-values`
143
160
 
144
- | Severity | Meaning | Hook behavior |
145
- |----------|---------|---------------|
146
- | `critical` | Security vulnerabilities, data loss risks | Blocks the edit (`--fail-on critical`) |
147
- | `warning` | Architecture violations, tech debt | Reported; does not block the edit |
148
- | `suggestion` | Style issues, minor improvements | Reported; does not block the edit |
161
+ Require designated CSS properties to reference a design token instead of a raw value. A declaration whose normalized value has no token reference (and is not in `allowValues`) is flagged.
162
+
163
+ ```json
164
+ {
165
+ "id": "no-raw-colors-in-pages",
166
+ "kind": "no-raw-values",
167
+ "severity": "warning",
168
+ "properties": ["color", "background-color"],
169
+ "allowValues": ["inherit", "transparent"],
170
+ "path": "src/pages/**",
171
+ "message": "No raw colors in src/pages/ — use design tokens"
172
+ }
173
+ ```
174
+
175
+ `properties` lists the CSS properties to check. `allowValues` names values that are always permitted without a token reference. `path` is optional.
176
+
177
+ ## Severity Levels
149
178
 
150
- > **Severity controls the gate, never the obligation.** A finding that does not block the edit is still a defect to fix it passes the gate, not the review.
179
+ Severity ranks how urgent a finding is to fix. It never decides whether a
180
+ finding is real, and it never licenses leaving one unresolved. Whether an edit
181
+ is *blocked* is a separate axis: the edit hook gates on invariant rules that
182
+ declare `gating: true` (a binary, per-rule flag), not on severity.
183
+
184
+ | Severity | What it means |
185
+ |----------|---------------|
186
+ | `critical` | Security vulnerabilities, data-loss risks |
187
+ | `warning` | Architecture violations, tech debt, missing documentation |
188
+ | `suggestion` | Smaller defects — naming, conventions, minor correctness |
189
+
190
+ > **Severity ranks urgency, never whether a finding is real.** There is no
191
+ > "noise" tier — every finding is a defect to resolve. A finding that does not
192
+ > block the edit still fails the review unless it is fixed, or the rule that
193
+ > produces it is edited in `.codeauditor.json`. There is no "waive" — a finding
194
+ > leaves the queue only by being resolved or by changing the rule that fires it.
195
+ > Documentation findings are not stylistic: missing
196
+ > JSDoc is a maintainability defect, not a nicety.
151
197
 
152
198
  ## Validation
153
199
 
@@ -155,7 +201,7 @@ Rules are validated against `invariant-rules.schema.json` on startup. Common err
155
201
 
156
202
  - **Missing required field**: each kind has required fields (e.g., `import-ban` requires `module`)
157
203
  - **Invalid severity**: must be one of `critical`, `warning`, `suggestion`
158
- - **Invalid kind**: must be one of the five kinds above
204
+ - **Invalid kind**: must be one of the seven kinds above
159
205
  - **Both allowFrom and denyFrom**: `call-constraint` requires exactly one
160
206
  - **Empty pattern**: `ast-pattern` requires a non-empty `pattern` string
161
207
  - **Invalid language**: `ast-pattern` language must be `typescript`, `javascript`, or `go`
@@ -5,7 +5,7 @@ description: Audit code quality, search the codebase semantically, enforce invar
5
5
 
6
6
  # Code Auditor Skill
7
7
 
8
- > **Version 3.4.8** • Run `code-audit --version` to check your installed version.
8
+ > **Version 3.6.0** • Run `code-audit --version` to check your installed version.
9
9
  > If versions differ, the CLI is authoritative — use `code-audit <command> --help` to see what your install actually supports.
10
10
 
11
11
  You have the `code-audit` CLI available. It indexes every function, component, and struct in the codebase for semantic search and invariant enforcement. Use these commands instead of raw grep/find whenever possible.
@@ -38,12 +38,25 @@ Run an audit before declaring a task complete:
38
38
 
39
39
  ```bash
40
40
  code-audit audit --path . # Full audit
41
- code-audit changed --json --fail-on critical # Diff-scoped audit (hook contract)
41
+ code-audit changed --json # Diff-scoped audit (hook contract)
42
42
  ```
43
43
 
44
- Use `code-audit changed` after edits to confirm you haven't introduced violations. If the hook is active it already runs `code-audit changed --fail-on critical` automatically on Write/Edit — pay attention to its output.
44
+ Use `code-audit changed` after edits to confirm you haven't introduced violations. If the hook is active it already runs `code-audit changed` automatically on Write/Edit — pay attention to its output.
45
45
 
46
- Expected output: JSON violation list (with `--json`) or colored terminal summary. Non-zero exit code means violations at or above `--fail-on` severity were found.
46
+ **Every finding is a defect to resolve, not a suggestion to weigh.** After a full audit, work the violations in severity order — criticals first, then warnings, then suggestions — and fix them all. Severity ranks urgency, never whether a finding is real; there is no "noise" tier. Documentation findings (missing JSDoc) are maintainability defects, not stylistic niceties. If you choose not to fix one, record why before moving on never silently dismiss it.
47
+
48
+ Expected output: JSON violation list (with `--json`) or colored terminal summary. The full `audit` command exits non-zero when violations at or above `--fail-on` severity exist; the diff-scoped `changed` hook gates on per-rule `gating: true` flags, not severity.
49
+
50
+ ### `code-audit next-file` — fix violations one file at a time
51
+
52
+ ```bash
53
+ code-audit next-file --path . # Highest-priority file + all its findings
54
+ code-audit next-file --path . --json # Machine-readable
55
+ ```
56
+
57
+ This is the refactoring loop. `next-file` audits the project and returns the single highest-priority file — ranked by highest-severity finding, then total finding count — with every finding on it, ordered critical → warning → suggestion. Fix that file, then run it again: a still-broken file comes back, otherwise the next-worst file surfaces. `{done:true}` means the tree is clean.
58
+
59
+ There is **no skip or decline affordance**. A finding leaves the queue only by being fixed, or by editing the rule that produces it in `.codeauditor.json` (your rules editor). If a rule keeps firing on something you judge correct, change the rule — never work around it.
47
60
 
48
61
  ### `code-audit config` — know the project's laws
49
62
 
@@ -77,20 +90,6 @@ A **built-in** `scripts-and-tests` profile ships with every install — it exclu
77
90
 
78
91
  Invariant violations are **immune** to path profile gate exclusion — invariants enforce declared laws and always block.
79
92
 
80
- ### `code-audit tasks` — queue remediation work
81
-
82
- ```bash
83
- code-audit tasks list # List all tasks
84
- code-audit tasks create --title "Fix SQL injection" --priority high
85
- code-audit tasks get <taskId> # Get task details
86
- code-audit tasks update <taskId> --status in_progress
87
- code-audit tasks complete <taskId> # Mark task done
88
- code-audit tasks delete <taskId> # Delete a task
89
- code-audit tasks from-audit # Create tasks from audit violations
90
- ```
91
-
92
- Use `tasks from-audit` to convert audit violations into a tracked task list so every finding is resolved, not dropped. Work findings in severity order — criticals first, then warnings, then suggestions. Tasks carry fingerprints so duplicates are automatically deduplicated across audit runs. Every finding should end as fixed, not silently dismissed; if you choose not to fix one, record why before moving on.
93
-
94
93
  ### `code-audit index` — refresh the index after structural changes
95
94
 
96
95
  ```bash
@@ -172,7 +171,7 @@ Use `--format dot` to generate a directed call-graph diagram (Graphviz DOT forma
172
171
 
173
172
  Terminal output shows rank, function name, file path, PageRank percentile, betweenness percentile, complexity percentile, untested status, and composite risk score. JSON output fields: `functionName`, `filePath`, `pageRankPercentile`, `betweennessPercentile`, `complexityPercentile`, `untested`, `riskScore`.
174
173
 
175
- > **Release checklist**: When bumping the version on a release, update the version stamp on line 8 of all three canonical SKILL.md copies. `npm run verify:close` gates on test + integration + dist verification — the tag cannot move without all three green.
174
+ > **Release checklist**: The version banner above is stamped by `npm run build:skills` from `package.json` (the single source of truth) do not hand-edit it. Bump the version in `package.json`, run the build, and the skill copies it. `npm run verify:close` gates on test + integration + dist verification — the tag cannot move without all three green.
176
175
 
177
176
  ## Interpreting hook feedback
178
177
 
@@ -181,13 +180,13 @@ When an edit hook blocks your edit with a violation message:
181
180
  1. **Read the violation** — it includes the invariant rule's `message` field explaining *why* the edit was blocked
182
181
  2. **Fix the violation** — change your approach to comply with the invariant
183
182
  3. **Do NOT retry the same edit** — the hook will block it again
184
- 4. The hook runs `code-audit changed --fail-on critical`, so only critical-severity invariant violations block the edit. Warnings and suggestions are still violations and must be fixed — they pass the gate, they are not resolved.
183
+ 4. The hook runs `code-audit changed`, and its gate is binary and per-rule: an invariant rule blocks the edit only if it declares `gating: true` (regardless of severity). Warnings and suggestions are still violations and must be fixed — they pass the gate, they are not resolved.
185
184
 
186
185
  The hook auto-installs the package via npx on first use — no manual npm step needed. If the hook reports `[code-auditor] code-audit could not run`, the npx auto-install failed (network, unsupported platform). The agent should try again; if it persists, `npm install code-auditor-mcp` is the manual fix.
187
186
 
188
187
  ## Host-specific notes
189
188
 
190
- - **Claude Code**: This skill is bundled in the `code-auditor` plugin (`claude plugin install code-auditor`). The plugin also ships a `PostToolUse` hook on `Write|Edit` that runs `code-audit changed --fail-on critical` automatically — the hook feedback section above describes that behavior. The MCP server is available as `mcp__code-auditor__*` tools for shell-less use.
189
+ - **Claude Code**: This skill is bundled in the `code-auditor` plugin (`claude plugin install code-auditor`). The plugin also ships a `PostToolUse` hook on `Write|Edit` that runs `code-audit changed` automatically — the hook feedback section above describes that behavior. The MCP server is available as `mcp__code-auditor__*` tools for shell-less use.
191
190
  - **Cursor**: Skill install via `code-audit install --agent cursor`. Cursor's `afterFileEdit` hook fires after the edit and cannot block retroactively, so violations are reported through the strongest available feedback channel — fix them even though the edit already landed.
192
191
  - **Codex**: Skill install via `code-audit install --agent codex`. Codex's `PostToolUse` hook provides blocking feedback via exit code 2, replacing the tool result with violation messages.
193
192
  - **Gemini CLI**: Skill install only (`code-audit install --agent gemini`). No hook system exists; MCP covers shell-less use.
@@ -201,11 +200,11 @@ The hook auto-installs the package via npx on first use — no manual npm step n
201
200
  | Find by import | `code-audit search "dep:<module>"` |
202
201
  | Complex functions | `code-audit search "lang:go complexity:>10"` |
203
202
  | Look up symbol | `code-audit search --definition "<name>"` |
204
- | Diff-scoped audit | `code-audit changed --json --fail-on critical` |
203
+ | Diff-scoped audit | `code-audit changed --json` |
205
204
  | List invariant rules | `code-audit config rules-list` |
206
205
  | Inspect path profiles | `code-audit config profiles` |
207
206
  | Resolve file profiles | `code-audit config profiles --file <path>` |
208
- | Triage violations | `code-audit tasks from-audit` |
207
+ | Next file to fix | `code-audit next-file` |
209
208
  | Sync index | `code-audit index sync --path .` |
210
209
  | Codebase map | `code-audit map -p .` |
211
210
  | Mine conventions | `code-audit conventions list` |