@nerviq/cli 1.29.0 → 1.29.1

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 (80) hide show
  1. package/CHANGELOG.md +1527 -1493
  2. package/README.md +550 -538
  3. package/SECURITY.md +82 -82
  4. package/bin/cli.js +2562 -2558
  5. package/docs/api-reference.md +356 -356
  6. package/docs/audit-fix.md +109 -0
  7. package/docs/autofix.md +3 -62
  8. package/docs/getting-started.md +1 -1
  9. package/docs/index.html +592 -592
  10. package/docs/integration-contracts.md +287 -287
  11. package/docs/maintenance.md +128 -128
  12. package/docs/new-platform-guide.md +202 -202
  13. package/docs/release-process.md +63 -0
  14. package/docs/shallow-risk.md +244 -244
  15. package/docs/why-nerviq.md +82 -82
  16. package/package.json +67 -67
  17. package/src/aider/activity.js +226 -226
  18. package/src/aider/context.js +162 -162
  19. package/src/aider/freshness.js +123 -123
  20. package/src/aider/techniques.js +3465 -3465
  21. package/src/audit/layers.js +180 -180
  22. package/src/audit.js +1032 -1032
  23. package/src/benchmark.js +299 -299
  24. package/src/codex/activity.js +324 -324
  25. package/src/codex/freshness.js +142 -142
  26. package/src/codex/techniques.js +4895 -4895
  27. package/src/context.js +326 -326
  28. package/src/continuous-ops.js +11 -1
  29. package/src/convert.js +340 -340
  30. package/src/copilot/config-parser.js +280 -280
  31. package/src/copilot/context.js +218 -218
  32. package/src/copilot/freshness.js +177 -177
  33. package/src/copilot/patch.js +238 -238
  34. package/src/copilot/techniques.js +3578 -3578
  35. package/src/cursor/freshness.js +194 -194
  36. package/src/cursor/patch.js +243 -243
  37. package/src/cursor/techniques.js +3735 -3735
  38. package/src/doctor.js +201 -201
  39. package/src/fix-engine.js +511 -8
  40. package/src/formatters/csv.js +86 -86
  41. package/src/formatters/junit.js +123 -123
  42. package/src/formatters/markdown.js +164 -164
  43. package/src/formatters/otel.js +151 -151
  44. package/src/freshness.js +156 -156
  45. package/src/gemini/activity.js +402 -402
  46. package/src/gemini/context.js +290 -290
  47. package/src/gemini/freshness.js +183 -183
  48. package/src/gemini/patch.js +229 -229
  49. package/src/gemini/techniques.js +3811 -3811
  50. package/src/governance.js +533 -533
  51. package/src/harmony/audit.js +306 -306
  52. package/src/i18n.js +63 -63
  53. package/src/insights.js +119 -119
  54. package/src/integrations.js +134 -134
  55. package/src/locales/en.json +33 -33
  56. package/src/locales/es.json +33 -33
  57. package/src/migrate.js +354 -354
  58. package/src/opencode/activity.js +286 -286
  59. package/src/opencode/freshness.js +137 -137
  60. package/src/opencode/techniques.js +3450 -3450
  61. package/src/setup/analysis.js +12 -12
  62. package/src/setup.js +7 -6
  63. package/src/shallow-risk/index.js +56 -56
  64. package/src/shallow-risk/patterns/agent-config-cross-platform-drift.js +50 -50
  65. package/src/shallow-risk/patterns/agent-config-dangerous-autoapprove.js +46 -46
  66. package/src/shallow-risk/patterns/agent-config-deprecated-keys.js +46 -46
  67. package/src/shallow-risk/patterns/agent-config-missing-file.js +317 -317
  68. package/src/shallow-risk/patterns/agent-config-secret-literal.js +49 -49
  69. package/src/shallow-risk/patterns/agent-config-stack-contradiction.js +34 -34
  70. package/src/shallow-risk/patterns/hook-script-missing.js +70 -70
  71. package/src/shallow-risk/patterns/mcp-server-no-allowlist.js +52 -52
  72. package/src/shallow-risk/shared.js +648 -648
  73. package/src/source-urls.js +295 -295
  74. package/src/state-paths.js +85 -85
  75. package/src/supplemental-checks.js +805 -805
  76. package/src/telemetry.js +160 -160
  77. package/src/windsurf/context.js +359 -359
  78. package/src/windsurf/freshness.js +194 -194
  79. package/src/windsurf/patch.js +231 -231
  80. package/src/windsurf/techniques.js +3779 -3779
