@rune-kit/rune 2.1.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 (155) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +357 -0
  3. package/agents/.gitkeep +0 -0
  4. package/agents/architect.md +29 -0
  5. package/agents/asset-creator.md +11 -0
  6. package/agents/audit.md +11 -0
  7. package/agents/autopsy.md +11 -0
  8. package/agents/brainstorm.md +11 -0
  9. package/agents/browser-pilot.md +11 -0
  10. package/agents/coder.md +29 -0
  11. package/agents/completion-gate.md +11 -0
  12. package/agents/constraint-check.md +11 -0
  13. package/agents/context-engine.md +11 -0
  14. package/agents/cook.md +11 -0
  15. package/agents/db.md +11 -0
  16. package/agents/debug.md +11 -0
  17. package/agents/dependency-doctor.md +11 -0
  18. package/agents/deploy.md +11 -0
  19. package/agents/design.md +11 -0
  20. package/agents/docs-seeker.md +11 -0
  21. package/agents/fix.md +11 -0
  22. package/agents/hallucination-guard.md +11 -0
  23. package/agents/incident.md +11 -0
  24. package/agents/integrity-check.md +11 -0
  25. package/agents/journal.md +11 -0
  26. package/agents/launch.md +11 -0
  27. package/agents/logic-guardian.md +11 -0
  28. package/agents/marketing.md +11 -0
  29. package/agents/onboard.md +11 -0
  30. package/agents/perf.md +11 -0
  31. package/agents/plan.md +11 -0
  32. package/agents/preflight.md +11 -0
  33. package/agents/problem-solver.md +11 -0
  34. package/agents/rescue.md +11 -0
  35. package/agents/research.md +11 -0
  36. package/agents/researcher.md +29 -0
  37. package/agents/review-intake.md +11 -0
  38. package/agents/review.md +11 -0
  39. package/agents/reviewer.md +28 -0
  40. package/agents/safeguard.md +11 -0
  41. package/agents/sast.md +11 -0
  42. package/agents/scanner.md +28 -0
  43. package/agents/scope-guard.md +11 -0
  44. package/agents/scout.md +11 -0
  45. package/agents/sentinel.md +11 -0
  46. package/agents/sequential-thinking.md +11 -0
  47. package/agents/session-bridge.md +11 -0
  48. package/agents/skill-forge.md +11 -0
  49. package/agents/skill-router.md +11 -0
  50. package/agents/surgeon.md +11 -0
  51. package/agents/team.md +11 -0
  52. package/agents/test.md +11 -0
  53. package/agents/trend-scout.md +11 -0
  54. package/agents/verification.md +11 -0
  55. package/agents/video-creator.md +11 -0
  56. package/agents/watchdog.md +11 -0
  57. package/agents/worktree.md +11 -0
  58. package/commands/.gitkeep +0 -0
  59. package/commands/rune.md +168 -0
  60. package/compiler/__tests__/openclaw-adapter.test.js +140 -0
  61. package/compiler/__tests__/parser.test.js +55 -0
  62. package/compiler/adapters/antigravity.js +59 -0
  63. package/compiler/adapters/claude.js +37 -0
  64. package/compiler/adapters/cursor.js +67 -0
  65. package/compiler/adapters/generic.js +60 -0
  66. package/compiler/adapters/index.js +45 -0
  67. package/compiler/adapters/openclaw.js +150 -0
  68. package/compiler/adapters/windsurf.js +60 -0
  69. package/compiler/bin/rune.js +288 -0
  70. package/compiler/doctor.js +153 -0
  71. package/compiler/emitter.js +240 -0
  72. package/compiler/parser.js +208 -0
  73. package/compiler/transformer.js +69 -0
  74. package/compiler/transforms/branding.js +27 -0
  75. package/compiler/transforms/cross-references.js +29 -0
  76. package/compiler/transforms/frontmatter.js +38 -0
  77. package/compiler/transforms/hooks.js +68 -0
  78. package/compiler/transforms/subagents.js +36 -0
  79. package/compiler/transforms/tool-names.js +60 -0
  80. package/contexts/dev.md +34 -0
  81. package/contexts/research.md +43 -0
  82. package/contexts/review.md +55 -0
  83. package/extensions/ai-ml/PACK.md +517 -0
  84. package/extensions/analytics/PACK.md +557 -0
  85. package/extensions/backend/PACK.md +678 -0
  86. package/extensions/chrome-ext/PACK.md +995 -0
  87. package/extensions/content/PACK.md +381 -0
  88. package/extensions/devops/PACK.md +520 -0
  89. package/extensions/ecommerce/PACK.md +280 -0
  90. package/extensions/gamedev/PACK.md +393 -0
  91. package/extensions/mobile/PACK.md +273 -0
  92. package/extensions/saas/PACK.md +805 -0
  93. package/extensions/security/PACK.md +536 -0
  94. package/extensions/trading/PACK.md +597 -0
  95. package/extensions/ui/PACK.md +947 -0
  96. package/package.json +47 -0
  97. package/skills/.gitkeep +0 -0
  98. package/skills/adversary/SKILL.md +271 -0
  99. package/skills/asset-creator/SKILL.md +157 -0
  100. package/skills/audit/SKILL.md +466 -0
  101. package/skills/autopsy/SKILL.md +200 -0
  102. package/skills/ba/SKILL.md +279 -0
  103. package/skills/brainstorm/SKILL.md +266 -0
  104. package/skills/browser-pilot/SKILL.md +168 -0
  105. package/skills/completion-gate/SKILL.md +151 -0
  106. package/skills/constraint-check/SKILL.md +165 -0
  107. package/skills/context-engine/SKILL.md +176 -0
  108. package/skills/cook/SKILL.md +636 -0
  109. package/skills/db/SKILL.md +256 -0
  110. package/skills/debug/SKILL.md +240 -0
  111. package/skills/dependency-doctor/SKILL.md +235 -0
  112. package/skills/deploy/SKILL.md +174 -0
  113. package/skills/design/DESIGN-REFERENCE.md +365 -0
  114. package/skills/design/SKILL.md +462 -0
  115. package/skills/doc-processor/SKILL.md +254 -0
  116. package/skills/docs/SKILL.md +336 -0
  117. package/skills/docs-seeker/SKILL.md +166 -0
  118. package/skills/fix/SKILL.md +192 -0
  119. package/skills/git/SKILL.md +285 -0
  120. package/skills/hallucination-guard/SKILL.md +204 -0
  121. package/skills/incident/SKILL.md +241 -0
  122. package/skills/integrity-check/SKILL.md +169 -0
  123. package/skills/journal/SKILL.md +190 -0
  124. package/skills/launch/SKILL.md +330 -0
  125. package/skills/logic-guardian/SKILL.md +240 -0
  126. package/skills/marketing/SKILL.md +229 -0
  127. package/skills/mcp-builder/SKILL.md +311 -0
  128. package/skills/onboard/SKILL.md +298 -0
  129. package/skills/perf/SKILL.md +297 -0
  130. package/skills/plan/SKILL.md +520 -0
  131. package/skills/preflight/SKILL.md +231 -0
  132. package/skills/problem-solver/SKILL.md +284 -0
  133. package/skills/rescue/SKILL.md +434 -0
  134. package/skills/research/SKILL.md +122 -0
  135. package/skills/review/SKILL.md +354 -0
  136. package/skills/review-intake/SKILL.md +222 -0
  137. package/skills/safeguard/SKILL.md +188 -0
  138. package/skills/sast/SKILL.md +190 -0
  139. package/skills/scaffold/SKILL.md +276 -0
  140. package/skills/scope-guard/SKILL.md +150 -0
  141. package/skills/scout/SKILL.md +232 -0
  142. package/skills/sentinel/SKILL.md +320 -0
  143. package/skills/sentinel-env/SKILL.md +226 -0
  144. package/skills/sequential-thinking/SKILL.md +234 -0
  145. package/skills/session-bridge/SKILL.md +287 -0
  146. package/skills/skill-forge/SKILL.md +317 -0
  147. package/skills/skill-router/SKILL.md +267 -0
  148. package/skills/surgeon/SKILL.md +203 -0
  149. package/skills/team/SKILL.md +397 -0
  150. package/skills/test/SKILL.md +271 -0
  151. package/skills/trend-scout/SKILL.md +145 -0
  152. package/skills/verification/SKILL.md +201 -0
  153. package/skills/video-creator/SKILL.md +201 -0
  154. package/skills/watchdog/SKILL.md +166 -0
  155. package/skills/worktree/SKILL.md +140 -0
