Agent SkillsAjayIrkal23/agentic-mercy-10x › dead-code-and-change-audit

dead-code-and-change-audit

GitHub

强制在每次代码变更中执行的持续代码卫生技能,检测并清理死代码、未用引用、孤立逻辑及重复项。覆盖前后端全栈,确保代码库整洁、链接完整且生产安全,杜绝遗留垃圾代码。

skills/dead-code-and-change-audit/SKILL.md AjayIrkal23/agentic-mercy-10x

触发场景

执行任何编码任务前 进行代码修改或重构时 功能实现完成后交付前

安装

npx skills add AjayIrkal23/agentic-mercy-10x --skill dead-code-and-change-audit -g -y
更多选项

不安装直接使用

npx skills use AjayIrkal23/agentic-mercy-10x@dead-code-and-change-audit

指定 Agent (Claude Code)

npx skills add AjayIrkal23/agentic-mercy-10x --skill dead-code-and-change-audit -a claude-code -g -y

安装 repo 全部 skill

npx skills add AjayIrkal23/agentic-mercy-10x --all -g -y

预览 repo 内 skill

npx skills add AjayIrkal23/agentic-mercy-10x --list

SKILL.md

Frontmatter
{
    "name": "dead-code-and-change-audit",
    "schema": 1,
    "category": "review",
    "surfaces": [
        "backend",
        "frontend"
    ],
    "triggers": {
        "paths": [
            ".claude\/hooks\/",
            ".claude\/rules\/"
        ],
        "intents": [
            "review"
        ],
        "keywords": [
            "always-on",
            "audit",
            "behind",
            "broken",
            "change",
            "changes",
            "cleanup",
            "code",
            "continuous",
            "dead",
            "detect",
            "enforces",
            "every",
            "files",
            "hygiene",
            "imports",
            "left",
            "linkages",
            "logic",
            "orphaned",
            "partial",
            "refactors",
            "references",
            "runs",
            "skill",
            "stale",
            "task",
            "unused"
        ]
    },
    "platforms": [
        "linux",
        "darwin",
        "windows"
    ],
    "token-cost": 2213,
    "description": "ALWAYS invoke on every task and every code change — always-on code hygiene that detects dead code, stale references, orphaned logic, unused imports, unused files, broken linkages, and partial refactors. Enforces continuous cleanup so no dead code is left behind. MUST use to audit code changes for dead code, stale references, orphaned logic, and partial refactors.",
    "disable-model-invocation": false
}

DEAD CODE AND CHANGE AUDIT

OBJECTIVE

This skill must run on every coding task and every code change.

Its purpose is to continuously inspect the codebase for:

  • dead code
  • unused imports
  • unused variables
  • unused functions
  • unused components
  • unused hooks
  • unused services
  • unused API wrappers
  • unused Redux slices/selectors/thunks
  • unused routes
  • stale types/interfaces
  • orphaned helpers/utils
  • outdated constants
  • broken references after refactor
  • partially removed flows
  • leftover files from previous implementations
  • duplicate logic introduced during changes
  • unreachable branches
  • modified code paths no longer referenced anywhere

This skill exists to ensure the codebase stays clean, linked, minimal, and production-safe.


ALWAYS-ON RULE

Run this skill:

  • on every task
  • before implementation
  • during implementation
  • after implementation
  • before final delivery

This is not optional.

Do not treat cleanup as a separate later task.

Code hygiene must happen continuously while working.


PRIMARY PRINCIPLE

Whenever code is added, removed, moved, renamed, or refactored:

  • verify all references
  • verify all imports
  • verify all exports
  • verify all routes
  • verify all store linkages
  • verify all service/API usage
  • verify all type usage
  • verify all domain ownership

If something becomes unused, stale, duplicated, or orphaned, it must be cleaned immediately.

Do not leave dead code behind.


ENFORCEMENT SCOPE

This skill applies to the full codebase, including but not limited to:

Frontend

  • pages
  • routes
  • layouts
  • components
  • subcomponents
  • hooks
  • API wrappers
  • services
  • Redux slices
  • Redux thunks
  • Redux selectors
  • constants
  • helpers
  • utils
  • types
  • styles
  • assets
  • feature flags
  • guards
  • loaders
  • empty/error state components