package/README.md CHANGED
@@ -1,538 +1,550 @@
1
- # Nerviq
2
-
3
- > Standardize and govern your AI coding agent setup — score, fix, and align across 8 platforms.
4
-
5
- [![npm version](https://img.shields.io/npm/v/@nerviq/cli)](https://www.npmjs.com/package/@nerviq/cli)
6
- [![License: AGPL-3.0](https://img.shields.io/badge/License-AGPL--3.0-blue.svg)](LICENSE)
7
- [![Checks: 2441](https://img.shields.io/badge/checks-2441-brightgreen)](https://github.com/nerviq/nerviq)
8
-
9
- ---
10
-
11
- ### 8 Platforms Supported
12
-
13
- Nerviq audits, sets up, and governs AI coding agent configurations for **8 platforms**:
14
-
15
- | Platform | Checks | Status |
16
- |----------|--------|--------|
17
- | Claude Code | 400 | Full |
18
- | Codex (OpenAI) | 272 | Full |
19
- | Gemini CLI (Google) | 300 | Full |
20
- | GitHub Copilot | 299 | Full |
21
- | Cursor | 301 | Full |
22
- | Windsurf | 297 | Full |
23
- | Aider | 283 | Full |
24
- | OpenCode | 286 | Full |
25
-
26
- ### 10 Stack-Specific Languages
27
-
28
- | Language | Checks | Key Areas |
29
- |----------|--------|-----------|
30
- | Python | 26 | pyproject, typing, pytest, linting, async, security |
31
- | Go | 21 | go.mod, vet, fmt, error wrapping, interfaces |
32
- | Rust | 21 | Cargo, clippy, unsafe docs, editions, cross-compile |
33
- | Java/Spring | 21 | Maven/Gradle, JUnit, Spring Boot, migrations |
34
- | Ruby | 16 | Gemfile, RSpec, Rubocop, Rails |
35
- | PHP | 16 | Composer, PHPUnit, Laravel, PSR |
36
- | .NET | 16 | csproj, NuGet, xUnit, EF Core |
37
- | Flutter | 15 | pubspec, analysis, state management, l10n |
38
- | Swift | 10 | SPM, SwiftLint, async/await, doc comments |
39
- | Kotlin | 10 | Gradle, ktlint, coroutines, Compose, KMP |
40
-
41
- ---
42
-
43
- ## What Nerviq Does
44
-
45
- Most repos use **more than one** AI coding agent — Claude and Cursor, Copilot and Codex, Gemini and Windsurf. Their configs drift silently. Nerviq is the neutral control plane that detects that drift, scores it, and helps align it.
46
-
47
- When your repo has 2+ platforms configured, `nerviq audit` leads with the Harmony Score — cross-platform alignment — before any single-platform results. Single-platform repos still get a normal per-platform audit.
48
-
49
- ```
50
- $ nerviq audit
51
- Detected: Next.js + TypeScript + Claude + Cursor
52
-
53
- Harmony Score: 78/100 — 3 drift issues across 2 platforms (Claude Code + Cursor)
54
- Run `nerviq harmony-audit` for the full cross-platform report.
55
-
56
- Platform: Claude Code
57
- CLAUDE.md .............. 23/25 checks passed
58
- .claude/settings.json .. 6/9 checks passed
59
-
60
- Platform: Cursor
61
- .cursor/rules/ ......... 14/16 checks passed
62
- .cursorrules ........... 4/7 checks passed
63
-
64
- Drift: trust-mode mismatch (Claude relaxed / Cursor strict)
65
- MCP coverage gap — 3 servers in Claude, 1 in Cursor
66
- format-on-save hook missing from Cursor
67
-
68
- 3 suggestions → `nerviq harmony-sync` to align.
69
- ```
70
-
71
- Single-platform repos still work the same way — the Harmony Score only appears when 2+ platforms are detected. Use `--no-harmony-first` to suppress it even on multi-platform repos.
72
-
73
- ### Scope — the 4 layers
74
-
75
- Every Nerviq check is tagged with one of four explicit layers so you know exactly what the tool claims (and does not claim) to cover:
76
-
77
- - **governance** — agent configuration posture: presence, content, and quality of agent-instruction files and platform settings.
78
- - **drift** — cross-platform consistency: do your configured platforms agree, and does declared state match repo reality?
79
- - **hygiene** — repo-level cleanliness adjacent to agents (gitignore, CHANGELOG, SECURITY.md, LICENSE, Node version pinning, etc.).
80
- - **shallow-risk** — obvious agent-config ↔ codebase boundary issues emitted through the experimental `--shallow-risk` lane.
81
-
82
- There is deliberately no "deep-review" or general-security-scanning layer — Nerviq is an agent-configuration audit tool, not a code-review tool. The experimental `nerviq audit --shallow-risk` pass now adds an opt-in, non-scoring boundary scan on top of the four-layer model. The full taxonomy and disambiguation rules live in `docs/integration-contracts.md §8`, and the `layer` field is surfaced in every output format (JSON, CSV, JUnit, Markdown, text).
83
-
84
- ## Quick Start
85
-
86
- ```bash
87
- npx @nerviq/cli --beginner # Show only the 5 starter commands
88
- npx @nerviq/cli audit # Quick scan: score + top 3 actions
89
- npx @nerviq/cli audit --full # Full audit with all checks + badge
90
- npx @nerviq/cli audit --snapshot --tag "pre-refactor" # Save a named snapshot for history/compare/trend
91
- npx @nerviq/cli audit --diff-only # PR/working-tree audit: changed files + linked governance/config surfaces only
92
- npx @nerviq/cli compare # Detailed per-check diff between latest 2 audit snapshots
93
- npx @nerviq/cli audit --webhook https://hooks.slack.com/services/... # Push audit results to Slack/Discord/generic HTTP
94
- npx @nerviq/cli audit --workspace packages/* # Monorepo: root governance + stack-specific workspace profiles
95
- npx @nerviq/cli setup # Generate starter-safe baseline
96
- npx @nerviq/cli augment # Improvement plan, no writes
97
- npx @nerviq/cli governance # Permission profiles + policy packs
98
- npx @nerviq/cli benchmark # Baseline vs projected score in isolated copy
99
- ```
100
-
101
- No install required. Zero dependencies.
102
-
103
- Text-mode CLI output explains terms like `MCP`, `hooks`, `deny rules`, and `governance` inline when they appear, so a first audit is easier to read.
104
-
105
- If you want the shortest possible command list inside the terminal, start with:
106
-
107
- ```bash
108
- npx @nerviq/cli --beginner
109
- ```
110
-
111
- ## Get Started by Role
112
-
113
- | You are a... | Start here | Then |
114
- |--------------|------------|------|
115
- | **Solo developer** | `nerviq audit` → `nerviq augment` | `nerviq benchmark` |
116
- | **Team lead / DevEx** | `nerviq governance` → `nerviq audit --json` | CI threshold + `nerviq watch` |
117
- | **Enterprise / Platform** | `nerviq harmony-audit` `nerviq harmony-drift` | Policy packs + `nerviq certify` |
118
-
119
- ## 2,441 Checks Across 96 Categories (8 Platforms × ~300 Governance Rules)
120
-
121
- | Category Group | Checks | Examples |
122
- |----------------|--------|---------|
123
- | Stack-Specific (10 languages) | 172 | Python, Go, Rust, Java, Ruby, PHP, .NET, Flutter, Swift, Kotlin |
124
- | Platform Config & Instructions | ~150 | CLAUDE.md, AGENTS.md, rules, managed blocks |
125
- | Security & Trust | ~80 | permissions, deny rules, secrets, trust posture |
126
- | Quality & Testing | ~70 | verification loops, lint/test/build, coverage |
127
- | Automation & Hooks | ~60 | PreToolUse, PostToolUse, notification hooks |
128
- | Workflow & Commands | ~50 | skills, commands, agents, snapshots |
129
- | Git & Hygiene | ~40 | .gitignore, env protection, changelog |
130
- | Tools & MCP | ~40 | .mcp.json, multi-server, Context7 |
131
- | Governance & Compliance | ~30 | permission profiles, audit trails |
132
- | DevOps & Infrastructure | ~30 | Docker, CI, Terraform, monitoring |
133
- | Cross-Platform Intelligence | ~25 | harmony (GA), synergy (Experimental), drift detection |
134
- | Enterprise & Freshness | ~20 | freshness tracking, deprecation, SBOM |
135
- | Memory & Context | ~15 | context management, compaction, @path |
136
- | Prompting & Design | ~10 | XML tags, constraints, frontend patterns |
137
-
138
- ## Harmony Cross-Platform Alignment `GA`
139
-
140
- Harmony detects drift between your AI coding platforms and keeps them in sync.
141
-
142
- ```bash
143
- npx @nerviq/cli harmony-audit # Cross-platform DX audit (0-100 harmony score)
144
- npx @nerviq/cli harmony-sync # Sync shared config across platforms
145
- npx @nerviq/cli harmony-drift # Detect drift between platform configs
146
- npx @nerviq/cli harmony-advise # Cross-platform improvement advice
147
- npx @nerviq/cli harmony-watch # Live monitoring for config drift
148
- npx @nerviq/cli harmony-governance # Unified governance across platforms
149
- npx @nerviq/cli harmony-add <platform> # Add a new platform to your project
150
- ```
151
-
152
- ## Synergy — Multi-Agent Amplification `EXPERIMENTAL`
153
-
154
- Synergy analyzes how your platforms work together and finds amplification opportunities. Currently uses static routing rules — learned routing is planned for v2.0.
155
-
156
- ```bash
157
- npx @nerviq/cli synergy-report # Multi-agent synergy analysis
158
- ```
159
-
160
- Synergy evaluates compound audit results, discovers compensation patterns (where one platform covers another's gaps), and ranks recommendations by cross-platform impact.
161
-
162
- ## SDK — `@nerviq/sdk` `BETA`
163
-
164
- Programmatic access to all Nerviq capabilities:
165
-
166
- ```js
167
- const { audit, harmonyAudit, detectPlatforms } = require('@nerviq/sdk');
168
-
169
- async function main() {
170
- try {
171
- const result = await audit('.', 'claude');
172
- console.log(`Score: ${result.score}/100`);
173
-
174
- const platforms = detectPlatforms('.');
175
- console.log(`Active platforms: ${platforms.join(', ') || 'none detected'}`);
176
-
177
- const harmony = await harmonyAudit('.');
178
- console.log(`Harmony score: ${harmony.harmonyScore}/100`);
179
- } catch (error) {
180
- console.error(error instanceof Error ? error.message : 'Unknown SDK error');
181
- process.exitCode = 1;
182
- }
183
- }
184
-
185
- main();
186
- ```
187
-
188
- Stable SDK surfaces: `audit`, `harmonyAudit`, `detectPlatforms`, `getCatalog`
189
- Experimental SDK surfaces: `synergyReport`, `routeTask`
190
-
191
- See [sdk/README.md](sdk/README.md) for full JavaScript examples, error handling guidance, and TypeScript usage.
192
-
193
- ## Integration Contract Pack
194
-
195
- Nerviq publishes a compact integration pack so external systems do not need to scrape CLI text:
196
-
197
- - OpenAPI 3.1 contract from `nerviq serve` via `GET /api/openapi.json`
198
- - Separate `nerviq-mcp` stdio JSON-RPC 2.0 transport for MCP hosts
199
- - Generic audit webhook schema at [`contracts/audit-webhook-event.schema.json`](contracts/audit-webhook-event.schema.json)
200
- - CI reference patterns in [`docs/ci-integration.md`](docs/ci-integration.md)
201
- - SDK usage guide in [`sdk/README.md`](sdk/README.md)
202
- - First-tier release gate in [`docs/first-tier-integration-gate.md`](docs/first-tier-integration-gate.md)
203
-
204
- See [`docs/integration-contracts.md`](docs/integration-contracts.md) for the full pack.
205
-
206
- ## Category Definition Kit
207
-
208
- Nerviq is positioned as the control plane for AI-enabled development:
209
-
210
- - a repo-native governance layer for AI coding agents
211
- - a cross-platform drift detector and operating model
212
- - not a full SAST scanner, prompt library, or single-vendor IDE plugin
213
-
214
- See [`docs/category-definition-kit.md`](docs/category-definition-kit.md) for the category language, comparison matrix, operating model, and adoption playbook.
215
-
216
- ## HTTP API — `nerviq serve`
217
-
218
- Nerviq ships with a built-in local HTTP API for dashboards, wrappers, scripts, and language-neutral integrations:
219
-
220
- ```bash
221
- npx @nerviq/cli serve --port 3000
222
- ```
223
-
224
- Endpoints:
225
- - `GET /api/openapi.json` Live OpenAPI 3.1 contract for this `serve` instance
226
- - `GET /api/health` — Server health check
227
- - `GET /api/catalog` Full check catalog
228
- - `GET /api/audit` — Run audit on a directory and platform via query params
229
- - `GET /api/harmony`Cross-platform harmony data
230
-
231
- All successful operational responses are wrapped in a JSON envelope:
232
-
233
- ```json
234
- {
235
- "data": {},
236
- "meta": {
237
- "version": "1.29.0",
238
- "timestamp": "2026-04-16T08:00:00.000Z"
239
- }
240
- }
241
- ```
242
-
243
- Pull the contract directly into Swagger UI, Postman, or internal tooling:
244
-
245
- ```bash
246
- curl http://127.0.0.1:3000/api/openapi.json > nerviq-openapi.json
247
- ```
248
-
249
- This HTTP surface is separate from the MCP transport. If your host expects Model Context Protocol over stdio, register the `nerviq-mcp` binary instead of pointing it at `nerviq serve`:
250
-
251
- ```json
252
- {
253
- "mcpServers": {
254
- "nerviq": {
255
- "command": "npx",
256
- "args": ["-y", "-p", "@nerviq/cli", "nerviq-mcp"]
257
- }
258
- }
259
- }
260
- ```
261
-
262
- ## Plugin System `nerviq.config.js`
263
-
264
- Extend Nerviq with custom checks via a config file in your project root:
265
-
266
- ```js
267
- // nerviq.config.js
268
- module.exports = {
269
- plugins: [
270
- {
271
- name: 'my-company-checks',
272
- checks: {
273
- internalDocs: {
274
- id: 'internalDocs',
275
- name: 'Internal docs present',
276
- check: (dir) => require('fs').existsSync(`${dir}/docs/internal.md`),
277
- impact: 'medium',
278
- category: 'Quality',
279
- fix: 'Add docs/internal.md with team-specific guidelines',
280
- },
281
- },
282
- },
283
- ],
284
- };
285
- ```
286
-
287
- See [docs/plugins.md](docs/plugins.md) for full plugin API reference.
288
-
289
- ## GitHub Action
290
-
291
- Add Nerviq to your CI pipeline:
292
-
293
- ```yaml
294
- # .github/workflows/nerviq.yml
295
- name: Nerviq Audit
296
- on: [push, pull_request]
297
-
298
- jobs:
299
- audit:
300
- runs-on: ubuntu-latest
301
- steps:
302
- - uses: actions/checkout@v4
303
- - uses: nerviq/nerviq@v1
304
- with:
305
- threshold: 60
306
- ```
307
-
308
- The action outputs `score`, `passed`, and `total` for use in downstream steps. Fails the workflow if the score is below the configured threshold.
309
-
310
- ## Certification
311
-
312
- Earn a Nerviq certification badge for your project:
313
-
314
- ```bash
315
- npx @nerviq/cli certify # Run certification and display badge
316
- ```
317
-
318
- Levels:
319
- - **Gold** — Harmony score >= 80, all platforms >= 70
320
- - **Silver** — Harmony score >= 60, all platforms >= 50
321
- - **Bronze** Any platform >= 40
322
-
323
- ## All Commands
324
-
325
- | Command | What it does |
326
- |---------|-------------|
327
- | `nerviq audit` | Score 0-100 — quick scan with top 3 actions and milestone coaching (default) |
328
- | `nerviq audit --full` | Full audit with all checks, weakest areas, confidence labels, and milestone coaching |
329
- | `nerviq audit --diff-only` | Analyze only changed files plus linked governance/config surfaces from git diff / working tree |
330
- | `nerviq fix <key>` | Auto-fix a specific check (shows score impact) |
331
- | `nerviq fix --all-critical` | Fix all critical issues at once |
332
- | `nerviq rollback` | Undo the most recent apply (delete created files) |
333
- | `nerviq rollback --list` | Show available rollback points |
334
- | `nerviq setup` | Generate starter-safe CLAUDE.md + hooks + commands |
335
- | `nerviq augment` | Repo-aware improvement plan with archetype profiling, operating profile, and adopt/defer/ignore guidance (no writes) |
336
- | `nerviq suggest-only` | Structured report for sharing, including repo archetype, operating profile, and adopt/defer/ignore guidance |
337
- | `nerviq plan` | Export proposal bundles with previews |
338
- | `nerviq apply` | Apply proposals with rollback |
339
- | `nerviq governance` | Permission profiles, hooks, policy packs |
340
- | `nerviq benchmark` | Baseline vs projected score in isolated temp copy |
341
- | `nerviq check-health` | Detect regressions between audit snapshots |
342
- | `nerviq deep-review` | AI-powered config review (opt-in) |
343
- | `nerviq deep-review --behavioral` | Local behavioral drift review with outcome-layer heuristics |
344
- | `nerviq interactive` | Step-by-step guided wizard |
345
- | `nerviq watch` | Live monitoring with score delta |
346
- | `nerviq history` | Audit snapshot history from saved snapshots |
347
- | `nerviq compare` | Compare latest vs previous audit snapshot |
348
- | `nerviq trend` | Export audit snapshot trend report |
349
- | `nerviq feedback` | Record recommendation outcomes |
350
- | `nerviq anti-patterns` | Detect anti-patterns in current project |
351
- | `nerviq freshness` | Show verification freshness for all checks |
352
- | `nerviq rules-export` | Export recommendation rules (human summary or --json) |
353
- | `nerviq badge` | shields.io badge for README |
354
- | `nerviq certify` | Certification level + badge |
355
- | `nerviq scan dir1 dir2` | Compare multiple repos |
356
- | `nerviq org scan dir1 dir2` | Aggregate multiple repos into one score table |
357
- | `nerviq org policy` | Inspect resolved org/team/repo policy layers |
358
- | `nerviq harmony-audit` | Cross-platform DX audit |
359
- | `nerviq harmony-score` | Standalone Harmony Score (0-100) with badge + CI gate |
360
- | `nerviq harmony-demo` | Zero-setup demo see Harmony in action instantly |
361
- | `nerviq harmony-sync` | Sync config across platforms |
362
- | `nerviq harmony-drift` | Detect platform drift |
363
- | `nerviq harmony-advise` | Cross-platform advice |
364
- | `nerviq harmony-watch` | Live drift monitoring |
365
- | `nerviq harmony-governance` | Unified platform governance |
366
- | `nerviq harmony-add <platform>` | Add a new platform to your project |
367
- | `nerviq synergy-report` | Multi-agent synergy analysis (Experimental) |
368
- | `nerviq catalog` | Show check catalog for all 8 platforms |
369
- | `nerviq doctor` | Self-diagnostics for install health, freshness, platform detection, declared MCP servers, and hook runtime |
370
- | `nerviq convert` | Convert config between platforms |
371
- | `nerviq migrate` | Migrate platform config versions |
372
- | `nerviq serve` | Start local HTTP API + OpenAPI contract |
373
-
374
- ## Options
375
-
376
- | Flag | Effect |
377
- |------|--------|
378
- | `--full` | Full audit output (all checks, weakest areas, confidence labels, milestone coaching) |
379
- | `--verbose` | Full audit + medium-priority recommendations |
380
- | `--threshold N` | Exit 1 if score < N (for CI) |
381
- | `--json` | Machine-readable JSON output |
382
- | `--out FILE` | Write output to file |
383
- | `--webhook URL` | POST audit results to Slack, Discord, or a generic JSON endpoint |
384
- | `--webhook-header NAME:VALUE` | Add a custom webhook header; repeat the flag for multiple headers |
385
- | `--webhook-retries N` | Retry transient webhook failures (`429`, `5xx`, timeouts) up to `N` extra times |
386
- | `--snapshot` | Save audit snapshot for trending |
387
- | `--tag LABEL` | Label a saved snapshot (repeat the flag for multiple tags) |
388
- | `--behavioral` | Run the opt-in local behavioral drift review via `deep-review` |
389
- | `--history` | With `deep-review --behavioral`, show behavioral snapshot history |
390
- | `--compare` | With `deep-review --behavioral`, compare the latest two behavioral snapshots |
391
- | `--diff-only` | Run a changed-file audit instead of a full repo audit |
392
- | `--diff-base SHA` | Base SHA for `--diff-only` PR comparisons (defaults to CI env vars when present) |
393
- | `--diff-head SHA` | Head SHA for `--diff-only` PR comparisons (defaults to `GITHUB_SHA` or `HEAD`) |
394
- | `--dry-run` | Preview changes without writing files |
395
- | `--config-only` | Only write config files, never source code |
396
- | `--auto` | Apply without prompts |
397
- | `--only A,B` | Limit apply to selected proposal IDs |
398
- | `--format sarif` | SARIF output for code scanning |
399
- | `--format markdown` | GitHub-flavoured PR-comment report |
400
- | `--format junit` | JUnit XML for CI test reporters (GitHub Actions, Jenkins, GitLab) |
401
- | `--format csv` | RFC 4180 CSV, one row per check |
402
- | `--platform NAME` | Target platform (claude, codex, gemini, copilot, cursor, windsurf, aider, opencode) |
403
- | `--workspace GLOB` | Audit workspaces separately as package-level live audits with summary-only JSON rows (e.g. packages/*) |
404
- | `--external PATH` | Benchmark an external repo |
405
-
406
- ### CI output formats
407
-
408
- Pipe audit output straight into the standard CI surfaces:
409
-
410
- ```bash
411
- # PR comment (GitHub-flavoured markdown)
412
- npx @nerviq/cli audit --format=markdown --out audit.md
413
-
414
- # CI test report (JUnit XML — Jenkins, GitLab, GitHub Actions reporter)
415
- npx @nerviq/cli audit --format=junit --out junit.xml
416
-
417
- # Spreadsheet / dashboard ingestion (RFC 4180 CSV)
418
- npx @nerviq/cli audit --format=csv --out audit.csv
419
- ```
420
-
421
- Webhook delivery automatically retries transient failures twice by default. For authenticated internal endpoints, you can add custom headers such as:
422
-
423
- ```bash
424
- npx @nerviq/cli audit \
425
- --webhook https://ops.example.com/nerviq/audit \
426
- --webhook-header "Authorization: Bearer $NERVIQ_WEBHOOK_TOKEN" \
427
- --webhook-header "X-Nerviq-Environment: production" \
428
- --webhook-retries 4
429
- ```
430
-
431
- Generic webhook endpoints now receive a stable `nerviq.audit.completed` event envelope with:
432
-
433
- - backward-compatible top-level `platform`, `score`, `passed`, `failed`, and `results`
434
- - nested `data` and `meta` blocks for new consumers
435
- - schema versioning through `schemaVersion`
436
-
437
- For PR-focused audits, you can scope Nerviq to the working tree or an explicit base/head range:
438
-
439
- ```bash
440
- npx @nerviq/cli audit --diff-only
441
- npx @nerviq/cli audit --diff-only --diff-base origin/main --diff-head HEAD
442
- ```
443
-
444
- `--diff-only` is intentionally a scoped review surface. It reports a `diff-only changed-file audit` score, lists the changed files it considered, and reminds you to run a full `nerviq audit` for the complete repo posture. Because diff-only scores are not directly comparable to full audit history, Nerviq blocks `--diff-only --snapshot`.
445
-
446
- For multi-repo governance, Nerviq also supports inherited policy layers:
447
-
448
- - `.nerviq/org-policy.json` in an ancestor directory for org defaults
449
- - `.nerviq/team-policy.json` in the repo for team overrides
450
- - `.nerviq/repo-policy.json` in the repo for repo-specific overrides
451
-
452
- Inspect the resolved contract with:
453
-
454
- ```bash
455
- npx @nerviq/cli org policy
456
- npx @nerviq/cli org scan ./app ./api ./infra --json
457
- ```
458
-
459
- For opt-in outcome-layer inspection, Nerviq can also run a local behavioral drift review:
460
-
461
- ```bash
462
- npx @nerviq/cli deep-review --behavioral
463
- npx @nerviq/cli deep-review --behavioral --snapshot --milestone baseline --tag "behavioral-baseline"
464
- npx @nerviq/cli deep-review --behavioral --history
465
- npx @nerviq/cli deep-review --behavioral --compare
466
- ```
467
-
468
- Behavioral drift mode is intentionally guarded:
469
-
470
- - It analyzes repository structure and instruction-vs-outcome mismatch heuristics
471
- - It does not claim agent attribution without explicit evidence
472
- - It is not marketed as SAST, semantic code review, or runtime analysis
473
-
474
- `nerviq setup` now seeds a trust-boundary section in `CLAUDE.md` and an `injection-defense` starter hook for `WebFetch`, `WebSearch`, `Read`, `Grep`, `Glob`, and MCP-backed external-content flows. `nerviq doctor` validates that the declared starter hook still runs and logs suspicious prompt-injection patterns correctly.
475
-
476
- ## Backed by Research
477
-
478
- Nerviq is built on the NERVIQ knowledge engine — the largest verified catalog of AI coding agent techniques:
479
-
480
- - **540+ research documents** covering all 8 platforms
481
- - **400+ experiments** with tested, rated results
482
- - **2,441 checks** across 8 platforms (~300 unique governance rules × 8 platform adaptations), each with `sourceUrl` and `confidence` level (0.0-1.0)
483
- - Every check is traceable to primary documentation or verified experiment
484
- - **Freshness:** daily changelog scanning across all 8 platforms, weekly liveness sweep (6 automated checks), monthly quality review, quarterly cross-validation — items older than 90 days are confidence-weighted
485
-
486
- ## Safety Modes
487
-
488
- Nerviq provides explicit safety controls so you decide what it can touch:
489
-
490
- | Mode | Flag | What it does |
491
- |------|------|-------------|
492
- | **Read-only** | `nerviq audit` | Reads files, writes nothing. Default command. |
493
- | **Suggest-only** | `nerviq suggest-only` | Generates markdown report, no file writes. |
494
- | **Dry-run** | `--dry-run` | Previews setup/fix/apply changes without writing. |
495
- | **Config-only** | `--config-only` | Only writes config files (.claude/, rules, hooks). Never touches source code. |
496
- | **Safe-write** | `--profile safe-write` | Default write profile. Creates new files, never overwrites existing ones. |
497
- | **Power-user** | `--profile power-user` | Overwrites existing files (use with `--snapshot` for rollback). |
498
-
499
- Every write command supports `--snapshot` for automatic backup before changes.
500
-
501
- ## Privacy
502
-
503
- - **Zero dependencies** nothing to audit
504
- - **Runs locally** — audit, setup, plan, apply, governance, benchmark all run on your machine
505
- - **Deep review is opt-in** `deep-review` sends selected config for AI analysis, while `deep-review --behavioral` stays local and uses heuristic outcome-layer analysis only
506
- - **AGPL-3.0 Licensed** open source
507
-
508
- ## Links
509
-
510
- - **npm**: [@nerviq/cli](https://www.npmjs.com/package/@nerviq/cli)
511
- - **GitHub**: [github.com/nerviq/nerviq](https://github.com/nerviq/nerviq)
512
- - **Website**: [nerviq.net](https://nerviq.net)
513
- - **Discord**: [Join the community](https://discord.gg/nerviq)
514
-
515
- ---
516
-
517
- If Nerviq helped you, consider giving it a on [GitHub](https://github.com/nerviq/nerviq) it helps others discover the project.
518
-
519
- ## What Nerviq Is and Isn't
520
-
521
- **Best for:** Teams going from zero governance to a strong baseline — fast. If you're starting with AI coding agents or have a few platforms running without consistent configuration, Nerviq gets you to a governed setup quickly.
522
-
523
- **Not designed for:** Deeply customized setups with 20+ skills, agent teams, and bespoke MCP integrations. If you've already built advanced agent workflows, you may not need this.
524
-
525
- **Strongest at:** AI agent governance, configuration intelligence, workflow policy hygiene, cross-platform alignment, and setup standardization.
526
-
527
- **Not a replacement for:** Deep architectural review of business logic, runtime performance profiling, full SAST coverage, secret scanning, or security penetration testing. Nerviq focuses on how your AI coding agents are configured and governed — not on what your application code does.
528
-
529
- **Confidence levels:** Every check includes a `confidence` score (0.0–1.0) and a `sourceUrl` linking to primary documentation. Checks marked `heuristic` are pattern-based and may produce false positives on non-standard project structures.
530
-
531
- **Feature maturity:**
532
-
533
- | Label | Meaning |
534
- |-------|---------|
535
- | `GA` | Stable, tested on real repos, safe for production use |
536
- | `BETA` | Works but has limited real-world testing. API may change |
537
- | `EXPERIMENTAL` | Early stage, static rules, results may vary |
538
-
1
+ # Nerviq
2
+
3
+ > Standardize and govern your AI coding agent setup — score, fix, and align across 8 platforms.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@nerviq/cli)](https://www.npmjs.com/package/@nerviq/cli)
6
+ [![License: AGPL-3.0](https://img.shields.io/badge/License-AGPL--3.0-blue.svg)](LICENSE)
7
+ [![Checks: 2441](https://img.shields.io/badge/checks-2441-brightgreen)](https://github.com/nerviq/nerviq)
8
+
9
+ ---
10
+
11
+ ### 8 Platforms Supported
12
+
13
+ Nerviq audits, sets up, and governs AI coding agent configurations for **8 platforms**:
14
+
15
+ | Platform | Checks | Status |
16
+ |----------|--------|--------|
17
+ | Claude Code | 400 | Full |
18
+ | Codex (OpenAI) | 272 | Full |
19
+ | Gemini CLI (Google) | 300 | Full |
20
+ | GitHub Copilot | 299 | Full |
21
+ | Cursor | 301 | Full |
22
+ | Windsurf | 297 | Full |
23
+ | Aider | 283 | Full |
24
+ | OpenCode | 286 | Full |
25
+
26
+ ### 10 Stack-Specific Languages
27
+
28
+ | Language | Checks | Key Areas |
29
+ |----------|--------|-----------|
30
+ | Python | 26 | pyproject, typing, pytest, linting, async, security |
31
+ | Go | 21 | go.mod, vet, fmt, error wrapping, interfaces |
32
+ | Rust | 21 | Cargo, clippy, unsafe docs, editions, cross-compile |
33
+ | Java/Spring | 21 | Maven/Gradle, JUnit, Spring Boot, migrations |
34
+ | Ruby | 16 | Gemfile, RSpec, Rubocop, Rails |
35
+ | PHP | 16 | Composer, PHPUnit, Laravel, PSR |
36
+ | .NET | 16 | csproj, NuGet, xUnit, EF Core |
37
+ | Flutter | 15 | pubspec, analysis, state management, l10n |
38
+ | Swift | 10 | SPM, SwiftLint, async/await, doc comments |
39
+ | Kotlin | 10 | Gradle, ktlint, coroutines, Compose, KMP |
40
+
41
+ ---
42
+
43
+ ## What Nerviq Does
44
+
45
+ Most repos use **more than one** AI coding agent — Claude and Cursor, Copilot and Codex, Gemini and Windsurf. Their configs drift silently. Nerviq is the neutral control plane that detects that drift, scores it, and helps align it.
46
+
47
+ When your repo has 2+ platforms configured, `nerviq audit` leads with the Harmony Score — cross-platform alignment — before any single-platform results. Single-platform repos still get a normal per-platform audit.
48
+
49
+ ```
50
+ $ nerviq audit
51
+ Detected: Next.js + TypeScript + Claude + Cursor
52
+
53
+ Harmony Score: 78/100 — 3 drift issues across 2 platforms (Claude Code + Cursor)
54
+ Run `nerviq harmony-audit` for the full cross-platform report.
55
+
56
+ Platform: Claude Code
57
+ CLAUDE.md .............. 23/25 checks passed
58
+ .claude/settings.json .. 6/9 checks passed
59
+
60
+ Platform: Cursor
61
+ .cursor/rules/ ......... 14/16 checks passed
62
+ .cursorrules ........... 4/7 checks passed
63
+
64
+ Drift: trust-mode mismatch (Claude relaxed / Cursor strict)
65
+ MCP coverage gap — 3 servers in Claude, 1 in Cursor
66
+ format-on-save hook missing from Cursor
67
+
68
+ 3 suggestions → `nerviq harmony-sync` to align.
69
+ ```
70
+
71
+ Single-platform repos still work the same way — the Harmony Score only appears when 2+ platforms are detected. Use `--no-harmony-first` to suppress it even on multi-platform repos.
72
+
73
+ ### Scope — the 4 layers
74
+
75
+ Every Nerviq check is tagged with one of four explicit layers so you know exactly what the tool claims (and does not claim) to cover:
76
+
77
+ - **governance** — agent configuration posture: presence, content, and quality of agent-instruction files and platform settings.
78
+ - **drift** — cross-platform consistency: do your configured platforms agree, and does declared state match repo reality?
79
+ - **hygiene** — repo-level cleanliness adjacent to agents (gitignore, CHANGELOG, SECURITY.md, LICENSE, Node version pinning, etc.).
80
+ - **shallow-risk** — obvious agent-config ↔ codebase boundary issues emitted through the experimental `--shallow-risk` lane.
81
+
82
+ There is deliberately no "deep-review" or general-security-scanning layer — Nerviq is an agent-configuration audit tool, not a code-review tool. The experimental `nerviq audit --shallow-risk` pass now adds an opt-in, non-scoring boundary scan on top of the four-layer model. The full taxonomy and disambiguation rules live in `docs/integration-contracts.md §8`, and the `layer` field is surfaced in every output format (JSON, CSV, JUnit, Markdown, text).
83
+
84
+ ## Quick Start
85
+
86
+ ```bash
87
+ npx @nerviq/cli --beginner # Show only the 5 starter commands
88
+ npx @nerviq/cli audit # Quick scan: score + top 3 actions
89
+ npx @nerviq/cli audit --fix # Dry-run deterministic autofix plan + audit-fix.patch
90
+ npx @nerviq/cli audit --full # Full audit with all checks + badge
91
+ npx @nerviq/cli audit --snapshot --tag "pre-refactor" # Save a named snapshot for history/compare/trend
92
+ npx @nerviq/cli audit --diff-only # PR/working-tree audit: changed files + linked governance/config surfaces only
93
+ npx @nerviq/cli compare # Detailed per-check diff between latest 2 audit snapshots
94
+ npx @nerviq/cli audit --webhook https://hooks.slack.com/services/... # Push audit results to Slack/Discord/generic HTTP
95
+ npx @nerviq/cli audit --workspace packages/* # Monorepo: root governance + stack-specific workspace profiles
96
+ npx @nerviq/cli setup # Generate starter-safe baseline
97
+ npx @nerviq/cli augment # Improvement plan, no writes
98
+ npx @nerviq/cli governance # Permission profiles + policy packs
99
+ npx @nerviq/cli benchmark # Baseline vs projected score in isolated copy
100
+ ```
101
+
102
+ No install required. Zero dependencies.
103
+
104
+ Text-mode CLI output explains terms like `MCP`, `hooks`, `deny rules`, and `governance` inline when they appear, so a first audit is easier to read.
105
+
106
+ If you want the shortest possible command list inside the terminal, start with:
107
+
108
+ ```bash
109
+ npx @nerviq/cli --beginner
110
+ ```
111
+
112
+ ### Safe Autofix with `--fix`
113
+
114
+ `nerviq audit --fix` now defaults to a safe dry-run. Nerviq only plans deterministic file-level fixes on an allowlist of governance and hygiene files such as `CLAUDE.md`, `AGENTS.md`, `.claude/settings.json`, `.gitignore`, `.editorconfig`, `CHANGELOG.md`, `CONTRIBUTING.md`, and `LICENSE`.
115
+
116
+ ```bash
117
+ npx @nerviq/cli audit --fix # Preview changes and write audit-fix.patch
118
+ npx @nerviq/cli audit --fix --apply --auto # Apply deterministic fixes
119
+ npx @nerviq/cli audit --fix --pr # Create a local branch and stage the autofix files
120
+ ```
121
+
122
+ Checks that need judgment stay advisory-only and are listed as manual follow-ups. See [`docs/audit-fix.md`](docs/audit-fix.md) for the full contract.
123
+
124
+ ## Get Started by Role
125
+
126
+ | You are a... | Start here | Then |
127
+ |--------------|------------|------|
128
+ | **Solo developer** | `nerviq audit` `nerviq augment` | `nerviq benchmark` |
129
+ | **Team lead / DevEx** | `nerviq governance` → `nerviq audit --json` | CI threshold + `nerviq watch` |
130
+ | **Enterprise / Platform** | `nerviq harmony-audit` `nerviq harmony-drift` | Policy packs + `nerviq certify` |
131
+
132
+ ## 2,441 Checks Across 96 Categories (8 Platforms × ~300 Governance Rules)
133
+
134
+ | Category Group | Checks | Examples |
135
+ |----------------|--------|---------|
136
+ | Stack-Specific (10 languages) | 172 | Python, Go, Rust, Java, Ruby, PHP, .NET, Flutter, Swift, Kotlin |
137
+ | Platform Config & Instructions | ~150 | CLAUDE.md, AGENTS.md, rules, managed blocks |
138
+ | Security & Trust | ~80 | permissions, deny rules, secrets, trust posture |
139
+ | Quality & Testing | ~70 | verification loops, lint/test/build, coverage |
140
+ | Automation & Hooks | ~60 | PreToolUse, PostToolUse, notification hooks |
141
+ | Workflow & Commands | ~50 | skills, commands, agents, snapshots |
142
+ | Git & Hygiene | ~40 | .gitignore, env protection, changelog |
143
+ | Tools & MCP | ~40 | .mcp.json, multi-server, Context7 |
144
+ | Governance & Compliance | ~30 | permission profiles, audit trails |
145
+ | DevOps & Infrastructure | ~30 | Docker, CI, Terraform, monitoring |
146
+ | Cross-Platform Intelligence | ~25 | harmony (GA), synergy (Experimental), drift detection |
147
+ | Enterprise & Freshness | ~20 | freshness tracking, deprecation, SBOM |
148
+ | Memory & Context | ~15 | context management, compaction, @path |
149
+ | Prompting & Design | ~10 | XML tags, constraints, frontend patterns |
150
+
151
+ ## Harmony — Cross-Platform Alignment `GA`
152
+
153
+ Harmony detects drift between your AI coding platforms and keeps them in sync.
154
+
155
+ ```bash
156
+ npx @nerviq/cli harmony-audit # Cross-platform DX audit (0-100 harmony score)
157
+ npx @nerviq/cli harmony-sync # Sync shared config across platforms
158
+ npx @nerviq/cli harmony-drift # Detect drift between platform configs
159
+ npx @nerviq/cli harmony-advise # Cross-platform improvement advice
160
+ npx @nerviq/cli harmony-watch # Live monitoring for config drift
161
+ npx @nerviq/cli harmony-governance # Unified governance across platforms
162
+ npx @nerviq/cli harmony-add <platform> # Add a new platform to your project
163
+ ```
164
+
165
+ ## Synergy — Multi-Agent Amplification `EXPERIMENTAL`
166
+
167
+ Synergy analyzes how your platforms work together and finds amplification opportunities. Currently uses static routing rules — learned routing is planned for v2.0.
168
+
169
+ ```bash
170
+ npx @nerviq/cli synergy-report # Multi-agent synergy analysis
171
+ ```
172
+
173
+ Synergy evaluates compound audit results, discovers compensation patterns (where one platform covers another's gaps), and ranks recommendations by cross-platform impact.
174
+
175
+ ## SDK `@nerviq/sdk` `BETA`
176
+
177
+ Programmatic access to all Nerviq capabilities:
178
+
179
+ ```js
180
+ const { audit, harmonyAudit, detectPlatforms } = require('@nerviq/sdk');
181
+
182
+ async function main() {
183
+ try {
184
+ const result = await audit('.', 'claude');
185
+ console.log(`Score: ${result.score}/100`);
186
+
187
+ const platforms = detectPlatforms('.');
188
+ console.log(`Active platforms: ${platforms.join(', ') || 'none detected'}`);
189
+
190
+ const harmony = await harmonyAudit('.');
191
+ console.log(`Harmony score: ${harmony.harmonyScore}/100`);
192
+ } catch (error) {
193
+ console.error(error instanceof Error ? error.message : 'Unknown SDK error');
194
+ process.exitCode = 1;
195
+ }
196
+ }
197
+
198
+ main();
199
+ ```
200
+
201
+ Stable SDK surfaces: `audit`, `harmonyAudit`, `detectPlatforms`, `getCatalog`
202
+ Experimental SDK surfaces: `synergyReport`, `routeTask`
203
+
204
+ See [sdk/README.md](sdk/README.md) for full JavaScript examples, error handling guidance, and TypeScript usage.
205
+
206
+ ## Integration Contract Pack
207
+
208
+ Nerviq publishes a compact integration pack so external systems do not need to scrape CLI text:
209
+
210
+ - OpenAPI 3.1 contract from `nerviq serve` via `GET /api/openapi.json`
211
+ - Separate `nerviq-mcp` stdio JSON-RPC 2.0 transport for MCP hosts
212
+ - Generic audit webhook schema at [`contracts/audit-webhook-event.schema.json`](contracts/audit-webhook-event.schema.json)
213
+ - CI reference patterns in [`docs/ci-integration.md`](docs/ci-integration.md)
214
+ - SDK usage guide in [`sdk/README.md`](sdk/README.md)
215
+ - First-tier release gate in [`docs/first-tier-integration-gate.md`](docs/first-tier-integration-gate.md)
216
+
217
+ See [`docs/integration-contracts.md`](docs/integration-contracts.md) for the full pack.
218
+
219
+ ## Category Definition Kit
220
+
221
+ Nerviq is positioned as the control plane for AI-enabled development:
222
+
223
+ - a repo-native governance layer for AI coding agents
224
+ - a cross-platform drift detector and operating model
225
+ - not a full SAST scanner, prompt library, or single-vendor IDE plugin
226
+
227
+ See [`docs/category-definition-kit.md`](docs/category-definition-kit.md) for the category language, comparison matrix, operating model, and adoption playbook.
228
+
229
+ ## HTTP API`nerviq serve`
230
+
231
+ Nerviq ships with a built-in local HTTP API for dashboards, wrappers, scripts, and language-neutral integrations:
232
+
233
+ ```bash
234
+ npx @nerviq/cli serve --port 3000
235
+ ```
236
+
237
+ Endpoints:
238
+ - `GET /api/openapi.json` — Live OpenAPI 3.1 contract for this `serve` instance
239
+ - `GET /api/health` — Server health check
240
+ - `GET /api/catalog` — Full check catalog
241
+ - `GET /api/audit` — Run audit on a directory and platform via query params
242
+ - `GET /api/harmony` — Cross-platform harmony data
243
+
244
+ All successful operational responses are wrapped in a JSON envelope:
245
+
246
+ ```json
247
+ {
248
+ "data": {},
249
+ "meta": {
250
+ "version": "1.29.1",
251
+ "timestamp": "2026-04-16T08:00:00.000Z"
252
+ }
253
+ }
254
+ ```
255
+
256
+ Pull the contract directly into Swagger UI, Postman, or internal tooling:
257
+
258
+ ```bash
259
+ curl http://127.0.0.1:3000/api/openapi.json > nerviq-openapi.json
260
+ ```
261
+
262
+ This HTTP surface is separate from the MCP transport. If your host expects Model Context Protocol over stdio, register the `nerviq-mcp` binary instead of pointing it at `nerviq serve`:
263
+
264
+ ```json
265
+ {
266
+ "mcpServers": {
267
+ "nerviq": {
268
+ "command": "npx",
269
+ "args": ["-y", "-p", "@nerviq/cli", "nerviq-mcp"]
270
+ }
271
+ }
272
+ }
273
+ ```
274
+
275
+ ## Plugin System — `nerviq.config.js`
276
+
277
+ Extend Nerviq with custom checks via a config file in your project root:
278
+
279
+ ```js
280
+ // nerviq.config.js
281
+ module.exports = {
282
+ plugins: [
283
+ {
284
+ name: 'my-company-checks',
285
+ checks: {
286
+ internalDocs: {
287
+ id: 'internalDocs',
288
+ name: 'Internal docs present',
289
+ check: (dir) => require('fs').existsSync(`${dir}/docs/internal.md`),
290
+ impact: 'medium',
291
+ category: 'Quality',
292
+ fix: 'Add docs/internal.md with team-specific guidelines',
293
+ },
294
+ },
295
+ },
296
+ ],
297
+ };
298
+ ```
299
+
300
+ See [docs/plugins.md](docs/plugins.md) for full plugin API reference.
301
+
302
+ ## GitHub Action
303
+
304
+ Add Nerviq to your CI pipeline:
305
+
306
+ ```yaml
307
+ # .github/workflows/nerviq.yml
308
+ name: Nerviq Audit
309
+ on: [push, pull_request]
310
+
311
+ jobs:
312
+ audit:
313
+ runs-on: ubuntu-latest
314
+ steps:
315
+ - uses: actions/checkout@v4
316
+ - uses: nerviq/nerviq@v1
317
+ with:
318
+ threshold: 60
319
+ ```
320
+
321
+ The action outputs `score`, `passed`, and `total` for use in downstream steps. Fails the workflow if the score is below the configured threshold.
322
+
323
+ ## Certification
324
+
325
+ Earn a Nerviq certification badge for your project:
326
+
327
+ ```bash
328
+ npx @nerviq/cli certify # Run certification and display badge
329
+ ```
330
+
331
+ Levels:
332
+ - **Gold** Harmony score >= 80, all platforms >= 70
333
+ - **Silver** Harmony score >= 60, all platforms >= 50
334
+ - **Bronze** Any platform >= 40
335
+
336
+ ## All Commands
337
+
338
+ | Command | What it does |
339
+ |---------|-------------|
340
+ | `nerviq audit` | Score 0-100 quick scan with top 3 actions and milestone coaching (default) |
341
+ | `nerviq audit --full` | Full audit with all checks, weakest areas, confidence labels, and milestone coaching |
342
+ | `nerviq audit --diff-only` | Analyze only changed files plus linked governance/config surfaces from git diff / working tree |
343
+ | `nerviq fix <key>` | Auto-fix a specific check (shows score impact) |
344
+ | `nerviq fix --all-critical` | Fix all critical issues at once |
345
+ | `nerviq rollback` | Undo the most recent apply (delete created files) |
346
+ | `nerviq rollback --list` | Show available rollback points |
347
+ | `nerviq setup` | Generate starter-safe CLAUDE.md + hooks + commands |
348
+ | `nerviq augment` | Repo-aware improvement plan with archetype profiling, operating profile, and adopt/defer/ignore guidance (no writes) |
349
+ | `nerviq suggest-only` | Structured report for sharing, including repo archetype, operating profile, and adopt/defer/ignore guidance |
350
+ | `nerviq plan` | Export proposal bundles with previews |
351
+ | `nerviq apply` | Apply proposals with rollback |
352
+ | `nerviq governance` | Permission profiles, hooks, policy packs |
353
+ | `nerviq benchmark` | Baseline vs projected score in isolated temp copy |
354
+ | `nerviq check-health` | Detect regressions between audit snapshots |
355
+ | `nerviq deep-review` | AI-powered config review (opt-in) |
356
+ | `nerviq deep-review --behavioral` | Local behavioral drift review with outcome-layer heuristics |
357
+ | `nerviq interactive` | Step-by-step guided wizard |
358
+ | `nerviq watch` | Live monitoring with score delta |
359
+ | `nerviq history` | Audit snapshot history from saved snapshots |
360
+ | `nerviq compare` | Compare latest vs previous audit snapshot |
361
+ | `nerviq trend` | Export audit snapshot trend report |
362
+ | `nerviq feedback` | Record recommendation outcomes |
363
+ | `nerviq anti-patterns` | Detect anti-patterns in current project |
364
+ | `nerviq freshness` | Show verification freshness for all checks |
365
+ | `nerviq rules-export` | Export recommendation rules (human summary or --json) |
366
+ | `nerviq badge` | shields.io badge for README |
367
+ | `nerviq certify` | Certification level + badge |
368
+ | `nerviq scan dir1 dir2` | Compare multiple repos |
369
+ | `nerviq org scan dir1 dir2` | Aggregate multiple repos into one score table |
370
+ | `nerviq org policy` | Inspect resolved org/team/repo policy layers |
371
+ | `nerviq harmony-audit` | Cross-platform DX audit |
372
+ | `nerviq harmony-score` | Standalone Harmony Score (0-100) with badge + CI gate |
373
+ | `nerviq harmony-demo` | Zero-setup demo — see Harmony in action instantly |
374
+ | `nerviq harmony-sync` | Sync config across platforms |
375
+ | `nerviq harmony-drift` | Detect platform drift |
376
+ | `nerviq harmony-advise` | Cross-platform advice |
377
+ | `nerviq harmony-watch` | Live drift monitoring |
378
+ | `nerviq harmony-governance` | Unified platform governance |
379
+ | `nerviq harmony-add <platform>` | Add a new platform to your project |
380
+ | `nerviq synergy-report` | Multi-agent synergy analysis (Experimental) |
381
+ | `nerviq catalog` | Show check catalog for all 8 platforms |
382
+ | `nerviq doctor` | Self-diagnostics for install health, freshness, platform detection, declared MCP servers, and hook runtime |
383
+ | `nerviq convert` | Convert config between platforms |
384
+ | `nerviq migrate` | Migrate platform config versions |
385
+ | `nerviq serve` | Start local HTTP API + OpenAPI contract |
386
+
387
+ ## Options
388
+
389
+ | Flag | Effect |
390
+ |------|--------|
391
+ | `--full` | Full audit output (all checks, weakest areas, confidence labels, milestone coaching) |
392
+ | `--verbose` | Full audit + medium-priority recommendations |
393
+ | `--threshold N` | Exit 1 if score < N (for CI) |
394
+ | `--json` | Machine-readable JSON output |
395
+ | `--out FILE` | Write output to file |
396
+ | `--webhook URL` | POST audit results to Slack, Discord, or a generic JSON endpoint |
397
+ | `--webhook-header NAME:VALUE` | Add a custom webhook header; repeat the flag for multiple headers |
398
+ | `--webhook-retries N` | Retry transient webhook failures (`429`, `5xx`, timeouts) up to `N` extra times |
399
+ | `--snapshot` | Save audit snapshot for trending |
400
+ | `--tag LABEL` | Label a saved snapshot (repeat the flag for multiple tags) |
401
+ | `--behavioral` | Run the opt-in local behavioral drift review via `deep-review` |
402
+ | `--history` | With `deep-review --behavioral`, show behavioral snapshot history |
403
+ | `--compare` | With `deep-review --behavioral`, compare the latest two behavioral snapshots |
404
+ | `--diff-only` | Run a changed-file audit instead of a full repo audit |
405
+ | `--diff-base SHA` | Base SHA for `--diff-only` PR comparisons (defaults to CI env vars when present) |
406
+ | `--diff-head SHA` | Head SHA for `--diff-only` PR comparisons (defaults to `GITHUB_SHA` or `HEAD`) |
407
+ | `--dry-run` | Preview changes without writing files |
408
+ | `--config-only` | Only write config files, never source code |
409
+ | `--auto` | Apply without prompts |
410
+ | `--only A,B` | Limit apply to selected proposal IDs |
411
+ | `--format sarif` | SARIF output for code scanning |
412
+ | `--format markdown` | GitHub-flavoured PR-comment report |
413
+ | `--format junit` | JUnit XML for CI test reporters (GitHub Actions, Jenkins, GitLab) |
414
+ | `--format csv` | RFC 4180 CSV, one row per check |
415
+ | `--platform NAME` | Target platform (claude, codex, gemini, copilot, cursor, windsurf, aider, opencode) |
416
+ | `--workspace GLOB` | Audit workspaces separately as package-level live audits with summary-only JSON rows (e.g. packages/*) |
417
+ | `--external PATH` | Benchmark an external repo |
418
+
419
+ ### CI output formats
420
+
421
+ Pipe audit output straight into the standard CI surfaces:
422
+
423
+ ```bash
424
+ # PR comment (GitHub-flavoured markdown)
425
+ npx @nerviq/cli audit --format=markdown --out audit.md
426
+
427
+ # CI test report (JUnit XML — Jenkins, GitLab, GitHub Actions reporter)
428
+ npx @nerviq/cli audit --format=junit --out junit.xml
429
+
430
+ # Spreadsheet / dashboard ingestion (RFC 4180 CSV)
431
+ npx @nerviq/cli audit --format=csv --out audit.csv
432
+ ```
433
+
434
+ Webhook delivery automatically retries transient failures twice by default. For authenticated internal endpoints, you can add custom headers such as:
435
+
436
+ ```bash
437
+ npx @nerviq/cli audit \
438
+ --webhook https://ops.example.com/nerviq/audit \
439
+ --webhook-header "Authorization: Bearer $NERVIQ_WEBHOOK_TOKEN" \
440
+ --webhook-header "X-Nerviq-Environment: production" \
441
+ --webhook-retries 4
442
+ ```
443
+
444
+ Generic webhook endpoints now receive a stable `nerviq.audit.completed` event envelope with:
445
+
446
+ - backward-compatible top-level `platform`, `score`, `passed`, `failed`, and `results`
447
+ - nested `data` and `meta` blocks for new consumers
448
+ - schema versioning through `schemaVersion`
449
+
450
+ For PR-focused audits, you can scope Nerviq to the working tree or an explicit base/head range:
451
+
452
+ ```bash
453
+ npx @nerviq/cli audit --diff-only
454
+ npx @nerviq/cli audit --diff-only --diff-base origin/main --diff-head HEAD
455
+ ```
456
+
457
+ `--diff-only` is intentionally a scoped review surface. It reports a `diff-only changed-file audit` score, lists the changed files it considered, and reminds you to run a full `nerviq audit` for the complete repo posture. Because diff-only scores are not directly comparable to full audit history, Nerviq blocks `--diff-only --snapshot`.
458
+
459
+ For multi-repo governance, Nerviq also supports inherited policy layers:
460
+
461
+ - `.nerviq/org-policy.json` in an ancestor directory for org defaults
462
+ - `.nerviq/team-policy.json` in the repo for team overrides
463
+ - `.nerviq/repo-policy.json` in the repo for repo-specific overrides
464
+
465
+ Inspect the resolved contract with:
466
+
467
+ ```bash
468
+ npx @nerviq/cli org policy
469
+ npx @nerviq/cli org scan ./app ./api ./infra --json
470
+ ```
471
+
472
+ For opt-in outcome-layer inspection, Nerviq can also run a local behavioral drift review:
473
+
474
+ ```bash
475
+ npx @nerviq/cli deep-review --behavioral
476
+ npx @nerviq/cli deep-review --behavioral --snapshot --milestone baseline --tag "behavioral-baseline"
477
+ npx @nerviq/cli deep-review --behavioral --history
478
+ npx @nerviq/cli deep-review --behavioral --compare
479
+ ```
480
+
481
+ Behavioral drift mode is intentionally guarded:
482
+
483
+ - It analyzes repository structure and instruction-vs-outcome mismatch heuristics
484
+ - It does not claim agent attribution without explicit evidence
485
+ - It is not marketed as SAST, semantic code review, or runtime analysis
486
+
487
+ `nerviq setup` now seeds a trust-boundary section in `CLAUDE.md` and an `injection-defense` starter hook for `WebFetch`, `WebSearch`, `Read`, `Grep`, `Glob`, and MCP-backed external-content flows. `nerviq doctor` validates that the declared starter hook still runs and logs suspicious prompt-injection patterns correctly.
488
+
489
+ ## Backed by Research
490
+
491
+ Nerviq is built on the NERVIQ knowledge engine — the largest verified catalog of AI coding agent techniques:
492
+
493
+ - **540+ research documents** covering all 8 platforms
494
+ - **400+ experiments** with tested, rated results
495
+ - **2,441 checks** across 8 platforms (~300 unique governance rules × 8 platform adaptations), each with `sourceUrl` and `confidence` level (0.0-1.0)
496
+ - Every check is traceable to primary documentation or verified experiment
497
+ - **Freshness:** daily changelog scanning across all 8 platforms, weekly liveness sweep (6 automated checks), monthly quality review, quarterly cross-validation — items older than 90 days are confidence-weighted
498
+
499
+ ## Safety Modes
500
+
501
+ Nerviq provides explicit safety controls so you decide what it can touch:
502
+
503
+ | Mode | Flag | What it does |
504
+ |------|------|-------------|
505
+ | **Read-only** | `nerviq audit` | Reads files, writes nothing. Default command. |
506
+ | **Suggest-only** | `nerviq suggest-only` | Generates markdown report, no file writes. |
507
+ | **Dry-run** | `--dry-run` | Previews setup/fix/apply changes without writing. |
508
+ | **Config-only** | `--config-only` | Only writes config files (.claude/, rules, hooks). Never touches source code. |
509
+ | **Safe-write** | `--profile safe-write` | Default write profile. Creates new files, never overwrites existing ones. |
510
+ | **Power-user** | `--profile power-user` | Overwrites existing files (use with `--snapshot` for rollback). |
511
+
512
+ Every write command supports `--snapshot` for automatic backup before changes.
513
+
514
+ ## Privacy
515
+
516
+ - **Zero dependencies** — nothing to audit
517
+ - **Runs locally** — audit, setup, plan, apply, governance, benchmark all run on your machine
518
+ - **Deep review is opt-in** — `deep-review` sends selected config for AI analysis, while `deep-review --behavioral` stays local and uses heuristic outcome-layer analysis only
519
+ - **AGPL-3.0 Licensed**open source
520
+
521
+ ## Links
522
+
523
+ - **npm**: [@nerviq/cli](https://www.npmjs.com/package/@nerviq/cli)
524
+ - **GitHub**: [github.com/nerviq/nerviq](https://github.com/nerviq/nerviq)
525
+ - **Website**: [nerviq.net](https://nerviq.net)
526
+ - **Discord**: [Join the community](https://discord.gg/nerviq)
527
+
528
+ ---
529
+
530
+ If Nerviq helped you, consider giving it a ⭐ on [GitHub](https://github.com/nerviq/nerviq) — it helps others discover the project.
531
+
532
+ ## What Nerviq Is — and Isn't
533
+
534
+ **Best for:** Teams going from zero governance to a strong baseline — fast. If you're starting with AI coding agents or have a few platforms running without consistent configuration, Nerviq gets you to a governed setup quickly.
535
+
536
+ **Not designed for:** Deeply customized setups with 20+ skills, agent teams, and bespoke MCP integrations. If you've already built advanced agent workflows, you may not need this.
537
+
538
+ **Strongest at:** AI agent governance, configuration intelligence, workflow policy hygiene, cross-platform alignment, and setup standardization.
539
+
540
+ **Not a replacement for:** Deep architectural review of business logic, runtime performance profiling, full SAST coverage, secret scanning, or security penetration testing. Nerviq focuses on how your AI coding agents are configured and governed — not on what your application code does.
541
+
542
+ **Confidence levels:** Every check includes a `confidence` score (0.0–1.0) and a `sourceUrl` linking to primary documentation. Checks marked `heuristic` are pattern-based and may produce false positives on non-standard project structures.
543
+
544
+ **Feature maturity:**
545
+
546
+ | Label | Meaning |
547
+ |-------|---------|
548
+ | `GA` | Stable, tested on real repos, safe for production use |
549
+ | `BETA` | Works but has limited real-world testing. API may change |
550
+ | `EXPERIMENTAL` | Early stage, static rules, results may vary |