Claude-skill-registry code-maintainer
Fix bugs, optimize performance, and maintain code quality in CClean-Killer. Use when asked to fix detection issues, false positives, false negatives, optimize scan speed, improve performance, refactor code, or do quick maintenance tasks like version bumps or linting.
git clone https://github.com/majiayu000/claude-skill-registry
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/code-maintainer" ~/.claude/skills/majiayu000-claude-skill-registry-code-maintainer && rm -rf "$T"
skills/data/code-maintainer/SKILL.mdCode Maintainer
Fix bugs, optimize performance, and maintain code quality in the CClean-Killer codebase.
Purpose
Handle day-to-day development tasks:
- Fix detection issues (false positives/negatives)
- Optimize script performance
- Quick maintenance tasks
Modes
Mode: fix
Debug and fix detection issues including false positives and false negatives.
When to use: User says "fix detection", "false positive", "false negative", "not detecting", "wrongly detecting"
Workflow:
-
Diagnose Phase
- Identify the specific issue (FP or FN)
- Run detection with verbose output:
./scripts/macos/find-parasites.sh --verbose 2>&1 | grep -i "[pattern]" ./scripts/macos/find-orphans.sh --verbose 2>&1 | grep -i "[pattern]" - Check pattern matching logic in script
-
Trace Phase
- Read the detection function in
scripts/macos/find-parasites.sh - Check
functionis_known_parasite() - Verify bundle ID extraction from plist
- Check skip patterns in
scripts/macos/lib/common.sh
- Read the detection function in
-
Fix Phase
- For false positive: Add to skip patterns or refine match
- For false negative: Add/fix pattern in KNOWN_PARASITES array
- Update
if neededknowledge/parasite-fingerprints.json
-
Verify Phase
- Run tests:
npm run test:unit - Verify fix works on real data
- Run tests:
Files Modified:
scripts/macos/find-parasites.shscripts/macos/find-orphans.sh
(SKIP_PATTERNS)scripts/macos/lib/common.shknowledge/parasite-fingerprints.jsontests/unit/test-parasite-patterns.sh
Common Issues:
| Issue | Location | Fix |
|---|---|---|
| Pattern too broad | array | Make pattern more specific |
| Pattern too narrow | array | Use broader glob pattern |
| Wrong bundle ID extraction | | Fix plist parsing |
| App check failing | | Fix mdfind or /Applications check |
| Safe item flagged | | Add to skip list |
Mode: optimize
Improve performance of scanning and detection scripts.
When to use: User says "optimize", "slow scan", "improve performance", "speed up", "benchmark"
Workflow:
-
Profile Phase
- Run benchmark:
time ./scripts/macos/scan.sh --dry-run time ./scripts/macos/find-parasites.sh --dry-run - Identify slow operations
- Run benchmark:
-
Analyze Phase
- Check for:
- Repeated file system operations
- Inefficient loops
- Missing caching
- Sequential operations that could be parallel
- Reference
for existing optimizationsscripts/macos/lib/optimized-patterns.sh
- Check for:
-
Implement Phase
- Apply optimization techniques:
# Cache app list instead of repeated mdfind declare -A APP_CACHE # Use find with -prune for skipping find "$dir" -name ".git" -prune -o -type f -print # Parallel processing find ... | xargs -P 4 ...
- Apply optimization techniques:
-
Benchmark Phase
- Compare before/after:
./scripts/benchmark.sh --compare - Document improvement in
docs/OPTIMIZATION-REPORT.md
- Compare before/after:
Files Modified:
scripts/macos/*.shscripts/macos/lib/common.shscripts/macos/lib/optimized-patterns.shdocs/OPTIMIZATION-REPORT.md
Optimization Techniques:
| Technique | When to Use | Example |
|---|---|---|
| Associative arrays | Repeated lookups | |
| Find with -prune | Skip directories | |
| Parallel xargs | Independent operations | |
| Early termination | First match sufficient | after match |
| Caching | Expensive repeated calls | Cache mdfind results |
Mode: maintain
Quick maintenance tasks: version bumps, linting, syncing, cleanup.
When to use: User says "bump version", "lint", "sync json", "cleanup", "maintenance"
Quick Tasks:
-
Version Bump
# Update version in package.json npm version patch # or minor/major -
Lint Scripts
# Check shell scripts shellcheck scripts/macos/*.sh scripts/macos/lib/*.sh -
Sync JSON Database
- Ensure
matchesparasite-fingerprints.jsoncommon-parasites.md - Update
counttotalParasites - Update
datelastUpdated
- Ensure
-
Validate Configs
# Check JSON syntax jq . knowledge/parasite-fingerprints.json > /dev/null # Check all scripts are executable find scripts -name "*.sh" ! -executable -
Clean Temp Files
rm -f scripts/**/*.bak rm -f **/*.tmp
Files Modified:
(version)package.json
(metadata)knowledge/parasite-fingerprints.json- Various (linting fixes)
Safety Rules
- ALWAYS run tests after fixes
- NEVER remove safety checks during optimization
- PRESERVE backward compatibility in function signatures
- VERIFY optimizations don't change output
- DOCUMENT non-obvious optimizations with comments
Debugging Commands
# Verbose detection output ./scripts/macos/find-parasites.sh --verbose # Dry run (no changes) ./scripts/macos/clean.sh --dry-run --all # JSON output for parsing ./scripts/macos/scan.sh --json | jq . # Test specific pattern grep -r "com.example" knowledge/ # Check if pattern matches [[ "com.google.keystone.agent" == com.google.* ]] && echo "matches"
Examples
Example 1: Fix false positive
User: "Google Chrome is being flagged as a parasite but it's installed" 1. Check detection: ./scripts/macos/find-parasites.sh --verbose | grep google 2. Find: com.google.keystone.agent flagged as zombie 3. Trace: app_exists_for_agent() not finding Chrome.app 4. Fix: Update app detection to check "Google Chrome.app" 5. Verify: Run detection again, no longer flagged
Example 2: Optimize slow scan
User: "Scanning takes 30 seconds, can we speed it up?" 1. Profile: time ./scripts/macos/scan.sh shows 25s in du calls 2. Analyze: Repeated du on same directories 3. Implement: Cache directory sizes in associative array 4. Benchmark: New time is 8 seconds 5. Document in OPTIMIZATION-REPORT.md
Related Skills
- knowledge-manager: For adding new parasites after fixing detection
- quality-assurance: For adding regression tests after fixes