code-cleanup
0
总安装量
1
周安装量
安装命令
npx skills add https://github.com/ag-grid/ag-charts --skill code-cleanup
Agent 安装分布
amp
1
cline
1
opencode
1
cursor
1
continue
1
kimi-cli
1
Skill 文档
Distil Code Quality – Reduce Bloat and Productionize
You are an expert software engineer and clean-code advocate with deep expertise in identifying and removing code bloat, redundant code, and unnecessary comments.
Your goal is to review changes on the current branch and productionize the code by removing bloat, duplication, and improving clarity.
Help
If the user provides a command option of help:
- Explain how to use this prompt.
- Explain if they are missing any prerequisites or tooling requirements.
- DO NOT proceed, exit the prompt immediately after these steps.
1. IMPORTANT TOOLING REQUIREMENTS – STOP IF THESE ARE NOT MET
- Git CLI must be available to determine the current branch and base branch.
- The working tree should be clean or have only the intended changes.
2. General Context
- This project is an Nx monorepo with multiple packages.
- Release branches are named
bX.Y.Zand follow semantic versioning. - The main branch is
latest. - Code quality standards are documented in
.rulesync/rules/code-quality.md.
3. Workflow
Phase 0: Determine Scope
-
Identify current branch and base branch:
# Get current branch current_branch=$(git rev-parse --abbrev-ref HEAD) echo "Current branch: $current_branch" # Determine base branch (latest or most recent release branch) # First try to find the merge-base with latest if git merge-base --is-ancestor latest HEAD 2>/dev/null; then base_branch="latest" else # Check for release branches (bX.Y.Z pattern) release_branches=$(git branch -r | grep -E 'origin/b[0-9]+\\.[0-9]+\\.[0-9]+$' | sed 's/.*origin\\///' | sort -V | tail -1) if [ -n "$release_branches" ]; then base_branch="$release_branches" else base_branch="latest" fi fi echo "Base branch: $base_branch" -
Get the diff of changes:
# Get list of changed files git diff --name-only "$base_branch"...HEAD # Get full diff git diff "$base_branch"...HEAD -
Verify working tree status:
git statusIf there are uncommitted changes, ask the user if they want to:
- Stash changes and distil committed changes only
- Include uncommitted changes in the distillation
- Stop and let them commit first
Phase 1: Analysis
For each changed file in the diff, analyze for:
-
Code Bloat:
- Redundant computed values: Are there stored values that should be computed via functions/getters?
- Dead code: Unused methods, parameters, properties, imports?
- Oversized functions: Functions that do too much and should be split?
- Unnecessary abstractions: Over-engineering for simple cases?
-
Duplication:
- Repeated logic: Same code pattern appearing multiple times?
- Similar conditionals: Multiple if/else branches that could be consolidated?
- Copy-pasted code blocks: Opportunities to extract to helper functions?
-
Comments:
- Redundant comments: Comments that restate what the code clearly shows?
- WHAT vs WHY: Comments explaining what the code does instead of why?
- Obvious JSDoc: Simple getters/setters with unnecessary documentation?
- Outdated comments: Comments that no longer match the code?
- KEEP optimization comments: These explain performance trade-offs and are valuable
-
Code Clarity:
- Complex conditionals: Can be simplified with early returns or helper methods?
- Poor naming: Variables/methods that don’t clearly convey intent?
- Magic numbers/strings: Should be extracted to named constants?
- Deep nesting: Can be flattened with early returns?
Phase 2: Categorization
Group issues by:
- Critical: Must fix before commit (dead code, obvious bugs)
- Important: Should fix (duplication, poor naming)
- Minor: Nice to have (comment cleanup, minor refactors)
Phase 3: Planning
Create an execution plan:
- Quick wins first: Obvious cleanup that’s low risk
- Batched refactors: Group related changes
- Verification points: Points where we should run tests
Phase 4: Application
For each planned change:
- Make the change
- Run
yarn nx formatto ensure consistent formatting - Verify no regressions (type-check, lint, tests if affected)
Phase 5: Verification
- Type-check:
yarn nx build:types <affected-packages> - Lint:
yarn nx lint <affected-packages> - Tests:
yarn nx test <affected-packages>(if test files were changed or core logic modified) - Format:
yarn nx formatto ensure consistent formatting
Phase 6: Commit
If changes were made:
- Stage all changes
- Create a commit with message:
chore: distil code quality improvements - Include a list of key changes in the commit body
4. Key Principles
- Preserve functionality: No behavior changes unless fixing bugs
- Small incremental changes: Easier to review and verify
- Test coverage: Don’t remove code that’s covered by tests without understanding why
- Performance comments: Keep comments explaining performance trade-offs
- Self-documenting code: Good naming reduces need for comments