@@ -0,0 +1,466 @@
1
+ ---
2
+ name: audit
3
+ description: Comprehensive project audit — security, dependencies, code quality, architecture, performance, infra, docs, and mesh analytics. Delegates to specialist skills and generates an 8-dimension health score.
4
+ metadata:
5
+ author: runedev
6
+ version: "0.1.0"
7
+ layer: L2
8
+ model: sonnet
9
+ group: quality
10
+ tools: "Read, Bash, Glob, Grep"
11
+ ---
12
+
13
+ # audit
14
+
15
+ ## Purpose
16
+
17
+ Comprehensive project health audit across 8 dimensions (7 project + 1 mesh analytics). Delegates security scanning to `sentinel`, dependency analysis to `dependency-doctor`, and code complexity to `autopsy`, then directly audits architecture, performance, infrastructure, and documentation. Applies framework-specific checks (React/Next.js, Node.js, Python, Go, Rust, React Native/Flutter) based on detected stack. Produces a consolidated health score and prioritized action plan saved to `AUDIT-REPORT.md`.
18
+
19
+ ## Triggers
20
+
21
+ - `/rune audit` — manual invocation
22
+ - User says "audit", "review project", "health check", "project assessment"
23
+
24
+ ## Calls (outbound)
25
+
26
+ - `scout` (L2): Phase 0 — project structure and stack discovery
27
+ - `dependency-doctor` (L3): Phase 1 — vulnerability scan and outdated dependency check
28
+ - `sentinel` (L2): Phase 2 — security audit (OWASP Top 10, secrets, config)
29
+ - `autopsy` (L2): Phase 3 — code quality and complexity assessment
30
+ - `perf` (L2): Phase 4 — performance regression check
31
+ - `db` (L2): Phase 5 — database health dimension (schema, migrations, indexes)
32
+ - `journal` (L3): record audit date, overall score, and verdict
33
+ - `constraint-check` (L3): audit HARD-GATE compliance across project skills
34
+ - `sast` (L3): Phase 2 — deep static analysis (Semgrep, Bandit, ESLint security rules)
35
+
36
+ ## Called By (inbound)
37
+
38
+ - `cook` (L1): pre-implementation audit gate
39
+ - `launch` (L1): pre-launch health check
40
+ - User: `/rune audit` direct invocation
41
+
42
+ ## Executable Instructions
43
+
44
+ ### Phase 0: Project Discovery
45
+
46
+ Call `rune:scout` for a full project map. Then use `Read` on:
47
+ - `README.md`, `CLAUDE.md`, `CONTRIBUTING.md`, `.editorconfig` (if they exist)
48
+
49
+ Determine:
50
+ - Language(s) and version(s)
51
+ - Framework(s) — determines which Framework-Specific Checks below apply
52
+ - Package manager, build tool(s), test framework(s), linter/formatter config
53
+ - Project type: `API/backend` | `frontend/SPA` | `fullstack` | `CLI tool` | `library` | `mobile` | `infra/IaC`
54
+ - Monorepo setup (workspaces, turborepo, nx, etc.)
55
+
56
+ **Output before proceeding:** Brief project profile, stack summary, and which Framework-Specific Checks will be applied.
57
+
58
+ ---
59
+
60
+ ### Phase 1: Dependency Audit
61
+
62
+ Delegate to `dependency-doctor`. The dependency-doctor report covers:
63
+ - Vulnerability scan (CVEs by severity)
64
+ - Outdated packages (patch / minor / major)
65
+ - Unused dependencies
66
+ - Dependency health score
67
+
68
+ Pass the full dependency-doctor report through to the final audit.
69
+
70
+ ---
71
+
72
+ ### Phase 2: Security Audit
73
+
74
+ Delegate to `sentinel`. Request a full security scan covering:
75
+ - Hardcoded secrets, API keys, tokens, passwords in source code
76
+ - OWASP Top 10: injection, broken auth, sensitive data exposure, XSS, CSRF, insecure deserialization, broken access control
77
+ - Configuration security (debug mode in prod, CORS `*`, missing HTTP security headers)
78
+ - Input validation at API boundaries
79
+ - `.gitignore` coverage of sensitive files
80
+
81
+ Pass the full sentinel report through to the final audit.
82
+
83
+ ---
84
+
85
+ ### Phase 3: Code Quality Audit
86
+
87
+ Delegate to `autopsy` for codebase health (complexity, coupling, hotspots, dead code, health score per module).
88
+
89
+ In addition, use `Grep` to find supplementary issues autopsy may not cover:
90
+
91
+ ```bash
92
+ # console.log in production code
93
+ grep -r "console\.log" src/ --include="*.ts" --include="*.js" -l
94
+
95
+ # TypeScript any types
96
+ grep -r ": any" src/ --include="*.ts" -n
97
+
98
+ # Empty catch blocks
99
+ grep -rn "catch.*{" src/ --include="*.ts" --include="*.js" -A 1 | grep -E "^\s*}"
100
+
101
+ # Python print() in production
102
+ grep -r "^print(" . --include="*.py" -l
103
+
104
+ # Rust .unwrap() outside tests
105
+ grep -rn "\.unwrap()" src/ --include="*.rs"
106
+ ```
107
+
108
+ Merge autopsy report + supplementary findings.
109
+
110
+ ---
111
+
112
+ ### Phase 4: Architecture Audit
113
+
114
+ Use `Read` and `Grep` to evaluate structural health directly.
115
+
116
+ **4.1 Project Structure**
117
+ - Logical folder organization (business logic vs infrastructure vs presentation separated?)
118
+ - Circular dependencies between modules (A imports B, B imports A)
119
+ - Barrel file analysis (excessive re-exports causing bundle bloat)
120
+
121
+ **4.2 Design Patterns & Principles**
122
+ - Single Responsibility violations (route handlers with direct DB calls, fat controllers)
123
+ - Tight coupling between layers
124
+
125
+ ```typescript
126
+ // BAD — route handler directly coupled to database
127
+ app.get('/users/:id', async (req, res) => {
128
+ const user = await db.query('SELECT * FROM users WHERE id = $1', [req.params.id]);
129
+ res.json(user);
130
+ });
131
+ // GOOD — layered architecture
132
+ app.get('/users/:id', async (req, res) => {
133
+ const user = await userService.getUser(req.params.id);
134
+ res.json(user);
135
+ });
136
+ ```
137
+
138
+ **4.3 API Design** (if applicable)
139
+ - Consistent naming conventions (camelCase vs snake_case in JSON responses)
140
+ - Correct HTTP method usage (GET reads, POST creates, PUT/PATCH updates, DELETE removes)
141
+ - Consistent error response format across endpoints
142
+ - Pagination on collection endpoints
143
+ - API versioning strategy
144
+
145
+ **4.4 Database Patterns** (if applicable)
146
+ - N+1 query patterns
147
+
148
+ ```typescript
149
+ // BAD — N+1
150
+ const users = await db.query('SELECT * FROM users');
151
+ for (const user of users) {
152
+ user.posts = await db.query('SELECT * FROM posts WHERE user_id = $1', [user.id]);
153
+ }
154
+ // GOOD — single JOIN
155
+ const usersWithPosts = await db.query(`
156
+ SELECT u.*, json_agg(p.*) as posts
157
+ FROM users u LEFT JOIN posts p ON p.user_id = u.id
158
+ GROUP BY u.id
159
+ `);
160
+ ```
161
+
162
+ - Missing indexes (check schema/migrations for columns used in WHERE/JOIN)
163
+ - Missing `LIMIT` on user-facing queries
164
+
165
+ **4.5 State Management** (frontend only)
166
+ - Global state pollution (local state handled globally)
167
+ - Prop drilling (>3 levels deep — use Context or composition)
168
+ - Data fetching patterns (caching, deduplication, stale-while-revalidate)
169
+
170
+ ---
171
+
172
+ ### Phase 5: Performance Audit
173
+
174
+ **5.1 Build & Bundle** (frontend)
175
+ - Tree-shaking effectiveness (importing entire libraries vs specific modules)
176
+
177
+ ```typescript
178
+ // BAD — imports entire library
179
+ import _ from 'lodash';
180
+ // GOOD — tree-shakeable import
181
+ import get from 'lodash/get';
182
+ ```
183
+
184
+ - Code splitting / lazy loading for routes
185
+ - Large unoptimized assets
186
+
187
+ **5.2 Runtime Performance**
188
+ - Synchronous operations that should be async (file I/O, network calls)
189
+ - Memory leak patterns (event listeners not cleaned up, growing caches, unclosed streams)
190
+ - Expensive operations in hot paths
191
+
192
+ ```typescript
193
+ // BAD — regex compiled on every call
194
+ function validate(input: string) {
195
+ return /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(input);
196
+ }
197
+ // GOOD — compile once at module level
198
+ const EMAIL_REGEX = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
199
+ function validate(input: string) { return EMAIL_REGEX.test(input); }
200
+ ```
201
+
202
+ **5.3 Database & I/O**
203
+ - Missing connection pooling
204
+ - Unbounded queries (no `LIMIT` on user-facing endpoints)
205
+ - Sequential I/O that could be parallel
206
+
207
+ ```typescript
208
+ // BAD — sequential when independent
209
+ const users = await fetchUsers();
210
+ const products = await fetchProducts();
211
+ // GOOD — parallel
212
+ const [users, products] = await Promise.all([fetchUsers(), fetchProducts()]);
213
+ ```
214
+
215
+ ---
216
+
217
+ ### Phase 6: Infrastructure & DevOps Audit
218
+
219
+ Use `Glob` and `Read` to check:
220
+
221
+ **6.1 CI/CD Pipeline**
222
+ - CI config exists (`.github/workflows/`, `.gitlab-ci.yml`, `.circleci/`, `Jenkinsfile`)
223
+ - Tests running in CI
224
+ - Linting enforced in CI
225
+ - Security scanning in pipeline (Dependabot, Snyk, CodeQL)
226
+
227
+ **6.2 Environment Configuration**
228
+ - `.env.example` exists with placeholder values (not real secrets)
229
+ - Environment variables validated at startup
230
+
231
+ ```typescript
232
+ // BAD — silently undefined
233
+ const port = process.env.PORT;
234
+ // GOOD — validate at startup
235
+ const port = process.env.PORT;
236
+ if (!port) throw new Error('PORT environment variable is required');
237
+ ```
238
+
239
+ **6.3 Containerization** (if applicable)
240
+ - Dockerfile: multi-stage build, non-root user, minimal base image
241
+ - `.dockerignore` covers `node_modules`, `.git`, `.env`
242
+
243
+ **6.4 Logging & Monitoring**
244
+ - Structured logging (JSON format, not raw `console.log`)
245
+ - Error tracking integration (Sentry, Datadog, etc.)
246
+ - Health check endpoints (`/health`, `/ready`)
247
+ - No sensitive data in logs (passwords, tokens, PII)
248
+
249
+ ---
250
+
251
+ ### Phase 7: Documentation Audit
252
+
253
+ Use `Glob` and `Read` to check:
254
+
255
+ **7.1 Project Documentation**
256
+ - README completeness: description, prerequisites, setup, usage, deployment, contributing
257
+ - API documentation (OpenAPI/Swagger spec, or documented endpoints)
258
+ - Can a new developer get running from README alone?
259
+ - Architecture Decision Records (ADRs) for non-obvious choices
260
+
261
+ **7.2 Code Documentation**
262
+ - Public API / exported functions documented
263
+ - Complex business logic with explanatory comments
264
+ - `CHANGELOG.md` maintained
265
+ - `LICENSE` file present
266
+
267
+ ---
268
+
269
+ ### Framework-Specific Checks
270
+
271
+ Apply **only** if the framework was detected in Phase 0. Skip entirely if not relevant.
272
+
273
+ **React / Next.js** (detect: `react` or `next` in `package.json`)
274
+ - `useEffect` with missing dependencies (stale closures)
275
+ - State updates during render (infinite loop pattern)
276
+ - List items using index as key on reorderable lists
277
+ - Props drilled through 3+ levels
278
+ - Client-side hooks in Server Components (Next.js App Router)
279
+ - Components exceeding 200 JSX lines
280
+
281
+ **Node.js / Express / Fastify** (detect: `express`, `fastify`, `koa`, `@nestjs/core`)
282
+ - Missing rate limiting on public endpoints
283
+ - Missing request timeout configuration
284
+ - Error messages leaking internal details to clients
285
+ - Unbounded `SELECT *` without pagination
286
+ - Missing authentication middleware on protected routes
287
+ - Synchronous operations blocking the event loop
288
+
289
+ **Python (Django / Flask / FastAPI)** (detect: `django`, `flask`, `fastapi` in requirements)
290
+ - Django: missing `permission_classes`, `DEBUG=True` in production, missing CSRF middleware
291
+ - Flask: `app.run(debug=True)` without environment check
292
+ - FastAPI: missing Pydantic models for request/response
293
+ - Mutable default arguments (`def func(items=[])`)
294
+ - Missing type hints on public functions (if project uses mypy/pyright)
295
+
296
+ **Go** (detect: `go.mod`)
297
+ - Ignored errors (`file, _ := os.Open(filename)`)
298
+ - Goroutine leaks (goroutines without cancellation context)
299
+ - Missing `defer` for resource cleanup (files, locks, connections)
300
+ - Race conditions (shared state without mutex or channels)
301
+
302
+ **Rust** (detect: `Cargo.toml`)
303
+ - `.unwrap()` / `.expect()` in non-test production code (use `?` operator)
304
+ - `unsafe` blocks without safety comments
305
+
306
+ **Mobile (React Native / Flutter)** (detect: `react-native` in `package.json` or `pubspec.yaml`)
307
+ - FlatList without `keyExtractor` or `getItemLayout`
308
+ - Missing `React.memo` on list item components
309
+ - Flutter: missing `const` constructors, missing `dispose()` for controllers and streams
310
+
311
+ ---
312
+
313
+ ### Phase 8: Mesh Analytics (H3 Intelligence)
314
+
315
+ **Goal**: Surface insights about skill usage, chain patterns, and mesh health from accumulated metrics.
316
+
317
+ **Data source**: `.rune/metrics/` directory (populated by hooks automatically).
318
+
319
+ 1. Check if `.rune/metrics/` exists. If not, emit INFO: "No metrics data yet — run a few cook sessions first."
320
+ 2. Read `.rune/metrics/skills.json` — extract per-skill invocation counts, last used dates
321
+ 3. Read `.rune/metrics/sessions.jsonl` — extract session count, avg duration, avg tool calls
322
+ 4. Read `.rune/metrics/chains.jsonl` — extract most common skill chains
323
+ 5. Read `.rune/metrics/routing-overrides.json` (if exists) — list active routing overrides
324
+
325
+ Compute and report:
326
+ - **Top 10 most-used skills** (by total invocations)
327
+ - **Unused skills** (0 invocations across all tracked sessions) — potential dead nodes
328
+ - **Most common skill chains** (top 5 patterns from chains.jsonl)
329
+ - **Average session stats** (duration, tool calls, skill invocations)
330
+ - **Active routing overrides** and their application count
331
+ - **Mesh density check**: cross-reference invocation data with declared connections — skills that are declared as "Called By" but never actually invoked may indicate broken mesh paths
332
+
333
+ **Propose routing overrides**: If patterns suggest inefficiency (e.g., debug consistently called 3+ times in a chain for the same session), propose a new routing override for user approval.
334
+
335
+ Output as a section in the final audit report:
336
+
337
+ ```
338
+ ### Mesh Analytics
339
+ | Skill | Invocations | Last Used | Chains Containing |
340
+ |-------|-------------|-----------|-------------------|
341
+ | cook | 47 | 2026-02-28| 34 |
342
+ | scout | 89 | 2026-02-28| 42 |
343
+ | ... | ... | ... | ... |
344
+
345
+ **Common Chains**:
346
+ 1. cook → scout → plan → test → fix → quality → verify (34x)
347
+ 2. debug → scout → fix → verification (12x)
348
+
349
+ **Session Stats**: 23 sessions, avg 35min, avg 52 tool calls
350
+ **Unused Skills**: [list or "none"]
351
+ **Routing Overrides**: [count] active
352
+ ```
353
+
354
+ **Shortcut**: `/rune metrics` invokes ONLY this phase, not the full 7-phase audit.
355
+
356
+ ---
357
+
358
+ ### Final Report
359
+
360
+ After all phases complete:
361
+
362
+ Use `Write` to save `AUDIT-REPORT.md` to the project root with the full findings from all phases.
363
+
364
+ Call `rune:journal` to record: audit date, overall health score, verdict, and CRITICAL count.
365
+
366
+ ## Severity Levels
367
+
368
+ ```
369
+ CRITICAL — Must fix immediately. Security vulnerabilities, data loss, broken builds.
370
+ HIGH — Should fix soon. Performance bottlenecks, CVEs, major code smells.
371
+ MEDIUM — Plan to fix. Code duplication, missing tests, outdated deps.
372
+ LOW — Nice to have. Style inconsistencies, minor refactors, doc gaps.
373
+ INFO — Observation only. Architecture notes, tech debt acknowledgment.
374
+ ```
375
+
376
+ Apply confidence filtering: only report findings with >80% confidence. Consolidate similar issues (e.g., "12 functions missing error handling in src/services/" — not 12 separate findings). Adapt judgment to project type (a `console.log` in a CLI tool is fine; in a production API handler, it's not).
377
+
378
+ ## Output Format
379
+
380
+ ```
381
+ ## Audit Report: [Project Name]
382
+
383
+ - **Verdict**: PASS | WARNING | FAIL
384
+ - **Overall Health**: [score]/10
385
+ - **Total Findings**: [n] (CRITICAL: [n], HIGH: [n], MEDIUM: [n], LOW: [n])
386
+ - **Framework Checks Applied**: [list]
387
+
388
+ ### Health Score
389
+ | Dimension | Score | Notes |
390
+ |----------------|:--------:|--------------------|
391
+ | Security | ?/10 | [brief note] |
392
+ | Code Quality | ?/10 | [brief note] |
393
+ | Architecture | ?/10 | [brief note] |
394
+ | Performance | ?/10 | [brief note] |
395
+ | Dependencies | ?/10 | [brief note] |
396
+ | Infrastructure | ?/10 | [brief note] |
397
+ | Documentation | ?/10 | [brief note] |
398
+ | Mesh Analytics | ?/10 | [brief note] |
399
+ | **Overall** | **?/10** | **[verdict]** |
400
+
401
+ ### Phase Breakdown
402
+ | Phase | Issues |
403
+ |----------------|--------|
404
+ | Dependencies | [n] |
405
+ | Security | [n] |
406
+ | Code Quality | [n] |
407
+ | Architecture | [n] |
408
+ | Performance | [n] |
409
+ | Infrastructure | [n] |
410
+ | Documentation | [n] |
411
+ | Mesh Analytics | [n] |
412
+
413
+ ### Top Priority Actions
414
+ 1. [action] — [file:line] — [why it matters]
415
+
416
+ ### Positive Findings
417
+ - [at least 3 things the project does well]
418
+
419
+ ### Follow-up Timeline
420
+ - FAIL → re-audit in 1-2 weeks after CRITICAL fixes
421
+ - WARNING → re-audit in 1 month
422
+ - PASS → routine audit in 3 months
423
+
424
+ Report saved to: AUDIT-REPORT.md
425
+ ```
426
+
427
+ ## Constraints
428
+
429
+ 1. MUST complete all 8 phases (Phase 8 may report "no data" if .rune/metrics/ doesn't exist yet) — if any phase is skipped, state explicitly which phase and why
430
+ 2. MUST delegate Phase 1 to dependency-doctor and Phase 2 to sentinel — no manual replacements
431
+ 3. MUST apply confidence filter — only report findings with >80% confidence; consolidate similar issues
432
+ 4. MUST include at least 3 positive findings — an audit with no positives is incomplete
433
+ 5. MUST produce quantified health scores (1-10 per dimension) — not vague "needs work"
434
+ 6. MUST NOT fabricate findings — every finding requires a specific file:line citation
435
+ 7. MUST save AUDIT-REPORT.md before declaring completion
436
+
437
+ ## Mesh Gates
438
+
439
+ | Gate | Requires | If Missing |
440
+ |------|----------|------------|
441
+ | Discovery Gate | Phase 0 project profile completed before Phase 1 | Run scout and read config files first |
442
+ | Security Gate | sentinel report received before assembling final report | Invoke rune:sentinel — do not skip |
443
+ | Deps Gate | dependency-doctor report received before assembling final report | Invoke rune:dependency-doctor — do not skip |
444
+ | Report Gate | All 8 phases completed before writing AUDIT-REPORT.md | Complete all phases, note skipped ones |
445
+
446
+ ## Sharp Edges
447
+
448
+ | Failure Mode | Severity | Mitigation |
449
+ |---|---|---|
450
+ | Generating health scores from file name patterns instead of actual reads | CRITICAL | Phase 0 scout run is mandatory — never score without reading actual code |
451
+ | Skipping a phase because "there are no changes in that area" | HIGH | All 7 phases run for every audit — partial audits produce misleading scores |
452
+ | Health score inflation — no negative findings in any dimension | MEDIUM | CONSTRAINT: minimum 3 positive AND 3 improvement areas required |
453
+ | Dependency-doctor or sentinel sub-call times out → skipped silently | MEDIUM | Mark phase as "incomplete — tool timeout" with N/A score, do not fabricate |
454
+
455
+ ## Done When
456
+
457
+ - All 8 phases completed (or explicitly marked N/A with reason)
458
+ - Health score calculated from actual file reads per dimension (not estimated)
459
+ - At least 3 positive findings and 3 improvement areas documented
460
+ - AUDIT-REPORT.md written to project root
461
+ - Journal entry recorded with audit date, score, and CRITICAL count
462
+ - Structured report emitted with overall health score and verdict
463
+
464
+ ## Cost Profile
465
+
466
+ ~8000-20000 tokens input, ~3000-6000 tokens output. Sonnet orchestrating; sentinel (sonnet/opus) and autopsy (opus) are the expensive sub-calls. Full audit runs 4 sub-skills. Most thorough L2 skill — run on demand, not on every cycle.
@@ -0,0 +1,200 @@
1
+ ---
2
+ name: autopsy
3
+ description: Full codebase health assessment. Analyzes complexity, dependencies, dead code, tech debt, and git hotspots. Produces a health score and rescue plan.
4
+ metadata:
5
+ author: runedev
6
+ version: "0.2.0"
7
+ layer: L2
8
+ model: opus
9
+ group: rescue
10
+ tools: "Read, Bash, Glob, Grep"
11
+ ---
12
+
13
+ # autopsy
14
+
15
+ ## Purpose
16
+
17
+ Full codebase health assessment for legacy projects. Autopsy analyzes complexity, dependency coupling, dead code, tech debt, and git hotspots to produce a health score per module and a prioritized rescue plan. Uses opus for deep analysis quality.
18
+
19
+ ## Called By (inbound)
20
+
21
+ - `rescue` (L1): Phase 0 RECON — assess damage before refactoring
22
+ - `onboard` (L2): when project appears messy during onboarding
23
+ - `audit` (L2): Phase 3 code quality and complexity assessment
24
+ - `incident` (L2): root cause analysis after containment
25
+
26
+ ## Calls (outbound)
27
+
28
+ - `scout` (L2): deep structural scan — files, LOC, entry points, imports
29
+ - `research` (L3): identify if tech stack is outdated
30
+ - `trend-scout` (L3): compare against current best practices
31
+ - `journal` (L3): record health assessment findings
32
+
33
+ ## Execution Steps
34
+
35
+ ### Step 1 — Structure scan
36
+
37
+ Call `rune:scout` with a request for a full project map. Ask scout to return:
38
+ - All source files with LOC counts
39
+ - Entry points and main modules
40
+ - Import/dependency graph (who imports who)
41
+ - Test files and their coverage targets
42
+ - Config files (tsconfig, eslint, package.json, etc.)
43
+
44
+ ### Step 2 — Module analysis
45
+
46
+ For each major module identified by scout, use `Read` to open the file and assess:
47
+ - LOC (flag anything over 500 as a god file)
48
+ - Function count and average function length
49
+ - Maximum nesting depth (flag > 4 levels)
50
+ - Cyclomatic complexity signals (deep conditionals, many branches)
51
+ - Test file presence and estimated coverage
52
+
53
+ Record findings per module in a working table.
54
+
55
+ ### Step 3 — Health scoring
56
+
57
+ Score each module 0-100 across six dimensions:
58
+
59
+ | Dimension | Weight | Scoring criteria |
60
+ |---|---|---|
61
+ | Complexity | 20% | Cyclomatic < 5 = 100, 5-10 = 70, 10-20 = 40, > 20 = 0 |
62
+ | Test coverage | 25% | > 80% = 100, 50-80% = 60, 20-50% = 30, < 20% = 0 |
63
+ | Documentation | 15% | README + inline comments = 100, partial = 50, none = 0 |
64
+ | Dependencies | 20% | Low coupling = 100, medium = 60, high/circular = 0 |
65
+ | Code smells | 10% | No god files, no deep nesting = 100, each violation -20 |
66
+ | Maintenance | 10% | Regular commits = 100, stale > 6 months = 50, untouched > 1yr = 0 |
67
+
68
+ Compute weighted score per module. Assign risk tier:
69
+ - 80-100 = healthy (green)
70
+ - 60-79 = watch (yellow)
71
+ - 40-59 = at-risk (orange)
72
+ - 0-39 = critical (red)
73
+
74
+ ### Step 4 — Risk assessment
75
+
76
+ Use `Bash` to gather git archaeology data:
77
+
78
+ ```bash
79
+ # Most changed files (hotspots)
80
+ git log --format=format: --name-only | sort | uniq -c | sort -rg | head -20
81
+
82
+ # Files not touched in over a year
83
+ git log --before="1 year ago" --format="%H" | head -1 | xargs -I{} git diff --name-only {}..HEAD
84
+
85
+ # Authors per file (high author count = high churn risk)
86
+ git log --format="%an" -- <file> | sort -u | wc -l
87
+ ```
88
+
89
+ Identify:
90
+ - Circular dependencies (A imports B, B imports A)
91
+ - God files (> 500 LOC with many importers)
92
+ - Hotspot files (changed most often = highest bug density)
93
+ - Dead files (no importers, no recent commits)
94
+
95
+ ### Step 5 — Generate RESCUE-REPORT.md
96
+
97
+ Use `Write` to save `RESCUE-REPORT.md` at the project root with this structure:
98
+
99
+ ```markdown
100
+ # Rescue Report: [Project Name]
101
+ Generated: [date]
102
+
103
+ ## Overall Health: [score]/100
104
+
105
+ ## Module Health
106
+ | Module | Score | Complexity | Coverage | Coupling | Risk | Priority |
107
+ |--------|-------|-----------|----------|----------|------|----------|
108
+ | [name] | [n] | [low/med/high] | [%] | [low/med/high] | [tier] | [1-N] |
109
+
110
+ ## Dependency Graph
111
+ [Mermaid diagram of module coupling]
112
+
113
+ ## Surgery Queue (Priority Order)
114
+ 1. [module] — Score: [n] — [primary reason] — Suggested pattern: [pattern]
115
+ 2. ...
116
+
117
+ ## Git Archaeology
118
+ - Hotspot files: [list with change frequency]
119
+ - Stale files: [list with age]
120
+ - Dead code candidates: [list]
121
+
122
+ ## Immediate Actions (Before Surgery)
123
+ - [action 1]
124
+ - [action 2]
125
+ ```
126
+
127
+ Call `rune:journal` to record that autopsy ran, the overall health score, and the surgery queue.
128
+
129
+ ### Step 6 — Report
130
+
131
+ Output a summary of the findings:
132
+
133
+ - Overall health score and tier
134
+ - Count of critical, at-risk, watch, and healthy modules
135
+ - Top 3 worst modules with scores and recommended patterns
136
+ - Confirm RESCUE-REPORT.md was saved
137
+ - Recommended next step: call `rune:safeguard` on the top-priority module
138
+
139
+ ## Health Score Factors
140
+
141
+ ```
142
+ CODE QUALITY — cyclomatic complexity, nesting depth, function length
143
+ DEPENDENCIES — coupling, circular deps, outdated packages
144
+ TEST COVERAGE — line coverage, branch coverage, test quality
145
+ DOCUMENTATION — inline comments, README, API docs
146
+ MAINTENANCE — git hotspots, commit frequency, author count
147
+ DEAD CODE — unused exports, unreachable branches
148
+ ```
149
+
150
+ ## Output Format
151
+
152
+ ```
153
+ ## Autopsy Report: [Project Name]
154
+
155
+ ### Overall Health: [score]/100 — [tier: healthy | watch | at-risk | critical]
156
+
157
+ ### Module Summary
158
+ | Module | Score | Risk | Priority |
159
+ |--------|-------|------|----------|
160
+ | [name] | [n] | [tier] | [1-N] |
161
+
162
+ ### Top Issues
163
+ 1. [module] — [primary finding] — Recommended pattern: [pattern]
164
+
165
+ ### Next Step
166
+ Run rune:safeguard on [top-priority module] before any refactoring.
167
+ ```
168
+
169
+ ## Constraints
170
+
171
+ 1. MUST scan actual code metrics — not estimate from file names
172
+ 2. MUST produce quantified health score — not vague "needs improvement"
173
+ 3. MUST identify specific modules with highest technical debt — ranked by severity
174
+ 4. MUST NOT recommend refactoring everything — prioritize by impact
175
+ 5. MUST check: test coverage, cyclomatic complexity, dependency freshness, dead code
176
+
177
+ ## Sharp Edges
178
+
179
+ Known failure modes for this skill. Check these before declaring done.
180
+
181
+ | Failure Mode | Severity | Mitigation |
182
+ |---|---|---|
183
+ | Health scores estimated without reading actual code metrics | CRITICAL | Constraint 1: scan actual code — open files, count LOC, assess nesting depth |
184
+ | Recommending refactoring everything without prioritization | HIGH | Constraint 4: rank by severity — worst health score modules first, max top-5 |
185
+ | Missing git archaeology (no hotspot/stale file analysis) | MEDIUM | Step 4 bash commands are mandatory — git log data is part of the health picture |
186
+ | Skipping RESCUE-REPORT.md write (only verbal summary) | HIGH | Step 5 write is mandatory — persistence is the point of autopsy |
187
+ | Health score not backed by all 6 dimensions scored | MEDIUM | All 6 dimensions (complexity, test coverage, docs, deps, smells, maintenance) required |
188
+
189
+ ## Done When
190
+
191
+ - scout completed with full project map (all files, entry points, import graph)
192
+ - All major modules scored across all 6 dimensions
193
+ - Git archaeology run (hotspots, stale files, dead code candidates identified)
194
+ - RESCUE-REPORT.md written to project root with Mermaid dependency diagram
195
+ - journal called with health score and surgery queue
196
+ - Autopsy Report emitted with overall health tier and top-3 issues
197
+
198
+ ## Cost Profile
199
+
200
+ ~5000-10000 tokens input, ~2000-4000 tokens output. Opus for deep analysis. Most expensive L2 skill but runs once per rescue.