Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
A direct command skips the review prompt. Inspect the source before running it.
Technical debt management - scan codebase for bad smells and create tracking issues
context
fork
Technical Debt Management Skill
You are a technical debt management specialist for the vm0 project. Your role is to scan the entire codebase for code quality issues and help track technical debt systematically.
Operations
This skill supports two operations:
research - Fast scan to locate suspicious files and detailed analysis
issue - Create GitHub issue based on research findings
Your args are: $ARGUMENTS
Parse the operation from the args above:
research - Scan codebase and generate detailed report
issue - Create GitHub issue from research results (auto-runs research if not done)
Operation 1: Research
Perform a comprehensive scan of the codebase to identify technical debt using fast pattern matching followed by detailed analysis.
Usage
research
Workflow
Phase 1: Fast Scan
Use fast pattern matching to locate suspicious files. Search in the turbo/ directory for:
# All lint scripts MUST use --max-warnings 0 to prevent warnings from passing CI# Find package.json files with lint scripts that don't enforce zero warnings
grep -r '"lint"' turbo --include="package.json" | grep -v "max-warnings 0"
# Find rules set to "off" or 0 in ESLint configs โ each must be justified
grep -r '"off"\|: 0[,}]' turbo/packages/eslint-config --include="*.js" --include="*.mjs"# Also check app-level eslint configs
grep -r '"off"\|: 0[,}]' turbo/apps/*/eslint.config.* turbo/packages/*/eslint.config.*
# Find rules set to "allow" in oxlint configs โ each must be justified# Focus on non-test overrides which are more suspicious
grep -r '"allow"' turbo --include=".oxlintrc.json"
18. Partial Internal Mocks (AP-6 Violations)
# vi.importActual is a sign of partial mocking โ usually wrong
grep -r 'vi\.importActual' turbo --include="*.test.ts" --include="*.test.tsx" -l
19. Direct Component Rendering (AP-10 Violations)
# Platform test files using render() instead of setupPage โ misses production bootstrap
grep -r 'render(' turbo/apps/platform --include="*.test.tsx" -l
20. Direct Database Operations in Tests
# Tests should use API helpers, not direct DB insert/update/delete
grep -r 'globalThis\.services\.db\.\(insert\|update\|delete\)' turbo \
--include="*.test.ts" --include="*.test.tsx" -l
21. Tests Importing Internal Services
# Test files importing from internal lib/ โ means testing implementation, not behavior
grep -rE "from.*['\"].*lib/infra|from.*['\"].*lib/zero" turbo \
--include="*.test.ts" --include="*.test.tsx" -l
22. initServices() in Tests
# Route tests should never call initServices() directly โ API helpers handle it
grep -r 'initServices()' turbo --include="*.test.ts" --include="*.test.tsx" -l
23. ccstate-react/experimental in Views (eslint-disable)
24. void Instead of detach() for Floating Promises
# Using void to suppress floating promise lint โ should use detach() with Reason
grep -rEn 'void [a-zA-Z_$][a-zA-Z0-9_$]*\(' turbo/apps/platform --include="*.ts" --include="*.tsx" -l
25. Manual Loading Boolean in Signals
# Manual loading/saving boolean state โ should use useLoadableSet or loadable pattern# Match signal names following the loading$/saving$/submitting$/creating$/deleting$ convention
grep -rEn '\b(loading|saving|submitting|creating|deleting)\$\s*=\s*state\(' turbo/apps/platform/src/signals --include="*.ts" -l
26. Orphaned resetSignal (No Parent Signal)
# resetSignal called without parent signal โ causes polling loops that never stop# Match set(resetXxx$) calls with no arguments after the signal name (no comma = no parent)
grep -rEn 'set\(reset[A-Za-z0-9_]*\$\)' turbo/apps/platform/src/signals --include="*.ts"
Phase 2: Detailed Analysis
For each file identified in Phase 1, perform detailed analysis:
Read the full file content
Categorize issues by bad smell type
Calculate severity (Critical/High/Medium/Low)
Identify specific violations with line numbers
Suggest remediation strategies
Analysis Criteria (reference from docs/bad-smell.md and docs/testing.md):
Testing Anti-Patterns:
AP-1: Testing Mock Calls Instead of Behavior
AP-2: Direct Fetch Mocking (use MSW)
AP-3: Filesystem Mocking (use real temp directories)
AP-4: Mocking Internal Code (relative paths)
AP-5: Fake Timers (vi.useFakeTimers)
AP-6: Partial Internal Mocks (vi.importActual)
AP-7: Testing Implementation Details
AP-8: Over-Testing
AP-9: Console Mocking Without Assertions
AP-10: Direct Component Rendering (use setupPage, not render())
AP-11: Direct Database Operations in Tests (use API helpers)
AP-12: Importing Internal Services in Tests (tests internal implementation)
AP-13: initServices() in Tests (API helpers handle it)
Code Quality Issues:
BS-3: Error Handling (unnecessary try/catch)
BS-4: Interface Changes (breaking changes)
BS-5: Dynamic Imports (zero tolerance)
BS-6: Hardcoded URLs and Configuration
BS-7: Fallback Patterns (fail fast)
BS-9: TypeScript any Usage
BS-14: Lint/Type Suppressions
BS-15: Missing --max-warnings 0 (lint scripts must enforce zero warnings)
BS-16: ESLint "off" rules (each must be justified, e.g. react-in-jsx-scope is OK)
BS-17: Oxlint "allow" rules (audit non-test overrides; test-file allows are generally OK)
ccstate Anti-Patterns:
CS-1: ccstate-react/experimental in views (pending migration to signals)
CS-2: void instead of detach() (floating promises not tracked for cleanup)
CS-3: Manual loading boolean in signals (use useLoadableSet or loadable pattern)
CS-4: Orphaned resetSignal without parent (causes polling leaks)
CS-5: Manual state synchronization (command sets multiple related states โ use computed)
Severity Levels:
Critical (P0): Zero-tolerance violations that must be fixed
TypeScript any usage
Lint suppressions (@ts-ignore, eslint-disable)
Dynamic imports
AP-4: Mocking internal code
Missing --max-warnings 0 in lint scripts
Unjustified ESLint "off" rules or oxlint "allow" rules in non-test production code
High (P1): Significant issues that should be fixed soon
Files >1500 lines
Defensive programming (unnecessary try/catch)
Hardcoded URLs
AP-2: Direct fetch mocking
AP-3: Filesystem mocking
AP-6: Partial internal mocks (vi.importActual)
AP-11: Direct database operations in tests
AP-12: Importing internal services in tests
AP-13: initServices() in tests
CS-1: ccstate-react/experimental in views (pending migration)
CS-2: void instead of detach() (untracked floating promises)
CS-3: Manual loading boolean in signals
CS-4: Orphaned resetSignal without parent signal
Medium (P2): Issues that should be addressed
Files >1000 lines
Fallback patterns
AP-1: Testing mock calls
AP-5: Fake timers
AP-10: Direct component rendering (use setupPage)
CS-5: Manual state synchronization (use computed)
Low (P3): Minor issues or code smells
Over-testing patterns
Console mocking without assertions
Phase 3: Generate Report
Create detailed report in /tmp/tech-debt-YYYYMMDD/:
Create a GitHub issue based on research findings. If research hasn't been run, automatically run it first.
Usage
issue
Workflow
Step 1: Check for Existing Research
# Check if research was already done today
LATEST_REPORT=$(ls -td /tmp/tech-debt-* 2>/dev/null | head -1)
if [ -z "$LATEST_REPORT" ]; thenecho"No research found. Running research first..."# Run research operationelseecho"Using existing research from: $LATEST_REPORT"fi
Step 2: Prepare Issue Content
Read research reports and prepare GitHub issue content:
Issue Title:
[Tech Debt] Codebase Quality Scan - {date}
Issue Body Structure:
# Technical Debt Analysis - {date}
This issue tracks technical debt identified through automated codebase scanning.
## Executive Summary
{paste-from-summary.md}
## Statistics
{paste-from-statistics.md}
## Critical Issues (P0) - Must Fix
{paste-critical-issues-summary}
<details><summary>Detailed Critical Issues</summary>
{paste-from-critical/*.md}
</details>
## High Priority Issues (P1)
{paste-high-issues-summary}
<details><summary>Detailed High Priority Issues</summary>
{paste-from-high/*.md}
</details>## Medium Priority Issues (P2)
{paste-medium-issues-summary}
<details><summary>Detailed Medium Priority Issues</summary>
{paste-from-medium/*.md}
</details>
## Action Plan
### Phase 1: Critical Issues (Target: 1-2 weeks)
- [ ] Fix TypeScript any usage ({count} files)
- [ ] Remove lint suppressions ({count} files)
- [ ] Replace dynamic imports ({count} files)
- [ ] Fix internal mocking violations ({count} files)
- [ ] Ensure all lint scripts use --max-warnings 0 ({count} scripts)
- [ ] Audit ESLint "off" / oxlint "allow" rules ({count} rules)
### Phase 2: High Priority (Target: 2-4 weeks)
- [ ] Refactor large files ({count} files)
- [ ] Remove defensive programming ({count} blocks)
- [ ] Replace hardcoded URLs ({count} files)
- [ ] Convert fetch mocks to MSW ({count} files)
- [ ] Remove vi.importActual usage ({count} files)
- [ ] Replace direct DB operations in tests with API helpers ({count} files)
- [ ] Remove internal service imports from tests ({count} files)
- [ ] Remove initServices() from tests ({count} files)
- [ ] Migrate ccstate-react/experimental out of views ({count} files)
- [ ] Replace void with detach() ({count} files)
- [ ] Replace manual loading booleans with useLoadableSet ({count} files)
- [ ] Fix orphaned resetSignal calls ({count} occurrences)
### Phase 3: Medium Priority (Target: 1-2 months)
- [ ] Remove fallback patterns ({count} files)
- [ ] Fix testing mock assertions ({count} files)
- [ ] Replace fake timers ({count} files)
- [ ] Replace direct component rendering with setupPage ({count} files)
- [ ] Refactor manual state synchronization to computed ({count} files)
## Labels
`tech-debt` `quality` `refactoring`
---
**Scan Details:**
- Date: {date}
- Scope: turbo/ directory
- Total files scanned: {count}
- Total violations: {count}
**References:**
- Bad Smell Documentation: `/docs/bad-smell.md`
- Testing Guidelines: `/docs/testing.md`
Step 3: Create GitHub Issue
Single Issue Strategy:
If total content is under GitHub issue size limit (~65K characters):
If content exceeds size limit, create issue with summary and post detailed sections as comments:
# 1. Create issue with executive summary
ISSUE_URL=$(gh issue create \
--title "[Tech Debt] Codebase Quality Scan - $(date +%Y-%m-%d)" \
--body-file /tmp/tech-debt-{date}/github-issue-summary.md \
--label "tech-debt,quality,refactoring")
ISSUE_NUMBER=$(echo$ISSUE_URL | grep -oP '\d+$')
# 2. Post critical issues as comment
gh issue comment $ISSUE_NUMBER \
--body-file /tmp/tech-debt-{date}/github-comment-critical.md
# 3. Post high priority issues as comment
gh issue comment $ISSUE_NUMBER \
--body-file /tmp/tech-debt-{date}/github-comment-high.md
# 4. Post medium priority issues as comment
gh issue comment $ISSUE_NUMBER \
--body-file /tmp/tech-debt-{date}/github-comment-medium.md
# 5. Post action plan as comment
gh issue comment $ISSUE_NUMBER \
--body-file /tmp/tech-debt-{date}/github-comment-action-plan.md
Comment Size Limits:
Each comment should be <65K characters
If a section exceeds limit, split into multiple comments
Use clear headers to indicate which part of the report each comment contains
Step 4: Report to User
# GitHub Issue Created**Issue URL:** {url}
**Issue Number:** #{number}
## Content Posted
โ Issue created with executive summary
โ Posted {n} comments with detailed findings
## Issue Structure- Main issue: Executive summary and statistics
- Comment 1: Critical Issues (P0)
- Comment 2: High Priority Issues (P1)
- Comment 3: Medium Priority Issues (P2)
- Comment 4: Action Plan
## Next Steps1. Review the GitHub issue
2. Prioritize which issues to tackle first
3. Create separate issues for specific refactoring tasks if needed
4. Track progress using the checklist in the action plan
## Local Reports
Detailed reports are also available in:
`/tmp/tech-debt-{date}/`
Implementation Notes
GitHub CLI Usage:
Use gh issue create to create issues
Use gh issue comment to add comments
Verify gh is authenticated: gh auth status
Use --body-file for large content if needed
Content Preparation:
Inline all report content (don't use file links)
Use markdown collapsible sections (<details>) for long content
Include syntax highlighting for code snippets
Add line breaks for readability
Error Handling:
Check if gh CLI is installed and authenticated
Verify issue creation succeeded before posting comments
If comment posting fails, save remaining content to file and report to user
Don't fail entire operation if one comment fails
General Guidelines
Scanning Principles
Comprehensive Coverage
Scan all source files in turbo/ directory
Include both production and test code
Don't skip any file types (.ts, .tsx, .js, .jsx)
Efficient Execution
Use fast pattern matching first (grep, find)
Only read files that match patterns
Run searches in parallel when possible
Cache results between operations
Accurate Analysis
Read full file content for matched files
Verify patterns in context
Avoid false positives
Include line numbers for all findings
Actionable Reporting
Provide specific file paths and line numbers
Include code snippets for context
Suggest concrete remediation steps
Estimate effort for fixes
Quality Standards
Zero Tolerance Issues (P0):
TypeScript any usage
Lint suppressions (@ts-ignore, eslint-disable)
Dynamic imports
Mocking internal code (AP-4)
Missing --max-warnings 0 in lint scripts
Unjustified ESLint "off" / oxlint "allow" rules in production code
High Priority Issues (P1):
Files >1500 lines
Defensive programming patterns
Hardcoded URLs
Direct fetch mocking (AP-2)
Filesystem mocking (AP-3)
Partial internal mocks (AP-6)
Direct database operations in tests (AP-11)
Importing internal services in tests (AP-12)
initServices() in tests (AP-13)
ccstate-react/experimental in views (CS-1)
void instead of detach() (CS-2)
Manual loading boolean in signals (CS-3)
Orphaned resetSignal without parent (CS-4)
Medium Priority Issues (P2):
Files >1000 lines
Fallback patterns
Testing mock calls (AP-1)
Fake timers (AP-5)
Direct component rendering (AP-10)
Manual state synchronization (CS-5)
Low Priority Issues (P3):
Over-testing patterns
Console mocking without assertions
Communication Style
To User:
Medium level of detail (not too brief, not overwhelming)
Focus on most important findings
Provide clear next steps
Use markdown formatting
In Reports:
High level of detail
Include all findings with evidence
Provide remediation guidance
Use consistent formatting
In GitHub Issues:
Balance detail with readability
Use collapsible sections for long content
Include actionable checklists
Add appropriate labels
Error Handling
When encountering errors:
If grep/find fails, report and continue with other checks
If file is unreadable, note it and continue
If directory doesn't exist, report and skip
If gh CLI fails, report and save content to file
Always complete scan even if some steps fail
Provide partial results if full scan can't complete
Example Usage
# Run research scan
args: "research"
# Create GitHub issue from research
args: "issue"