Backend

  • route registrations
  • controllers
  • services
  • schemas
  • validators
  • models
  • repositories
  • jobs/workers
  • queues
  • event handlers
  • middleware
  • helpers
  • constants
  • DTOs/types
  • cron logic
  • integrations
  • observability hooks

Cross-layer

  • request/response contracts
  • route maps
  • domain references
  • feature toggles
  • shared utilities
  • shared types
  • docs referring to removed flows

MANDATORY EXECUTION FLOW

PHASE 1 — PRE-CHANGE AUDIT

Before making any change:

  1. Identify the exact feature, route, module, or domain being touched
  2. Identify all linked layers
  3. Identify likely dead or duplicate code around that area
  4. Inspect whether the current flow is partially deprecated already
  5. Confirm whether older files still exist from previous versions

Questions that must be answered:

  • What files currently power this feature?
  • Which files only appear related but are no longer used?
  • Are there parallel implementations?
  • Are there old slices/hooks/services still linked nowhere?
  • Are there stale routes or menu entries?
  • Are there backup components or old versions left in the repo?

Do not start editing blindly.


PHASE 2 — DURING-CHANGE LINKAGE CONTROL

While implementing:

  • remove replaced code paths
  • remove stale imports immediately
  • update all references when renaming
  • check route registrations after moving files
  • check selectors after slice changes
  • check services after API refactors
  • check schema/model references after backend refactors
  • check all callers after changing function signatures

Do not allow:

  • old and new logic to coexist without reason
  • temporary duplicate implementations
  • commented-out dead code
  • “keep for later” unused files
  • unreachable branches after condition changes
  • partially migrated code paths

Temporary code must not be left behind.


PHASE 3 — POST-CHANGE DEAD CODE SWEEP

After implementation, perform a structured cleanup sweep.

Sweep 1 — File-Level

Check for:

  • unused files
  • duplicate replacement files
  • legacy backup files
  • old components no longer imported
  • dead pages no longer routed
  • dead services no longer called
  • dead backend handlers no longer registered

Sweep 2 — Symbol-Level

Check for:

  • unused imports
  • unused exports
  • unused variables
  • unused types
  • unused interfaces
  • unused enums
  • unused constants
  • unused helper functions
  • unused selectors
  • unused thunks
  • unused hooks

Sweep 3 — Flow-Level

Check for:

  • broken route-to-page linkages
  • broken controller-to-service linkages
  • broken frontend-to-API contract usage
  • broken domain ownership after file moves
  • incomplete refactors
  • stale references in navigation/sidebar/menu
  • stale feature flags
  • stale modal/dialog trigger paths
  • stale validation schemas
  • stale query params or filters no longer used

Sweep 4 — Domain-Level

For the impacted domain, verify:

  • all active files are still needed
  • all removed behavior has been fully removed
  • no old pattern remains beside the new pattern
  • no store state is hanging without consumers
  • no backend service exists without route/use-case
  • no frontend component exists without usage

CLEANUP RULES

RULE 1 — DELETE UNUSED CODE

If code is confirmed unused and has no valid active purpose, remove it.

Do not keep dead code “just in case”.

Version control exists for history.


RULE 2 — DO NOT COMMENT OUT DEAD CODE

Never leave old implementations commented out.

Delete them.


RULE 3 — REMOVE PARTIAL REFACTOR LEFTOVERS

Whenever a flow is migrated:

  • remove old wiring
  • remove old state usage
  • remove old hooks
  • remove old API wrappers
  • remove old route links
  • remove old backend path registrations

A migration is incomplete if the old flow still lingers without purpose.


RULE 4 — REMOVE UNUSED IMPORTS IMMEDIATELY

Unused imports must never remain after edits.


RULE 5 — REMOVE DUPLICATE ABSTRACTIONS

If two helpers/services/components now do the same job because of refactor drift:

  • consolidate them
  • remove the stale one
  • keep the canonical implementation only

RULE 6 — CLEAN UNUSED TYPES

Types must be cleaned with the same discipline as logic.

Do not keep:

  • stale interfaces
  • outdated response types
  • dead DTOs
  • old form state types
  • deprecated enums
  • legacy payload shapes

RULE 7 — CLEAN ROUTE AND NAVIGATION LEFTOVERS

When pages/features are removed or replaced, also remove:

  • route definitions
  • sidebar links
  • menu entries
  • guards
  • breadcrumb config
  • page titles/meta mappings
  • role permission mappings tied only to dead routes

