@stacknext/cli 0.8.0 → 0.10.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.
@@ -0,0 +1,192 @@
1
+ ---
2
+ title: Commands
3
+ description: Complete reference for the stacknext CLI commands and options.
4
+ ---
5
+
6
+ # Commands
7
+
8
+ Run `stacknext <command> --help` for the installed version's exact flags. All
9
+ commands run from a Next.js application directory unless stated otherwise.
10
+
11
+ ## `stacknext init`
12
+
13
+ Configure a project. Writes `stacknext.config.json` and generated
14
+ `instrumentation.ts`/`.js` only when absent; never overwrites user files.
15
+
16
+ | Option | Meaning |
17
+ | --- | --- |
18
+ | `--install` | Install `@stacknext/next` with the detected package manager. |
19
+ | `--agents` | Add or update the managed StackNext block in `AGENTS.md`. |
20
+ | `--skip-agents` | Explicitly skip the managed block (the default). |
21
+
22
+ ## `stacknext dev`
23
+
24
+ Start the loopback collector and dashboard, then run the app's `dev` script.
25
+
26
+ | Option | Meaning |
27
+ | --- | --- |
28
+ | `--open` | Open the dashboard in the default browser. |
29
+ | `--quiet` | Reduce startup output. |
30
+ | `--token <token>` | Use an existing token (16+ characters). |
31
+
32
+ `dev` writes `.stacknext/run.json` with mode `0600` and removes it on graceful
33
+ shutdown. Stop it with SIGINT/SIGTERM, not `SIGKILL`.
34
+
35
+ ## `stacknext status`
36
+
37
+ Print the runtime, collector connection and current counts.
38
+
39
+ | Option | Meaning |
40
+ | --- | --- |
41
+ | `--json` | Machine-readable output. |
42
+
43
+ ## `stacknext doctor`
44
+
45
+ Check Node.js, Next.js, the App Router, config, instrumentation, adapters,
46
+ dashboard build, runtime file permissions and collector health.
47
+
48
+ | Option | Meaning |
49
+ | --- | --- |
50
+ | `--json` | Machine-readable result with `checks`, `failures`, `warnings`. |
51
+
52
+ Exit code is `1` when a check fails.
53
+
54
+ ## `stacknext coverage`
55
+
56
+ Show what the current retention window observed. Evidence, not a score.
57
+
58
+ | Option | Meaning |
59
+ | --- | --- |
60
+ | `--json` | Machine-readable `CoverageReport`. |
61
+
62
+ ## `stacknext diagnose`
63
+
64
+ List deterministic findings or show one finding.
65
+
66
+ | Option | Meaning |
67
+ | --- | --- |
68
+ | `--id <finding-id>` | Show one finding and its related trace. |
69
+ | `--trace-id <trace-id>` | Findings that reference a trace. |
70
+ | `--category <category>` | `database`, `http`, `performance`, `errors`, `runtime`. |
71
+ | `--severity <severity>` | `info`, `warning`, `error`. |
72
+ | `--status <status>` | `observed`, `possible`, `insufficient-evidence`. |
73
+ | `--rule <rule-id>` | One of the six rule ids. |
74
+ | `--route <route>` | Route substring. |
75
+ | `--since <time>` / `--until <time>` | ISO timestamp or epoch ms. |
76
+ | `--limit <n>` / `--offset <n>` | Pagination. |
77
+ | `-q, --q <text>` | Search text. |
78
+ | `--json` | Machine-readable output. |
79
+
80
+ ## `stacknext capture`
81
+
82
+ Run a test command and save correlated telemetry as a run.
83
+
84
+ ```bash
85
+ stacknext capture --name baseline -- pnpm exec playwright test --workers=1
86
+ ```
87
+
88
+ | Option | Meaning |
89
+ | --- | --- |
90
+ | `--name <name>` | Run name. |
91
+ | `--project <name>` | Project name override. |
92
+ | `--attach` | Require an existing `stacknext dev` collector. |
93
+ | `--url <url>` | Attach to a specific loopback collector. |
94
+ | `--token <token>` | Token for `--url`. |
95
+ | `--json` | Machine-readable result. |
96
+ | `--quiet` | Reduce output. |
97
+
98
+ A successful child with incomplete telemetry exits `3`.
99
+
100
+ ## `stacknext runs`
101
+
102
+ | Command | Options | Purpose |
103
+ | --- | --- | --- |
104
+ | `runs list` | `--limit`, `--offset`, `--json` | List live and saved runs. |
105
+ | `runs show <run-id>` | `--json` | Show one run and its samples. |
106
+
107
+ ## `stacknext baseline`
108
+
109
+ | Command | Options | Purpose |
110
+ | --- | --- | --- |
111
+ | `baseline save <run-id>` | `--name <name>`, `--notes <text>`, `--overwrite`, `--json` | Save a completed run. |
112
+ | `baseline list` | `--limit`, `--offset`, `--json` | List baselines. |
113
+ | `baseline show <baseline-id>` | `--json` | Show one baseline. |
114
+ | `baseline remove <baseline-id>` | `--yes`, `--json` | Permanently remove one baseline. |
115
+
116
+ `--name` is required. Only a completed run can become a baseline.
117
+
118
+ ## `stacknext compare`
119
+
120
+ ```bash
121
+ stacknext compare <baseline-id> <candidate-run-id>
122
+ ```
123
+
124
+ | Option | Meaning |
125
+ | --- | --- |
126
+ | `--json` | Machine-readable result. |
127
+ | `--ignore-environment` | Compare despite environment differences (warning retained). |
128
+ | `--min-samples <n>` | Minimum verified samples per side (default 3). |
129
+ | `--duration-regression-pct <n>` | Default 20. |
130
+ | `--duration-regression-ms <n>` | Default 25. |
131
+ | `--duration-improvement-pct <n>` | Default 20. |
132
+ | `--duration-improvement-ms <n>` | Default 25. |
133
+ | `--count-regression-min <n>` | Default 1. |
134
+ | `--fail-on <status>` | Exit 1 for `regression`, `inconclusive` or `any`. |
135
+ | `--no-save` | Do not persist the comparison. |
136
+
137
+ Comparisons are report-only by default. `inconclusive` is not a pass.
138
+
139
+ ## `stacknext snapshot`
140
+
141
+ | Command | Options | Purpose |
142
+ | --- | --- | --- |
143
+ | `snapshot save` | `--label`, `--json` | Freeze the current sample. |
144
+ | `snapshot list` | `--limit`, `--offset`, `--json` | List snapshots. |
145
+ | `snapshot show <id>` | `--json` | Show a summary or full payload. |
146
+ | `snapshot export <id>` | `-o, --output`, `--stdout`, `--force` | Export redacted JSON. |
147
+ | `snapshot import <file>` | `--label`, `--json` | Import and re-redact. |
148
+ | `snapshot delete <id>` | `--yes`, `--json` | Delete one snapshot. |
149
+
150
+ `snapshots` is an alias for `snapshot`.
151
+
152
+ ## `stacknext export`
153
+
154
+ | Option | Meaning |
155
+ | --- | --- |
156
+ | `-o, --output <file>` | Output path. |
157
+ | `--stdout` | Write JSON to stdout. |
158
+ | `--force` | Overwrite an existing output file. |
159
+
160
+ ## `stacknext mcp`
161
+
162
+ Start the read-only stdio MCP server.
163
+
164
+ | Option | Meaning |
165
+ | --- | --- |
166
+ | `--collector <url>` | Collector URL (defaults to runtime state). |
167
+ | `--token <token>` | Bearer token (defaults to runtime state). |
168
+
169
+ ## `stacknext skill`
170
+
171
+ | Command | Options | Purpose |
172
+ | --- | --- | --- |
173
+ | `skill path` | `--json` | Print the bundled skill directory and version. |
174
+ | `skill install` | `--client opencode\|codex\|claude-code`, `--dir`, `--force`, `--json` | Copy the skill into a project. |
175
+
176
+ ## `stacknext uninstall`
177
+
178
+ Print a removal plan unless `--yes` is passed.
179
+
180
+ | Option | Meaning |
181
+ | --- | --- |
182
+ | `--yes` | Apply the plan. |
183
+ | `--keep-config` | Preserve `stacknext.config.json`. |
184
+ | `--remove-data` | Remove `.stacknext` saved data (refused while running). |
185
+ | `--json` | Machine-readable report. |
186
+
187
+ ## Global
188
+
189
+ ```bash
190
+ stacknext --version
191
+ stacknext --help
192
+ ```
@@ -0,0 +1,100 @@
1
+ ---
2
+ title: Configuration
3
+ description: stacknext.config.json, runtime state, ports and environment variables.
4
+ ---
5
+
6
+ # Configuration
7
+
8
+ ## Project config
9
+
10
+ `stacknext init` creates `stacknext.config.json` at the application root. The
11
+ full schema, defaults and validation rules live in
12
+ the `@stacknext/core` package's `docs/configuration.md` (follow its relative path
13
+ in `packages.md`).
14
+
15
+ Minimal generated example:
16
+
17
+ ```json
18
+ {
19
+ "projectName": "my-app",
20
+ "dashboard": { "port": 4400 },
21
+ "collector": { "maxSpans": 5000, "retentionMs": 600000 },
22
+ "instrumentation": { "verbose": false, "captureFetch": true, "captureErrors": true },
23
+ "privacy": {
24
+ "captureHeaders": false,
25
+ "captureRequestBodies": false,
26
+ "captureSqlParameters": false,
27
+ "redactSensitiveData": true
28
+ },
29
+ "database": { "drizzle": false, "prisma": false },
30
+ "slowRequestMs": 500
31
+ }
32
+ ```
33
+
34
+ Missing fields are filled with defaults when loaded. Unknown fields are
35
+ rejected. Privacy capture flags must remain `false` and redaction must remain
36
+ `true`.
37
+
38
+ ## Runtime state
39
+
40
+ While `stacknext dev` runs:
41
+
42
+ ```text
43
+ .stacknext/
44
+ ├── .gitignore
45
+ ├── run.json # mode 0600, contains the bearer token
46
+ ├── snapshots/
47
+ ├── runs/
48
+ ├── baselines/
49
+ └── comparisons/
50
+ ```
51
+
52
+ `run.json` is written on startup and removed on graceful shutdown. If a process
53
+ is killed, the file can be stale; `stacknext doctor` detects a dead pid. Never
54
+ commit or share `run.json`.
55
+
56
+ `.stacknext` is created with mode `0700`; saved records use `0600`.
57
+
58
+ ## Ports
59
+
60
+ - Preferred dashboard/collector port: 4400.
61
+ - If busy, StackNext tries the next 25 ports.
62
+ - The example app listens on 4402 by default.
63
+
64
+ The collector binds only to `127.0.0.1` or `localhost` and rejects non-loopback
65
+ `Host` headers.
66
+
67
+ ## Environment variables
68
+
69
+ | Variable | Used by | Meaning |
70
+ | --- | --- | --- |
71
+ | `STACKNEXT_COLLECTOR_URL` | app, Playwright | Loopback collector URL. |
72
+ | `STACKNEXT_TOKEN` | app, capture | Bearer token. |
73
+ | `STACKNEXT_PROJECT_NAME` | app | Project name. |
74
+ | `STACKNEXT_SERVICE_NAME` | app | OTel service name. |
75
+ | `STACKNEXT_NEXT_VERSION` | app | Next.js version for environment checks. |
76
+ | `STACKNEXT_CAPTURE_FETCH` | app | `0` drops fetch spans. |
77
+ | `STACKNEXT_CAPTURE_ERRORS` | app | `0` disables error collection. |
78
+ | `STACKNEXT_DEBUG` | app, CLI | `1` enables debug logs. |
79
+ | `NEXT_OTEL_VERBOSE` | app | `1` enables documented verbose Next.js spans. |
80
+ | `STACKNEXT_TEST_RUN_ID` | Playwright | Active run id. |
81
+ | `STACKNEXT_CAPTURE_SETTLE_MS` | Playwright | Probe delay (default 500). |
82
+ | `STACKNEXT_CAPTURE_TIMEOUT_MS` | Playwright | Probe timeout (default 5000). |
83
+ | `STACKNEXT_PACK_DIR` | release scripts | Archive output directory. |
84
+
85
+ `stacknext dev` exports the first group to the Next.js child process. An
86
+ explicit value wins over the config; for example `NEXT_OTEL_VERBOSE=0` disables
87
+ verbose tracing even when `instrumentation.verbose` is `true`.
88
+
89
+ ## Config ownership
90
+
91
+ - `stacknext dev` reads and validates the config.
92
+ - `stacknext doctor` reports invalid fields with issue paths.
93
+ - `stacknext uninstall` removes the config unless `--keep-config` is passed.
94
+ - Regression and snapshots record the resolved config with their evidence.
95
+
96
+ ## Related
97
+
98
+ - [@stacknext/core configuration](../../core/docs/configuration.md)
99
+ - [Agent setup](agent-setup.md)
100
+ - [Troubleshooting](troubleshooting.md)
package/docs/index.md ADDED
@@ -0,0 +1,142 @@
1
+ ---
2
+ title: StackNext local documentation
3
+ description: Entry point and package index for the version-matched StackNext documentation installed with @stacknext/cli.
4
+ ---
5
+
6
+ # StackNext local documentation
7
+
8
+ This directory ships inside the installed `@stacknext/cli` package. It is the
9
+ fastest way for a developer or coding agent to find documentation that matches
10
+ the installed StackNext version, without network access.
11
+
12
+ ## Start here
13
+
14
+ 1. Read [commands](commands.md) for the CLI surface.
15
+ 2. Read [configuration](configuration.md) for `stacknext.config.json`.
16
+ 3. Read [agent setup](agent-setup.md) when configuring an AI client.
17
+ 4. Read the package document for every package involved in the task.
18
+
19
+ The generated [package index](packages.md) lists the documented packages, their
20
+ versions, their role and the path to each package's own documentation.
21
+
22
+ ## Version matching
23
+
24
+ <!-- coderabbit-ai-generated:v1 -->
25
+
26
+ <!-- coderabbit-ai-generated-section:v1:e6af214d2a4b32adab7521d25e5832f83653a892caaf39c3eddbd1f46461e7a6 -->
27
+
28
+ Packages currently shipping a `docs/` directory include package-specific
29
+ documentation in the same npm archive as their code. That documentation
30
+ therefore matches the installed version by construction.
31
+
32
+ <!-- /coderabbit-ai-generated:v1 -->
33
+
34
+ Check a version before relying on an API:
35
+
36
+ ```bash
37
+ node -p "require('@stacknext/next/package.json').version"
38
+ ```
39
+
40
+ Read the `package.json` next to the package's `docs/` directory. Do not assume
41
+ that this documentation matches a different release or the project's main
42
+ branch.
43
+
44
+ ## Locating package documentation
45
+
46
+ <!-- coderabbit-ai-generated:v1 -->
47
+
48
+ <!-- coderabbit-ai-generated-section:v1:e89f29adfff1f8925389640671146bfdf24816a645149772ceb1d2ad0c5288cd -->
49
+
50
+ Package docs ship inside installed packages that currently include a `docs/` directory. Start from this CLI `docs/`
51
+ directory and use the relative paths in the generated
52
+ [package index](packages.md), because optional and internal packages may not sit
53
+ at the app's root `node_modules` path.
54
+
55
+ <!-- /coderabbit-ai-generated:v1 -->
56
+
57
+ Direct integration packages are normally at the app root when installed there:
58
+
59
+ ```text
60
+ node_modules/@stacknext/cli/docs/index.md
61
+ node_modules/@stacknext/next/docs/index.md
62
+ node_modules/@stacknext/drizzle/docs/index.md
63
+ node_modules/@stacknext/prisma/docs/index.md
64
+ node_modules/@stacknext/playwright/docs/index.md
65
+ ```
66
+
67
+ <!-- coderabbit-ai-generated:v1 -->
68
+
69
+ <!-- coderabbit-ai-generated-section:v1:a2a2d1bacf1a7101a5884977852db99861650a2a201f6dffdf985fa4ec246abe -->
70
+
71
+ `@stacknext/core` and `@stacknext/regression` are installed through the CLI
72
+ and ship documentation. In a pnpm workspace, locate their docs using the
73
+ relative paths listed in `packages.md`. The CLI also installs
74
+ `@stacknext/diagnostics`, `@stacknext/mcp` and `@stacknext/dashboard`, which
75
+ do not currently ship `docs/` directories.
76
+
77
+ <!-- /coderabbit-ai-generated:v1 -->
78
+
79
+ If neither the direct path nor the relative index path exists, the package is
80
+ not available to this project. Do not invent its documentation path or assume
81
+ its APIs are available.
82
+
83
+ ## Which package to read
84
+
85
+ <!-- coderabbit-ai-generated:v1 -->
86
+
87
+ <!-- coderabbit-ai-generated-section:v1:cce8643ce7fa90852e67d36250d2daa286bf00bf29c08506b2ca194409f5b5a8 -->
88
+
89
+ <!-- coderabbit-ai-generated:v1 -->
90
+
91
+ <!-- coderabbit-ai-generated-section:v1:4ccde9b676836098da0c0e0810b43c6306a967030d387f11f30aed3a2b950eab -->
92
+
93
+ | Task | Read |
94
+ | --- | --- |
95
+ | Install, configure or run StackNext | `cli`, `next` |
96
+ | Change `instrumentation.ts` or manual spans | `next` |
97
+ | Work with shared types, redaction, transport or snapshots | `core` |
98
+ | Change or interpret diagnostic findings | CLI [commands](commands.md) |
99
+ | Work with Playwright capture, baselines or comparisons | `playwright`, `regression` |
100
+ | Add Drizzle query evidence | `drizzle` |
101
+ | Add Prisma query evidence | `prisma` |
102
+ | Configure an MCP client or use runtime evidence | CLI [agent setup](agent-setup.md) |
103
+
104
+ <!-- /coderabbit-ai-generated:v1 -->
105
+
106
+ <!-- /coderabbit-ai-generated:v1 -->
107
+
108
+ ## Optional and internal packages
109
+
110
+ <!-- coderabbit-ai-generated:v1 -->
111
+
112
+ <!-- coderabbit-ai-generated-section:v1:a2dd9b11290d93c4f272aa68aa40252cdb2bb1e42b5f87e52a85da57d3345086 -->
113
+
114
+ - **Public integration packages:** `@stacknext/cli`, `@stacknext/next`,
115
+ `@stacknext/playwright`, `@stacknext/drizzle`, `@stacknext/prisma`.
116
+ - **Installed by the CLI:** `@stacknext/core`, `@stacknext/diagnostics`,
117
+ `@stacknext/regression`, `@stacknext/mcp`, `@stacknext/dashboard`.
118
+ - Optional packages are only present when the project installed them. Never
119
+ instruct an agent to read a package directory that is not installed.
120
+ - Internal packages that ship `docs/` are documented for maintainers;
121
+ applications should not install them directly.
122
+
123
+ <!-- /coderabbit-ai-generated:v1 -->
124
+
125
+ ## Rules for coding agents
126
+
127
+ - Prefer this local documentation over model memory or online documentation for
128
+ the installed version.
129
+ - Verify the package version before using an API or example.
130
+ - Do not assume undocumented exports, configuration keys or integrations exist.
131
+ - For runtime investigation, use the StackNext MCP tools where available.
132
+ - Follow the installed `stacknext-debugging` Agent Skill for evidence-first
133
+ workflows.
134
+ - Treat diagnostic findings as evidence, not confirmed root causes.
135
+ - Treat `inconclusive` regression comparisons as inconclusive, not passes.
136
+
137
+ ## More documentation
138
+
139
+ - [Agent setup](agent-setup.md) — `stacknext init --agents`, MCP and skills.
140
+ - [Skill installation](skill.md) — supported clients and paths.
141
+ - [Troubleshooting](troubleshooting.md) — missing telemetry, ports and clients.
142
+ - [Package index](packages.md) — generated list of installed package docs.
@@ -0,0 +1,71 @@
1
+ ---
2
+ title: Installed package documentation
3
+ description: Generated index of the documented StackNext packages and their local documentation paths.
4
+ ---
5
+
6
+ <!-- Generated by scripts/sync-docs.mjs. Do not edit this file. -->
7
+
8
+ # Installed package documentation
9
+
10
+ This index is generated from the packages that ship documentation. It does
11
+ not mean every package is installed in a project. Check the path before
12
+ reading: optional packages can be absent.
13
+
14
+ Versions in this table are the versions of the package that produced this
15
+ archive. Read the `version` field in the package.json next to the docs
16
+ directory to confirm the installed version.
17
+
18
+ | Package | Version | Visibility | Role | Documentation |
19
+ | --- | --- | --- | --- | --- |
20
+ | `@stacknext/cli` | 0.10.0 | public | CLI, collector and dashboard host | `index.md` |
21
+ | `@stacknext/next` | 0.10.0 | public | Next.js instrumentation | `../../next/docs/index.md` |
22
+ | `@stacknext/core` | 0.10.0 | internal | Shared base package | `../../core/docs/index.md` |
23
+ | `@stacknext/diagnostics` | 0.10.0 | internal | Diagnostic engine | `@stacknext/diagnostics/docs/index.md (resolve from CLI)` |
24
+ | `@stacknext/regression` | 0.10.0 | internal | Regression data model | `../../regression/docs/index.md` |
25
+ | `@stacknext/playwright` | 0.10.0 | public | Playwright fixture | `../../playwright/docs/index.md` |
26
+ | `@stacknext/drizzle` | 0.10.0 | public | Database adapter | `../../drizzle/docs/index.md` |
27
+ | `@stacknext/prisma` | 0.10.0 | public | Database adapter | `../../prisma/docs/index.md` |
28
+ | `@stacknext/mcp` | 0.10.0 | internal | Read-only MCP server | `@stacknext/mcp/docs/index.md (resolve from CLI)` |
29
+ | `@stacknext/dashboard` | 0.10.0 | internal | Static dashboard | `@stacknext/dashboard/docs/index.md (resolve from CLI)` |
30
+
31
+ ## How to use this index
32
+
33
+ Starting from `node_modules/@stacknext/cli/docs/`, read `index.md`. For every
34
+ other package with a relative path, use the table. For example:
35
+
36
+ ```text
37
+ node_modules/@stacknext/cli/docs/index.md
38
+ ../../next/docs/index.md # from node_modules/@stacknext/cli/docs/
39
+ ```
40
+
41
+ Do not assume an internal package is at the app-root `node_modules` path.
42
+ For diagnostics, MCP and dashboard, resolve the package from the installed
43
+ CLI so the docs match its dependency version, including hoisted installs.
44
+ Run this from the project directory:
45
+
46
+ ```js
47
+ const { createRequire } = require('node:module')
48
+ const { dirname, join } = require('node:path')
49
+ const cliRequire = createRequire(require.resolve('@stacknext/cli/package.json'))
50
+ for (const name of ['@stacknext/diagnostics', '@stacknext/mcp', '@stacknext/dashboard']) {
51
+ console.log(join(dirname(cliRequire.resolve(`${name}/package.json`)), 'docs', 'index.md'))
52
+ }
53
+ ```
54
+
55
+ If resolution fails, the dependency is unavailable. Do not instruct an
56
+ agent to read a missing package directory.
57
+
58
+ ## Public, optional and internal packages
59
+
60
+ - **Public integration packages** are intended for direct installation when
61
+ the project uses the corresponding feature.
62
+ - **Internal packages** are installed as dependencies of the CLI or another
63
+ package. Their docs are for maintainers and advanced contributors.
64
+ - Optional packages (`@stacknext/playwright`, `@stacknext/drizzle` and
65
+ `@stacknext/prisma`) are only present when explicitly installed.
66
+
67
+ ## Related
68
+
69
+ - `index.md` — local documentation entry point.
70
+ - `agent-setup.md` — managed AGENTS.md, MCP and skill setup.
71
+ - `commands.md` — CLI reference.
package/docs/skill.md ADDED
@@ -0,0 +1,75 @@
1
+ ---
2
+ title: Agent Skill
3
+ description: The bundled stacknext-debugging skill, supported clients and installation behavior.
4
+ ---
5
+
6
+ # Agent Skill
7
+
8
+ `@stacknext/cli` ships the portable Agent Skill at:
9
+
10
+ ```text
11
+ node_modules/@stacknext/cli/skills/stacknext-debugging/
12
+ ├── SKILL.md
13
+ └── references/
14
+ ├── documentation.md
15
+ ├── setup.md
16
+ ├── tools.md
17
+ └── workflows.md
18
+ ```
19
+
20
+ The repository's `skills/stacknext-debugging/` directory is the canonical
21
+ source. It is copied into the CLI archive before packing.
22
+
23
+ ## What it covers
24
+
25
+ - local documentation discovery and version checks;
26
+ - the twenty read-only MCP tools;
27
+ - evidence-first workflows for errors, slow requests, database activity,
28
+ diagnostic findings, regression records and snapshots;
29
+ - mandatory reasoning rules: observation versus causation, null durations,
30
+ overlapping spans, coverage gaps, `inconclusive` comparisons and the
31
+ difference between a snapshot and live telemetry.
32
+
33
+ The skill does not duplicate full package API references. It points to the
34
+ installed package docs for those.
35
+
36
+ ## Commands
37
+
38
+ ```bash
39
+ stacknext skill path
40
+ stacknext skill path --json
41
+ stacknext skill install --client opencode
42
+ stacknext skill install --client codex
43
+ stacknext skill install --client claude-code
44
+ stacknext skill install --client codex --dir ./apps/my-app
45
+ stacknext skill install --client codex --force
46
+ ```
47
+
48
+ ## Behavior
49
+
50
+ - `skill path` prints the bundled directory, or `{ path, version }` with
51
+ `--json`.
52
+ - `skill install` copies the whole directory into the client's project path.
53
+ - An existing destination is not replaced without `--force`; the command exits
54
+ `1` and reports the path.
55
+ - `--dir` selects the project root; it defaults to the current directory.
56
+ - Unsupported clients throw with the three supported names.
57
+
58
+ ## Version alignment
59
+
60
+ `SKILL.md` frontmatter contains `metadata.version`, which must equal the
61
+ StackNext package version. The release workflow and package archive validation
62
+ enforce this. The repository skill is updated by the release preparation script
63
+ along with package versions.
64
+
65
+ ## Portable format
66
+
67
+ `SKILL.md` follows the Agent Skills specification with YAML frontmatter and a
68
+ concise body. Details live in `references/`. Keep it portable: no
69
+ client-specific syntax in the canonical skill and no claim of support without a
70
+ recorded test in `docs/agent-testing.md`.
71
+
72
+ ## Client paths
73
+
74
+ See [Agent setup](agent-setup.md) for the project paths and the recommended
75
+ installation order.
@@ -0,0 +1,84 @@
1
+ ---
2
+ title: Troubleshooting
3
+ description: Fix missing telemetry, port conflicts, stale runtime state, MCP and agent setup problems.
4
+ ---
5
+
6
+ # Troubleshooting
7
+
8
+ ## Start with doctor
9
+
10
+ ```bash
11
+ stacknext doctor
12
+ stacknext doctor --json
13
+ ```
14
+
15
+ It checks Node.js, Next.js, the App Router, configuration, instrumentation,
16
+ adapters, dashboard build, runtime file permissions and collector health. It
17
+ exits `1` when a check fails.
18
+
19
+ ## Dashboard is empty
20
+
21
+ 1. Confirm you started the app with `stacknext dev`, not `next dev`.
22
+ 2. Make a request after the app is ready.
23
+ 3. Run `stacknext status --json` and check `runtime` and `connections`.
24
+ 4. Run `stacknext coverage`. `active` means connected but not exercised;
25
+ `configured` means no app is connected.
26
+ 5. Inspect `instrumentation.ts` and the app logs with `STACKNEXT_DEBUG=1`.
27
+
28
+ ## Port already in use
29
+
30
+ The dashboard prefers 4400 and tries the next 25 ports. Check the URL printed by
31
+ `stacknext dev`. The example app uses 4402 by default. Stop orphaned `next dev`
32
+ processes on ports 4400–4425 before restarting.
33
+
34
+ ## Stale `.stacknext/run.json`
35
+
36
+ If `stacknext dev` crashes or is killed, `doctor` reports a stale pid. Restart
37
+ `stacknext dev`; it replaces the state. Do not reuse or share the token.
38
+
39
+ ## Stop the server cleanly
40
+
41
+ Send SIGINT or SIGTERM to `stacknext dev`. It closes the collector, stops the
42
+ app child and removes `.stacknext/run.json`. `SIGKILL` skips cleanup and can
43
+ leave the state file behind.
44
+
45
+ ## MCP client cannot connect
46
+
47
+ - Start `stacknext dev` before the client starts the server.
48
+ - Run `stacknext mcp` from the app directory, or pass `--collector` and
49
+ `--token`.
50
+ - Ensure stdout is not mixed with logs. The server writes logs to stderr.
51
+ - Check that the collector URL is loopback. Remote URLs are rejected.
52
+ - Restart the client after changing its MCP configuration.
53
+
54
+ ## `stacknext init --agents` fails
55
+
56
+ - If `AGENTS.md` contains only one of the two markers, the command refuses to
57
+ guess and leaves the file unchanged. Restore or remove the partial block.
58
+ - Check file permissions.
59
+ - `--skip-agents` skips the operation; it is the default when `--agents` is not
60
+ passed.
61
+
62
+ ## Skill installation refuses to overwrite
63
+
64
+ The destination already exists. Review it, then use `--force` to replace it, or
65
+ choose another project directory with `--dir`.
66
+
67
+ ## Capture exits 3
68
+
69
+ The test command succeeded but telemetry correlation is incomplete. Inspect
70
+ `stacknext runs show <run-id> --json` and the sample reasons. Do not interpret
71
+ the run as a pass. See
72
+ `node_modules/@stacknext/playwright/docs/troubleshooting.md`.
73
+
74
+ ## Verbose tracing is slower
75
+
76
+ `NEXT_OTEL_VERBOSE=1` adds spans and dev-server work. Use it for short
77
+ investigations, not permanently. Set `NEXT_OTEL_VERBOSE=0` to override
78
+ `instrumentation.verbose: true`.
79
+
80
+ ## Package versions do not match
81
+
82
+ Run `stacknext --version` and compare all `@stacknext/*` entries in the lockfile.
83
+ All ten packages are released at one version. Mismatched versions are
84
+ unsupported.