debugsk 0.0.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.
@@ -0,0 +1,80 @@
1
+ ---
2
+ name: code-debug-skill
3
+ description: Standardized, hypothesis-driven debug investigation workflow for unexpected behavior, regressions, incidents, flaky tests, or production issues. Use to plan instrumentation, reproduce with decisive signals, compare runs, and narrow root cause without assuming any vendor or infrastructure.
4
+ ---
5
+
6
+ # Bug Investigation Skill
7
+
8
+ ## Investigation mindset (how to think)
9
+ - Treat facts as primary. Separate observations from inferences at all times.
10
+ - Keep multiple competing hypotheses and rank them by likelihood and impact.
11
+ - For each hypothesis, define:
12
+ - prediction (what must be observed if true),
13
+ - falsifier (what would disprove it),
14
+ - required instrumentation (what to measure or log).
15
+ - Prefer decisive signals over narratives. Do not ask for reproduction without a plan to capture evidence.
16
+ - Narrow with comparisons (fail vs pass) and a binary-search style approach when possible.
17
+ - Make the smallest change that increases observability. Avoid speculative fixes.
18
+
19
+ ## Tool selection (what to use)
20
+ - Primary tool for new instrumentation: local HTTP ingest logger.
21
+ - Start via `npx debugsk@latest server start --json`.
22
+ - Use the JSON output to copy the snippet and endpoint.
23
+ - The server accepts CORS preflight (OPTIONS), so the default JSON snippet works across origins.
24
+ - If reproduction is possible, prioritize logs/metrics that directly test predictions.
25
+ - If reproduction is not possible, pivot to existing signals:
26
+ - logs/metrics/traces, config diffs, data snapshots, dumps, and deterministic probes.
27
+ - If native signals do not answer the question, prefer `debugsk` for new observations.
28
+ - This avoids contaminating native logging and keeps investigation logs isolated.
29
+ - Use native logs as reference in addition to new instrumentation.
30
+
31
+ ## Operating principles
32
+ - Separate facts (observed) from hypotheses (inferred).
33
+ - Maintain multiple competing hypotheses until evidence eliminates them.
34
+ - For each hypothesis, define predictions, falsifiers, and required instrumentation.
35
+ - Do not ask for reproduction until an instrumentation plan is ready.
36
+
37
+ ## Core loop
38
+ 1. Clarify the bug precisely:
39
+ - Environment (local/staging/production), version/commit, frequency, impact.
40
+ - Minimal reproduction steps, expected vs actual, errors and timestamps.
41
+ 2. Identify candidate code paths:
42
+ - Search by endpoint/route/feature/config key/error text.
43
+ - Map request → handler → data/dependencies.
44
+ 3. Generate at least three hypotheses:
45
+ - Client/input, server logic, data/state, concurrency, config, dependency, resource.
46
+ 4. Instrument to validate hypotheses:
47
+ - Add logs/metrics at decision points and boundaries.
48
+ - Include correlation keys (sessionId/runId/hypothesisId + requestId/traceId if available).
49
+ 5. Execute controlled reproduction:
50
+ - Provide a short checklist and exact steps.
51
+ - Capture logs for the run.
52
+ 6. Analyze logs and narrow:
53
+ - Compare successful vs failing runs.
54
+ - Prefer binary search-style narrowing when possible.
55
+ 7. Iterate until root cause is confirmed.
56
+
57
+ ## Instrumentation policy
58
+ - Prefer a local HTTP ingest logger when available; otherwise integrate with existing logging.
59
+ - If native signals are insufficient, prioritize `debugsk` over adding more native logs.
60
+ - Use native logs as reference alongside the added instrumentation.
61
+ - Logs must never throw, avoid secrets/PII, and be easy to remove.
62
+ - Record location, message, timestamp, and correlation fields in every event.
63
+ - Do not guard instrumentation behind environment flags. Write logs for the investigation, then remove them after completion.
64
+ - AI inserts instrumentation and provides the exact reproduction steps; the user performs the reproduction run and shares the resulting logs.
65
+
66
+ ## User interaction rules
67
+ - When reproduction is required, provide exact steps, expected signals, and required artifacts.
68
+ - If reproduction is not possible, pivot to existing logs, metrics, traces, config diffs, or safe probes.
69
+
70
+ ## Cleanup policy
71
+ - When the user confirms the issue is resolved or the investigation is closed, stop the debug server and delete all investigation logs (e.g., `.logs/`).
72
+ - Do not use `git checkout`, `git clean`, or other bulk git cleanup for log deletion. Remove files explicitly and safely.
73
+ - If deletion could affect unrelated files, confirm the exact paths before removal.
74
+
75
+ ## Reporting format
76
+ Use the template in `assets/report-template.md`.
77
+
78
+ ## References
79
+ - Use `references/logging-schema.md` when adding or validating instrumentation.
80
+ - Use `references/hypothesis-template.md` to structure hypotheses and predictions.
@@ -0,0 +1,19 @@
1
+ # Investigation Summary
2
+ - Impact:
3
+ - Confidence:
4
+
5
+ # Facts (observed)
6
+
7
+ # Hypotheses
8
+
9
+ # Instrumentation Plan
10
+
11
+ # Reproduction Checklist
12
+
13
+ # Findings (log-backed)
14
+
15
+ # Root Cause (if confirmed)
16
+
17
+ # Next Actions (if not confirmed)
18
+
19
+ # Fix Plan + Tests
@@ -0,0 +1,26 @@
1
+ # Hypothesis Template
2
+
3
+ Use this structure for each hypothesis.
4
+
5
+ ```
6
+ Hypothesis ID: H1
7
+ Statement: <short, testable claim>
8
+
9
+ Predictions (if true):
10
+ - <observable signal in logs/metrics>
11
+ - <observable signal in logs/metrics>
12
+
13
+ Falsifiers (if false):
14
+ - <what would disprove it>
15
+
16
+ Instrumentation needed:
17
+ - <location + event name + fields>
18
+ - <location + event name + fields>
19
+
20
+ Reproduction steps:
21
+ - <step 1>
22
+ - <step 2>
23
+
24
+ Expected log queries:
25
+ - <grep/filter examples>
26
+ ```
@@ -0,0 +1,37 @@
1
+ # Logging Schema (Minimal Standard)
2
+
3
+ Use this schema when instrumenting. Keep fields small, structured, and correlated.
4
+
5
+ ## Required fields
6
+ - `timestamp`: ms epoch or ISO-8601 string
7
+ - `message`: short, human-readable message
8
+ - `sessionId`: investigation session identifier
9
+ - `runId`: single reproduction run identifier
10
+ - `hypothesisId`: hypothesis identifier (e.g. "H1")
11
+
12
+ ## Recommended fields
13
+ - `location`: file:line or function name
14
+ - `level`: debug/info/warn/error
15
+ - `data`: arbitrary JSON payload
16
+ - `traceId` / `requestId` / `spanId`: use existing correlation IDs when available
17
+
18
+ ## Example event
19
+ ```json
20
+ {
21
+ "timestamp": 1730000000000,
22
+ "sessionId": "debug-session",
23
+ "runId": "run1",
24
+ "hypothesisId": "H1",
25
+ "location": "path/to/file.ts:79",
26
+ "message": "enter: createSession()",
27
+ "data": { "userId": "...", "provider": "..." }
28
+ }
29
+ ```
30
+
31
+ ## Storage layout (recommended)
32
+ ```
33
+ .logs/
34
+ runtime.json
35
+ server.pid
36
+ {sessionId}-{runId}.jsonl
37
+ ```