RULE 8 — CLEAN STORE LEFTOVERS

When frontend state changes, also check:

  • unused slice state
  • dead reducers
  • dead thunks
  • dead selectors
  • dead action creators
  • state fields no longer consumed anywhere

RULE 9 — CLEAN BACKEND LEFTOVERS

When backend logic changes, also check:

  • dead controllers
  • dead services
  • dead schemas
  • dead model methods
  • dead queue jobs
  • dead cron paths
  • dead middleware
  • dead route registrations
  • dead validators
  • dead mapper/transform helpers

RULE 10 — CLEAN DOC LEFTOVERS

If architecture, route ownership, contracts, or flow paths changed:

  • update the docs
  • remove mentions of removed flows
  • remove references to deleted modules
  • keep docs aligned with actual active code

CHANGE IMPACT CHECKLIST

For every task, explicitly verify:

  • What files were modified?
  • What files became obsolete because of those modifications?
  • What imports became unused?
  • What exports now have no consumers?
  • What hooks/services/selectors are now unreferenced?
  • What routes or controllers are now stale?
  • What types/interfaces are now outdated?
  • What duplicated logic was introduced or exposed?
  • What old flow was replaced and must be removed?
  • What docs now need cleanup?

This checklist must be completed every time.


REQUIRED ACTION STYLE

When performing changes:

  • prefer full cleanup over partial cleanup
  • prefer canonical implementations over duplicates
  • prefer removal over accumulation
  • prefer clear ownership over historical leftovers
  • prefer small focused files over stale large files

Every change should leave the codebase cleaner than before.


DELIVERY REQUIREMENT

Before marking any task complete, confirm:

  • no dead imports remain
  • no dead code introduced by this task remains
  • no replaced code path is left behind
  • no stale route/store/service wiring remains
  • no orphaned file remains in the impacted flow
  • no stale contract/type remains in the impacted area

If any of the above fails, the task is not complete.


ABSOLUTE RULE

Never finish a coding task by only making the new code work.

A task is complete only when:

  1. the feature/change works
  2. the linkage is correct
  3. the old/stale/dead code is removed
  4. the impacted domain is cleaner than before

Dead code cleanup is part of implementation, not an optional follow-up.

版本历史

  • 581d130 当前 2026-07-19 09:06

同 Skill 集合

