| name | deep-insight |
| description | Use when the user wants a code-metrics + complexity + dependency analysis report on a target file/directory/glob. Triggers on `/deep-insight`, "code insight", "complexity report", "code metrics", "๋ฉํธ๋ฆญ ๋ถ์", "๋ณต์ก๋ ๋ฆฌํฌํธ", "์์กด์ฑ ๋ถ์", or auto-invocation by `/deep-test` as the Insight Tier of the 3-tier Quality Gate (never blocks). Analysis-only โ does NOT modify code. Saves results to `$WORK_DIR/insight-report.md` when run inside a deep-work session, prints inline otherwise. |
| user-invocable | true |
Invocation
์ด ์คํฌ์ ๋ ๊ฐ์ง ๊ฒฝ๋ก๋ก ํธ์ถ๋ฉ๋๋ค โ ์ด๋ ์ชฝ์ด๋ ๋ณธ SKILL ๋ณธ๋ฌธ์ ์ ์ฐจ๋ฅผ ๊ทธ๋๋ก ์คํํฉ๋๋ค:
- Claude Code ์ฌ๋์ โ ์ฌ์ฉ์๊ฐ
/deep-insight [args...] ์
๋ ฅ (skill ์ user-invocable: true ๊ฐ ์ฌ๋์ ์ง์
์ ํ์ฉ).
- ํ ์์ด์ ํธ / Codex / Copilot CLI / Gemini CLI / SDK โ
Skill({ skill: "deep-work:deep-insight", args: "..." }) ํํ๋ก ๋ช
์ invoke (cross-platform ํ์ค ๊ฒฝ๋ก).
๋ ๊ฒฝ๋ก ๋ชจ๋ args ๋ ๋์ผํ ํ ํฐ ๋ฌธ์์ด๋ก ์ ๋ฌ๋๋ฉฐ, ๋ณธ๋ฌธ ($ARGUMENTS ์๋ฆฌ) ์ ํ์๊ฐ ๋์ผํ๊ฒ ์ฒ๋ฆฌํฉ๋๋ค.
Inputs (skill args)
| ์ธ์ | ์๋ฏธ |
|---|
| (์์) | Auto-detect scope: ํ์ฑ ์ธ์
์ changed files, ์์ผ๋ฉด ํ์ฌ ๋๋ ํฐ๋ฆฌ |
<target> | File path / directory / glob pattern |
๋น args / ๋งค์นญ๋์ง ์๋ ํ ํฐ โ ๋ณธ๋ฌธ์ default ๋ถ๊ธฐ๋ก ์ง์
.
Prerequisites
์ด entry skill ์ deep-work-orchestrator (Phase dispatch) ๋ฐ deep-work-workflow (reference skill โ Phase ๊ท์ฝ/Exit Gate/M3 envelope) ์ ํจ๊ป ๋์ํฉ๋๋ค. ํ์ฑ deep-work ์ธ์
์ด ์์ ๋๋ ์ธ์
state file (.claude/deep-work.<SESSION_ID>.md) ์ ๋ณ์ (work_dir, current_phase, active_slice ๋ฑ) ๋ฅผ ์ฝ์ด ๋์ํ๋ฉฐ, ์ธ์
์ธ๋ถ์์๋ standalone ์คํ์ด ๊ฐ๋ฅํ ๊ฒฝ์ฐ ๋ณธ๋ฌธ์ ๋ถ๊ธฐ๋ฅผ ๋ฐ๋ฆ
๋๋ค.
Cross-platform self-containment: Claude Code ์์๋ sibling skill ์ด description ๋งค์นญ์ผ๋ก ์๋ ๋ก๋๋ฉ๋๋ค. Codex / Copilot CLI / Gemini CLI / Agent SDK ์์ Skill() ๋ก ํธ์ถ ์ sibling auto-load ๋ณด์ฅ์ด ์ฝํ ์ ์์ผ๋ฏ๋ก, ๋ณธ๋ฌธ์ self-contained ์ผ๋ก ๋ณด์กด๋์ด ์์ต๋๋ค โ state file ํด์, $ARGUMENTS ํ์ฑ, AskUserQuestion ๋ถ๊ธฐ, ์ถ๋ ฅ ํฌ๋งท์ด ์ธ๋ผ์ธ.
Quality Gate (v6.2.4) โ /deep-test๊ฐ Insight Tier๋ก ์๋ ์คํํฉ๋๋ค (์ฐจ๋จ ์์). ํน์ ๋์์ ๋ฉํธ๋ฆญ/๋ณต์ก๋/์์กด์ฑ ๋ถ์์ด ํ์ํ ๋ ์ง์ ์ฌ์ฉํ์ธ์.
Standalone: /deep-insight [target]
Code Insight Analysis
You are performing a Code Insight Analysis โ measuring code metrics, complexity indicators, and dependency patterns to provide informational reports. This is the Insight tier of the 3-tier Quality Gate system.
Critical Constraints
- DO NOT modify any code files. This is an analysis-only operation.
- Read, analyze, and report findings.
- Insight results NEVER block the workflow. They are purely informational.
- Save analysis results to file when in workflow mode.
Instructions
1. Determine operating mode
Resolve the current session's state file:
- If
DEEP_WORK_SESSION_ID env var is set โ .claude/deep-work.${DEEP_WORK_SESSION_ID}.md
- If
.claude/deep-work-current-session pointer file exists โ read session ID โ .claude/deep-work.${SESSION_ID}.md
- Legacy fallback โ
.claude/deep-work.local.md
Set $STATE_FILE to the resolved path.
Check if $STATE_FILE exists and has an active session (current_phase is not idle and not empty).
Workflow Mode (active deep-work session):
- Read
work_dir from the state file
- Set
WORK_DIR to the value of work_dir
- Read
$WORK_DIR/plan.md to extract the list of files (from "Files to Modify" section)
- Cross-reference with actual changes:
git diff --name-only from baseline
- If
$WORK_DIR/file-changes.log exists, use it for additional file tracking data
- Analysis scope: files listed in plan.md that were actually modified
Standalone Mode (no active session):
- If
$ARGUMENTS is provided: use as target (file path, directory, or glob pattern)
- If
$ARGUMENTS is empty: detect scope automatically:
- Check
git diff --name-only HEAD~1 for recently changed files
- If not a git repo or no changes, use current directory
- Analysis scope: all code files in detected scope (exclude node_modules, .git, pycache, build, dist, .next, vendor, etc.)
2. Collect analysis targets
Gather the list of files to analyze. For each file:
- Skip files that are clearly not code (README.md, .json config, .env, .lock, etc.)
- Skip files smaller than 3 lines (trivial)
- Skip auto-generated files (migrations, lock files, bundled output, .min.js)
If the total number of files exceeds 50, prioritize:
- Files with the most lines of code
- Files modified most recently
- Files explicitly listed in plan.md (workflow mode)
Display progress:
โน๏ธ Insight ๋ถ์ ๋์: [N]๊ฐ ํ์ผ
- src/auth/service.ts (245 lines)
- src/models/user.ts (180 lines)
- ...
If exceeding 50 files:
โ ๏ธ ๋ถ์ ๋์์ด 50๊ฐ๋ฅผ ์ด๊ณผํฉ๋๋ค. ์์ 50๊ฐ ํ์ผ๋ง ๋ถ์ํฉ๋๋ค.
3. Run built-in analyses
Execute 4 categories of analysis. Each analysis should be resilient โ if one fails, continue with the rest.
3A. File Metrics
For each target file, measure:
- Lines of code (excluding blank lines and comment-only lines)
- Function/method count: Use
grep -c patterns appropriate for the language:
- JS/TS:
function , => {, method definitions in classes
- Python:
def
- Go:
func
- Rust:
fn
- Java/Kotlin: method patterns
- Other: best-effort grep
- Export count (JS/TS:
export , Python: __all__, Go: uppercase functions)
Generate summary table:
## A. ํ์ผ ๋ฉํธ๋ฆญ
| ํ์ผ | ์ฝ๋ ์ค ์ | ํจ์ ์ | Export ์ |
|------|-----------|---------|----------|
| src/auth.ts | 245 | 12 | 5 |
| src/db.ts | 180 | 8 | 3 |
**ํฉ๊ณ**: ์ฝ๋ 425์ค, ํจ์ 20๊ฐ, Export 8๊ฐ
3B. Complexity Indicators
For each target file, check:
- Long files: files exceeding 300 lines โ flag with line count
- Long functions: functions exceeding 50 lines โ identify function name and line range
- Use heuristic: find function declarations, then count lines until matching closing brace/dedent
- Deep nesting: maximum indentation depth (count leading spaces/tabs)
- Threshold: > 4 levels of nesting
Generate findings:
## B. ๋ณต์ก๋ ์งํ
### ๋ํ ํ์ผ (300์ค ์ด๊ณผ)
| ํ์ผ | ์ค ์ | ์ํ |
|------|------|------|
| src/auth.ts | 456 | โ ๏ธ ๋ํ |
### ์ฅํจ์ (50์ค ์ด๊ณผ)
| ํ์ผ | ํจ์๋ช
| ์ค ์ |
|------|--------|------|
| src/auth.ts | handleLogin | 82 |
### ๊น์ ์ค์ฒฉ (4๋จ๊ณ ์ด๊ณผ)
| ํ์ผ | ์ต๋ ๊น์ด | ์์น |
|------|----------|------|
| src/parser.ts | 6 | line 45-78 |
**์์ฝ**: ๋ํ ํ์ผ N๊ฐ, ์ฅํจ์ N๊ฐ, ๊น์ ์ค์ฒฉ N๊ฐ
If no issues found for a subcategory, display: "์์ โ
"
3C. Dependency Analysis
For each target file, parse import/require statements:
- JS/TS:
import ... from '...', require('...')
- Python:
import ..., from ... import ...
- Go:
import "...", import (...)
- Other: best-effort pattern matching
Build a simple adjacency list of internal dependencies (skip external packages).
Check for:
- Circular dependencies: Simple DFS cycle detection among internal modules
- If cycles found, list each cycle as:
A โ B โ C โ A
- Import depth: Maximum chain length in the dependency graph
- Hub files: Files imported by 5+ other files (potential coupling hotspot)
Generate findings:
## C. ์์กด์ฑ ๋ถ์
### Import ํต๊ณ
| ํ์ผ | Import ์ | ๋ด๋ถ | ์ธ๋ถ |
|------|----------|------|------|
| src/auth.ts | 8 | 3 | 5 |
### ์ํ ์ฐธ์กฐ
์์ โ
(or: โ ๏ธ ์ํ ์ฐธ์กฐ ๋ฐ๊ฒฌ: src/a.ts โ src/b.ts โ src/a.ts)
### Hub ํ์ผ (5+ ์ฐธ์กฐ)
| ํ์ผ | ์ฐธ์กฐ ์ |
|------|---------|
| src/utils.ts | 12 |
### Import ๊น์ด
์ต๋ Import ์ฒด์ธ: 4 (src/page.ts โ src/auth.ts โ src/db.ts โ src/config.ts)
3D. Change Summary (workflow mode only)
Only execute this section when in workflow mode with an active session.
Read $WORK_DIR/file-changes.log if it exists, or fall back to git diff --stat.
Generate:
## D. ๋ณ๊ฒฝ ์์ฝ
| ํญ๋ชฉ | ๊ฐ |
|------|---|
| ์ด ๋ณ๊ฒฝ ํ์ผ ์ | N |
| ์ ๊ท ์์ฑ | N |
| ์์ | N |
| ์ญ์ | N |
| ์ถ๊ฐ ์ค ์ | +N |
| ์ญ์ ์ค ์ | -N |
### ํ์ผ๋ณ ์์ ํ์ (file-changes.log ๊ธฐ์ค)
| ํ์ผ | ์์ ํ์ |
|------|----------|
| src/auth.ts | 5 |
| src/db.ts | 3 |
If neither file-changes.log nor git data is available, display:
๋ณ๊ฒฝ ๋ฐ์ดํฐ ์์ โ git diff ๋๋ file-changes.log๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค.
4. Execute user-defined Insight gates (workflow mode)
If in workflow mode and $WORK_DIR/plan.md contains a Quality Gates table with โน๏ธ markers:
- Parse each โน๏ธ gate: extract gate name and command
- Execute each command
- Record the result (output, exit code) โ but NEVER treat failure as blocking
- Include results in the Insight Gates section
## ์ฌ์ฉ์ ์ ์ Insight Gates
| Gate | ๋ช
๋ น์ด | ๊ฒฐ๊ณผ | ์ถ๋ ฅ |
|------|--------|------|------|
| Complexity Score | `npx complexity-report` | โน๏ธ INFO | score: 12.3 |
If a user-defined Insight gate command fails:
| Gate Name | `command` | โน๏ธ SKIP | ๋ช
๋ น์ด ์คํ ์คํจ (exit code: N) |
5. Generate overall summary
Combine all analyses into a concise overview:
## ์ข
ํฉ ์ธ์ฌ์ดํธ ์์ฝ
| ์นดํ
๊ณ ๋ฆฌ | ํต์ฌ ์์น | ์ฃผ๋ชฉ ํฌ์ธํธ |
|----------|----------|------------|
| ํ์ผ ๋ฉํธ๋ฆญ | Nํ์ผ, N์ค, Nํจ์ | โ |
| ๋ณต์ก๋ | ๋ํ N / ์ฅํจ์ N / ๊น์ ์ค์ฒฉ N | [๊ฐ์ฅ ์ฌ๊ฐํ ํญ๋ชฉ] |
| ์์กด์ฑ | ์ํ ์ฐธ์กฐ N / Hub N / ์ต๋ ๊น์ด N | [๊ฐ์ฅ ์ฌ๊ฐํ ํญ๋ชฉ] |
| ๋ณ๊ฒฝ ์์ฝ | +N/-N์ค, Nํ์ผ | โ |
**ํ์ **: โน๏ธ Insight โ ์ํฌํ๋ก์ฐ ์ฐจ๋จ ์์, ์ฐธ๊ณ ์ฉ ์ ๋ณด ์ ๊ณต
6. Save results
Workflow Mode:
Standalone Mode:
- Display full results in terminal
- Ask user: "๋ถ์ ๊ฒฐ๊ณผ๋ฅผ ํ์ผ๋ก ์ ์ฅํ ๊น์? (๊ธฐ๋ณธ: ์๋์ค)"
- If yes, save to
./insight-report.md
7. Workflow integration (workflow mode only)
If called as a Quality Gate during Test phase:
- Record results in
quality-gates.md as Insight entry
- Results do NOT affect pass/fail determination โ always informational only
If called outside the Test phase:
- Still run the analysis
- Note: "deep-work ์ํฌํ๋ก์ฐ ํ์ฑ โ ๊ฒฐ๊ณผ๊ฐ $WORK_DIR/insight-report.md์ ์ ์ฅ๋ฉ๋๋ค"
8. Error resilience
If any analysis section fails (e.g., no git repo, unsupported language):
- Log the error inline:
โ ๏ธ [Section Name] ๋ถ์ ์คํจ: [reason]
- Continue with remaining analyses
- NEVER abort the entire analysis due to a single section failure
- NEVER return a non-zero/blocking result