본문으로 건너뛰기
cccskills
무료GitHub에 공개

dead-code-removal

Dead code removal via parallel scanning, reference verification, batch execution, and atomic commits. You are the ORCHESTRATOR — you scan, verify, batch, then delegate ALL removals.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(1)

  • SKILL.md6.4 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Dead Code Removal

Dead code removal via massively parallel scanning and execution. You are the ORCHESTRATOR — you scan, verify, batch, then execute all removals with atomic commits.

Rules:

  • Reference verification is law. Verify with grep/language tools before ANY removal decision.
  • Never remove entry points. Main entry files, test files, config files — off-limits.

False-positive guards — NEVER mark as dead:

  • Symbols in entry point files or barrel index re-exports
  • Symbols referenced in test files (tests are valid consumers)
  • Symbols with @public / @api doc tags
  • Hook factories (createXXXHook), tool factories (createXXXTool), plugin definitions
  • Command templates, skill definitions, config objects
  • Symbols in package exports

PHASE 1: SCAN — Find Dead Code Candidates

Run ALL of these in parallel:

Compiler/linter strict mode (primary scanner — run FIRST):

# TypeScript
npx tsc --noEmit --noUnusedLocals --noUnusedParameters 2>&1

# Python
vulture src/ --min-confidence 80

# Go
staticcheck -checks U1000 ./...

This gives you the definitive list of unused locals, imports, parameters, and types with exact file:line locations.

Orphaned file detection (run simultaneously): Find files in src/ NOT imported by any other file. Check all import statements. EXCLUDE: index files, test files, entry points, markdown, config files. Return: file paths.

Unused export detection (run simultaneously): Find exported functions/types/constants that are never imported by other files. Cross-reference: for each export, grep the symbol name across src/ — if it only appears in its own file, it's a candidate. EXCLUDE: entry point exports, test files. Return: file path, line, symbol name, export type.

Collect all results into a master candidate list.


PHASE 2: VERIFY — Reference Confirmation (Zero False Positives)

For EACH candidate from Phase 1:

# Search for all references (excluding the declaration itself)
grep -rn "symbolName" src/ --include="*.ts" | grep -v "declaration_file.ts"

# Or use language-specific tools:
#   TypeScript: ts-prune, ts-unused-exports
#   Python: vulture --min-confidence 80
#   Go: staticcheck -checks U1000

# 0 references = CONFIRMED dead
# 1+ references = NOT dead, drop from list

Also apply the false-positive guards above. Produce a confirmed list:

| # | File | Symbol | Type | Action |
|---|------|--------|------|--------|
| 1 | src/foo.ts:42 | unusedFunc | function | REMOVE |
| 2 | src/bar.ts:10 | OldType | type | REMOVE |
| 3 | src/baz.ts:7 | ctx | parameter | PREFIX _ |

Action types:

  • REMOVE — delete the symbol/import/file entirely
  • PREFIX _ — unused function parameter required by signature → rename to _paramName

If ZERO confirmed: report "No dead code found" and STOP.


PHASE 3: BATCH — Group by File for Conflict-Free Parallelism

Goal: maximize parallel execution with ZERO conflicts.

  1. Group confirmed dead code items by FILE PATH
  2. All items in the SAME file go to the SAME batch (prevents two agents editing the same file)
  3. If a dead FILE (entire file deletion) exists, it's its own batch
  4. Target 5-15 batches. If fewer than 5 items total, use 1 batch per item.

Example batching:

Batch A: [src/hooks/foo/hook.ts — 3 unused imports]
Batch B: [src/features/bar/manager.ts — 2 unused constants, 1 dead function]
Batch C: [src/tools/baz/tool.ts — 1 unused param, src/tools/baz/types.ts — 1 unused type]
Batch D: [src/dead-file.ts — entire file deletion]

