Codebase Audit Skill
Systematic, phased codebase auditing with progressive scan → diagnose → repair workflow.
When to Use
- User requests full project review/architecture mapping
- Before major refactoring or onboarding to a new codebase
- User wants technical debt assessment with prioritization
Phased Approach
Phase 1: Architecture Mapping (Read-Only)
- Scan
pages.json / router config for page hierarchy
- Map directory structure (main package vs sub-packages/modules)
- Identify framework stack (Vue version, state management, UI libraries)
- Identify infrastructure (HTTP layer, i18n, storage, utilities)
- Count files by size — flag files >500 lines
- Output: Architecture Audit Report with page tree + infrastructure table
Phase 2: Deep Diagnostic (Read-Only)
Use Python execute_code scripts for parallel multi-dimensional scanning:
Scan 1: File Scale & API Style
# Walk project, parse Vue files, detect:
# - Mixed API styles (setup + data/methods)
# - Files >500/1000/2000 lines
# - v-for without :key, v-if+v-for on same element
# - data() with >10 properties
Scan 2: HTTP/Network Layer
# Check: config.js for hardcoded env/test flags
# Check: auth.js for token expiry handling
# Check: client.js for timeout, retry, abort mechanisms
# Check: interceptors for 401 handling
# Find direct uni.request/wx.fetch calls bypassing HTTP client
Scan 3: Lifecycle & State
# Detect onShow+mounted, onLoad+mounted mixing
# Find onShow triggering API calls (duplicate requests)
# Track uni.$emit/$on usage patterns
# Check uni.$on without corresponding uni.$off (memory leaks)
# Find pages with API calls but no login guard
Scan 4: UI/UX Consistency
# Detect hardcoded colors not using CSS variables
# Find px+rpx mixed usage in same file
# Check list components missing empty/loading states
# Count inline style="..." attributes (>5 is suspicious)
# Find console.log/warn in production code
# Detect font-size < 24rpx
# Find complex template expressions (>{{50+ chars}})
Phase 3: Auto-Repair (Write Mode)
- Only after explicit [EXECUTE] command from user
- One-step commit: one fix at a time
- Logic guard: never change core business logic
- Verification note after each fix
Prioritization Framework
| Priority |
Criteria |
Examples |
| P0 Critical |
Memory leaks, security, data corruption, production config leaks |
uni.$on without $off, hardcoded prod URLs, missing 401 handling |
| P1 High |
Giant files (>1000 lines), missing auth guards, broken lifecycle |
3000-line component, unguarded API pages, onShow+mounted duplicate |
| P2 Medium |
Missing UX states, style inconsistency, event bus overuse |
No empty state, inline styles, hardcoded colors |
| P3 Low |
Architecture improvements, optimization suggestions |
Add Pinia, extract composables, request cancellation |
Key Vue/uni-app Specific Checks
- Lifecycle mixing:
onShow/onLoad (小程序) vs onMounted (Vue) — they fire at different times
- Event leaks:
uni.$on in onMounted without uni.$off in onUnmounted
- Mixed API:
<script setup> + data()/methods() causes reactivity issues
- onShow duplicate:
onShow fires on every return from background — avoid heavy API calls
- Hardcoded env:
config.js with isTest = true without .env files
- ⚠️ uni-app 微信小程序端不支持原生
process.env 注入,需在 vite.config.js 中配置 define 或使用条件编译 #ifdef
Output Format
Always produce structured reports with:
- Specific file paths and line numbers
- Exact code snippets showing the issue
- Impact analysis
- Concrete fix recommendation
- Priority tag (P0-P3)
1---2name: codebase-audit3description: Systematic multi-phase codebase audit for technical debt, architecture mapping, and defect detection. Read-only scanning before any modifications. Supports Vue/uni-app, JS/TS projects.4domain: software-development5metadata:6 source: https://skillmd.com/skills/ichichuang/codebase-audit7---89# Codebase Audit Skill1011Systematic, phased codebase auditing with progressive scan → diagnose → repair workflow.1213## When to Use14- User requests full project review/architecture mapping15- Before major refactoring or onboarding to a new codebase16- User wants technical debt assessment with prioritization1718## Phased Approach1920### Phase 1: Architecture Mapping (Read-Only)211. Scan `pages.json` / router config for page hierarchy222. Map directory structure (main package vs sub-packages/modules)233. Identify framework stack (Vue version, state management, UI libraries)244. Identify infrastructure (HTTP layer, i18n, storage, utilities)255. Count files by size — flag files >500 lines266. Output: Architecture Audit Report with page tree + infrastructure table2728### Phase 2: Deep Diagnostic (Read-Only)29Use Python `execute_code` scripts for parallel multi-dimensional scanning:3031#### Scan 1: File Scale & API Style32```python33# Walk project, parse Vue files, detect:34# - Mixed API styles (setup + data/methods)35# - Files >500/1000/2000 lines36# - v-for without :key, v-if+v-for on same element37# - data() with >10 properties38```3940#### Scan 2: HTTP/Network Layer41```python42# Check: config.js for hardcoded env/test flags43# Check: auth.js for token expiry handling44# Check: client.js for timeout, retry, abort mechanisms45# Check: interceptors for 401 handling46# Find direct uni.request/wx.fetch calls bypassing HTTP client47```4849#### Scan 3: Lifecycle & State50```python51# Detect onShow+mounted, onLoad+mounted mixing52# Find onShow triggering API calls (duplicate requests)53# Track uni.$emit/$on usage patterns54# Check uni.$on without corresponding uni.$off (memory leaks)55# Find pages with API calls but no login guard56```5758#### Scan 4: UI/UX Consistency59```python60# Detect hardcoded colors not using CSS variables61# Find px+rpx mixed usage in same file62# Check list components missing empty/loading states63# Count inline style="..." attributes (>5 is suspicious)64# Find console.log/warn in production code65# Detect font-size < 24rpx66# Find complex template expressions (>{{50+ chars}})67```6869### Phase 3: Auto-Repair (Write Mode)70- Only after explicit [EXECUTE] command from user71- One-step commit: one fix at a time72- Logic guard: never change core business logic73- Verification note after each fix7475## Prioritization Framework76| Priority | Criteria | Examples |77|----------|----------|----------|78| P0 Critical | Memory leaks, security, data corruption, production config leaks | uni.$on without $off, hardcoded prod URLs, missing 401 handling |79| P1 High | Giant files (>1000 lines), missing auth guards, broken lifecycle | 3000-line component, unguarded API pages, onShow+mounted duplicate |80| P2 Medium | Missing UX states, style inconsistency, event bus overuse | No empty state, inline styles, hardcoded colors |81| P3 Low | Architecture improvements, optimization suggestions | Add Pinia, extract composables, request cancellation |8283## Key Vue/uni-app Specific Checks841. **Lifecycle mixing**: `onShow`/`onLoad` (小程序) vs `onMounted` (Vue) — they fire at different times852. **Event leaks**: `uni.$on` in `onMounted` without `uni.$off` in `onUnmounted`863. **Mixed API**: `<script setup>` + `data()`/`methods()` causes reactivity issues874. **onShow duplicate**: `onShow` fires on every return from background — avoid heavy API calls885. **Hardcoded env**: `config.js` with `isTest = true` without `.env` files89 - ⚠️ uni-app 微信小程序端不支持原生 `process.env` 注入,需在 `vite.config.js` 中配置 `define` 或使用条件编译 `#ifdef`9091## Output Format92Always produce structured reports with:93- Specific file paths and line numbers94- Exact code snippets showing the issue95- Impact analysis96- Concrete fix recommendation97- Priority tag (P0-P3)