attic/2026-07-09/skills-pre-update/taste-skill/SKILL.md
attic/2026-07-09/skills-pre-update/ui-ux-pro-max/SKILL.md
skills/agent-development/SKILL.md
skills/api-and-interface-design/SKILL.md
skills/api-contract-standards/SKILL.md
skills/architect-system-design/SKILL.md
skills/backend-api-standards/SKILL.md
skills/backend-code-review/SKILL.md
skills/backend-error-handling/SKILL.md
skills/backend-performance-standards/SKILL.md
skills/backend-standards-always-follow/SKILL.md
skills/canary-playwright/SKILL.md
skills/caveman/SKILL.md
skills/ci-cd-and-automation/SKILL.md
skills/code-execution-standard/SKILL.md
skills/code-review-and-quality/SKILL.md
skills/code-simplification/SKILL.md
skills/codebase-design/SKILL.md
skills/codebase-start-point-guide/SKILL.md
skills/command-development/SKILL.md
skills/composition-patterns/SKILL.md
skills/context-engineering/SKILL.md
skills/debug-investigation/SKILL.md
skills/debugging-and-error-recovery/SKILL.md
skills/deprecation-and-migration/SKILL.md
skills/design-extract/SKILL.md
skills/design-review-playwright/SKILL.md
skills/diagnose/SKILL.md
skills/documentation-and-adrs/SKILL.md
skills/domain-modeling/SKILL.md
skills/domain-scaffold-patterns/SKILL.md
skills/doubt-driven-development/SKILL.md
skills/dox-doc-tree/SKILL.md
skills/eval-harness/SKILL.md
skills/fix-lint-format/SKILL.md
skills/forensic-change-coupling/SKILL.md
skills/forensic-complexity-trends/SKILL.md
skills/forensic-debt-quantification/SKILL.md
skills/forensic-hotspot-finder/SKILL.md
skills/frontend-api-standards/SKILL.md
skills/frontend-code-review/SKILL.md
skills/frontend-response-handling/SKILL.md
skills/frontend-server-data-patterns/SKILL.md
skills/frontend-standards-always-follow/SKILL.md
skills/frontend-structure-standards/SKILL.md
skills/frontend-ui-engineering/SKILL.md
skills/git-workflow-and-versioning/SKILL.md
skills/golang-patterns/SKILL.md
skills/golang-testing/SKILL.md
skills/graphify/SKILL.md
skills/gsd-add-tests/SKILL.md
skills/gsd-ai-integration-phase/SKILL.md
skills/gsd-audit-fix/SKILL.md
skills/gsd-audit-milestone/SKILL.md
skills/gsd-audit-uat/SKILL.md
skills/gsd-autonomous/SKILL.md
skills/gsd-capture/SKILL.md
skills/gsd-cleanup/SKILL.md
skills/gsd-code-review/SKILL.md
skills/gsd-complete-milestone/SKILL.md
skills/gsd-config/SKILL.md
skills/gsd-debug/SKILL.md
skills/gsd-discuss-phase/SKILL.md
skills/gsd-docs-update/SKILL.md
skills/gsd-eval-review/SKILL.md
skills/gsd-execute-phase/SKILL.md
skills/gsd-explore/SKILL.md
skills/gsd-extract-learnings/SKILL.md
skills/gsd-fast/SKILL.md
skills/gsd-forensics/SKILL.md
skills/gsd-graphify/SKILL.md
skills/gsd-health/SKILL.md
skills/gsd-import/SKILL.md
skills/gsd-inbox/SKILL.md
skills/gsd-ingest-docs/SKILL.md
skills/gsd-manager/SKILL.md
skills/gsd-map-codebase/SKILL.md
skills/gsd-milestone-summary/SKILL.md
skills/gsd-mvp-phase/SKILL.md
skills/gsd-new-milestone/SKILL.md
skills/gsd-new-project/SKILL.md
skills/gsd-ns-context/SKILL.md
skills/gsd-ns-ideate/SKILL.md
skills/gsd-ns-manage/SKILL.md
skills/gsd-ns-review/SKILL.md
skills/gsd-ns-workflow/SKILL.md
skills/gsd-pause-work/SKILL.md
skills/gsd-phase/SKILL.md
skills/gsd-plan-phase/SKILL.md
skills/gsd-plan-review-convergence/SKILL.md
skills/gsd-pr-branch/SKILL.md
skills/gsd-profile-user/SKILL.md
skills/gsd-progress/SKILL.md
skills/gsd-quick/SKILL.md
skills/gsd-resume-work/SKILL.md
skills/gsd-review-backlog/SKILL.md
skills/gsd-review/SKILL.md
skills/gsd-secure-phase/SKILL.md
skills/gsd-ship/SKILL.md
skills/gsd-sketch/SKILL.md
skills/gsd-spec-phase/SKILL.md
skills/gsd-spike/SKILL.md
skills/gsd-stats/SKILL.md
skills/gsd-surface/SKILL.md
skills/gsd-thread/SKILL.md
skills/gsd-ui-phase/SKILL.md
skills/gsd-ui-review/SKILL.md
skills/gsd-ultraplan-phase/SKILL.md
skills/gsd-undo/SKILL.md
skills/gsd-update/SKILL.md
skills/gsd-validate-phase/SKILL.md
skills/gsd-verify-work/SKILL.md
skills/gsd-workspace/SKILL.md
skills/gsd-workstreams/SKILL.md
skills/huashu-design/SKILL.md
skills/improve-codebase-architecture/SKILL.md
skills/incremental-implementation/SKILL.md
skills/iterative-retrieval/SKILL.md
skills/lean-ctx/SKILL.md
skills/mcp-builder/SKILL.md
skills/mcp-usage-standards/SKILL.md
skills/mmx-cli/SKILL.md
skills/owasp-security/SKILL.md
skills/pdf/SKILL.md
skills/performance-optimization/SKILL.md
skills/plan-exec-stack-guide/SKILL.md
skills/plan-mode-gate/SKILL.md
skills/planning-and-task-breakdown/SKILL.md
skills/postgres-patterns/SKILL.md
skills/project-reference-linkage/SKILL.md
skills/project-structure-map/SKILL.md
skills/qa-playwright/SKILL.md
skills/react-hooks-patterns/SKILL.md
skills/resolving-merge-conflicts/SKILL.md
skills/santa-review/SKILL.md
skills/scaffold-standards/SKILL.md
skills/security-and-hardening/SKILL.md
skills/service-layer-standards/SKILL.md
skills/shadcn/SKILL.md
skills/shipping-and-launch/SKILL.md
skills/skill-linkage-story/SKILL.md
skills/source-driven-development/SKILL.md
skills/spec-driven-development/SKILL.md
skills/strategic-compact/SKILL.md
skills/tailwind-design-system/SKILL.md
skills/taste-skill/SKILL.md
skills/tdd/SKILL.md
skills/tech-debt-audit/SKILL.md
skills/test-driven-development/SKILL.md
skills/tool-and-doc-selection/SKILL.md
skills/using-agent-skills/SKILL.md
skills/verification-loop/SKILL.md
skills/vite-react-best-practices/SKILL.md
skills/web-design-guidelines/SKILL.md
skills/webapp-testing/SKILL.md
skills/workflow-orchestrator/SKILL.md
skills/zoom-out/SKILL.md
attic/2026-07-09/skills-pre-update/huashu-design/SKILL.md
attic/2026-07-09/skills-pre-update/impeccable/SKILL.md
skills/browser-testing-with-devtools/SKILL.md
skills/codebase-intel-first/SKILL.md
skills/docx/SKILL.md
skills/find-skills/SKILL.md
skills/gsd-help/SKILL.md
skills/gsd-ns-project/SKILL.md
skills/gsd-settings/SKILL.md
skills/higgsfield-generate/SKILL.md
skills/higgsfield-marketplace-cards/SKILL.md
skills/higgsfield-product-photoshoot/SKILL.md
skills/higgsfield-soul-id/SKILL.md
skills/higgsfield-websites/SKILL.md
skills/impeccable/SKILL.md
skills/jcodemunch-token-saver/SKILL.md
skills/pptx/SKILL.md
skills/tdd-auto-init/SKILL.md
skills/ui-ux-pro-max/SKILL.md
skills/update-docs/SKILL.md
skills/xlsx/SKILL.md
skills/autoplan/SKILL.md
skills/benchmark/SKILL.md
skills/browse/SKILL.md
skills/careful/SKILL.md
skills/connect-chrome/SKILL.md
skills/context-restore/SKILL.md
skills/design-consultation/SKILL.md
skills/design-html/SKILL.md
skills/design-review/SKILL.md
skills/design-shotgun/SKILL.md
skills/diagram/SKILL.md
skills/document-generate/SKILL.md
skills/freeze/SKILL.md
skills/guard/SKILL.md
skills/investigate/SKILL.md
skills/ios-clean/SKILL.md
skills/ios-design-review/SKILL.md
skills/ios-sync/SKILL.md
skills/landing-report/SKILL.md
skills/make-pdf/SKILL.md
skills/open-gstack-browser/SKILL.md
skills/pair-agent/SKILL.md
skills/plan-design-review/SKILL.md
skills/plan-devex-review/SKILL.md
skills/plan-tune/SKILL.md
skills/qa/SKILL.md
skills/setup-browser-cookies/SKILL.md
skills/setup-deploy/SKILL.md
skills/setup-gbrain/SKILL.md
skills/ship/SKILL.md
skills/skillify/SKILL.md
skills/spec/SKILL.md
skills/sync-gbrain/SKILL.md
skills/unfreeze/SKILL.md
skills/benchmark-models/SKILL.md
skills/canary/SKILL.md
skills/codex/SKILL.md
skills/context-save/SKILL.md
skills/cso/SKILL.md
skills/devex-review/SKILL.md
skills/document-release/SKILL.md
skills/gstack-upgrade/SKILL.md
skills/health/SKILL.md
skills/ios-fix/SKILL.md
skills/ios-qa/SKILL.md
skills/land-and-deploy/SKILL.md
skills/learn/SKILL.md
skills/office-hours/SKILL.md
skills/plan-ceo-review/SKILL.md
skills/plan-eng-review/SKILL.md
skills/qa-only/SKILL.md
skills/retro/SKILL.md
skills/review/SKILL.md
skills/scrape/SKILL.md

元信息

文件数
0
版本
fc73590
Hash
c1c14755
收录时间
2026-07-19 09:06

首页 - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-07-23 05:43
浙ICP备14020137号-1 $访客地图$