Files in the same directory CAN be batched together (they won't conflict as long as no two agents edit the same file). Maximize batch count for parallelism.


PHASE 4: EXECUTE — Apply Removals

For EACH batch:

Protocol

  1. Read each file to understand exact syntax at the target lines
  2. Re-verify with grep that the symbol is still dead (another batch may have changed things)
  3. Apply the change:
    • Unused import (only symbol in line): remove entire import line
    • Unused import (one of many): remove only that symbol from the import list
    • Unused constant/function/type: remove the declaration. Clean up trailing blank lines.
    • Unused parameter: prefix with _ (do NOT remove — required by signature)
    • Dead file: delete with rm
  4. After ALL edits in this batch, run the type checker / build
  5. If build fails: git checkout -- [files] and report failure
  6. If build passes: stage ONLY your files and commit: git add [your-specific-files] && git commit -m "refactor: remove dead code from [brief file list]"
  7. Report what you removed and the commit hash

Critical Rules

  • Stage ONLY your batch's files (git add [specific files]). NEVER git add -A — other batches may be running in parallel.
  • If build fails after your edits, REVERT all changes and report. Do not attempt to fix.
  • Pre-existing test failures in other files are expected. Only the type checker / build matters for your batch.

PHASE 5: FINAL VERIFICATION

After ALL batches complete:

# Language-specific type check (must pass)
npx tsc --noEmit          # TypeScript
mypy src/                  # Python
go vet ./...               # Go

# Tests (note any NEW failures vs pre-existing)
npm test
pytest

# Build (must pass)
npm run build

Produce summary:

## Dead Code Removal Complete

### Removed
| # | Symbol | File | Type | Commit |
|---|--------|------|------|--------|
| 1 | unusedFunc | src/foo.ts | function | abc1234 |

### Skipped (verification failed)
| # | Symbol | File | Reason |
|---|--------|------|--------|

### Verification
- Type check: PASS/FAIL
- Tests: X passing, Y failing (Z pre-existing)
- Build: PASS/FAIL
- Total removed: N symbols across M files
- Total commits: K atomic commits

SCOPE CONTROL

If a specific scope is provided, narrow the scan:

  • File path → only that file
  • Directory → only that directory
  • Symbol name → only that symbol
  • all or empty → full project scan (default)

ABORT CONDITIONS

STOP and report if:

  • More than 50 candidates found (ask user to narrow scope or confirm proceeding)
  • Build breaks and cannot be fixed by reverting

Inspired by: oh-my-opencode remove-deadcode command

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Applies abstract interpretation using different abstract domains (intervals, octagons, polyhedra, sign, congruence) to statically analyze program variables and infer invariants, value ranges, and relationships. Use when analyzing program properties, inferring loop invariants, detecting potential errors, or understanding variable relationships through static analysis.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ArabelaTso/Skills-4-SE2562026년 8월 21일 업데이트

Uses abstract interpretation to automatically infer loop invariants, function preconditions, and postconditions for formal verification. Generates invariants that capture program behavior and support correctness proofs in Dafny, Isabelle, Coq, and other verification systems. Use when adding formal specifications to code, generating verification conditions, inferring contracts for functions, or discovering loop invariants for proofs.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ArabelaTso/Skills-4-SE2562026년 8월 21일 업데이트

Performs abstract interpretation over source code to infer possible program states, variable ranges, and data properties without executing the program. Reports potential runtime errors including out-of-bounds accesses, null dereferences, type inconsistencies, division by zero, and integer overflows. Use when analyzing code for potential runtime errors, performing static analysis, checking safety properties, or verifying program behavior without execution.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ArabelaTso/Skills-4-SE2562026년 8월 21일 업데이트

Performs abstract interpretation to produce summarized execution traces and high-level program behavior representations. Highlights key control flow paths, variable relationships, loop invariants, function summaries, and potential runtime states using abstract domains (intervals, signs, nullness, etc.). Use when analyzing program behavior, understanding execution paths, computing loop invariants, tracking variable ranges, detecting potential runtime errors, or generating program summaries without concrete execution.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ArabelaTso/Skills-4-SE2562026년 8월 21일 업데이트

Create ACSL (ANSI/ISO C Specification Language) formal annotations for C/C++ programs. Use this skill when working with formal verification, adding function contracts (requires/ensures), loop invariants, assertions, memory safety annotations, or any ACSL specifications. Supports Frama-C verification and generates comprehensive formal specifications for C/C++ code.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ArabelaTso/Skills-4-SE2562026년 8월 21일 업데이트

CLI-based browser automation with persistent page state using ref-based element interaction. Use when users ask to navigate websites, interact with web pages, fill forms, take screenshots, test web applications, or extract information from web pages.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ArabelaTso/Skills-4-SE2562026년 8월 21일 업데이트

ArabelaTso의 스킬 모두 보기

이 스킬의 문제 신고