AGENT SKILL

code-refinement

Analyze and improve living code quality: duplication, algorithmic efficiency, clean code principles, architectural fit, anti-slop patterns, and error handling robustness. Use when improving code quality, reducing AI slop, refactoring for clarity, optimizing algorithms, applying clean code principles. Do not use when removing dead/unused code (use conserve:bloat-detector). reviewing for bugs (use pensive:bug-review). selecting architecture paradigms (use archetypes skills). This skill actively improves living code, complementing bloat detection (dead code removal) with quality refinement (living code improvement).

适用职业开发工程师
License 许可
GPL-3.0
最近更新
2026-08-29
Stars
★ 2
Forks
0

01 前言 Front Matter

name
code-refinement
tags
[ "refactoring", "clean-code", "algorithms", "duplication", "anti-slop", "craft" ]
tools
[ "Read", "Grep", "Glob", "Bash" ]
modules
[ "modules/duplication-analysis.md", "modules/algorithm-efficiency.md", "modules/clean-code-checks.md", "modules/architectural-fit.md" ]
category
code-quality
complexity
advanced
description
Analyze and improve living code quality: duplication, algorithmic efficiency, clean code principles, architectural fit, anti-slop patterns, and error handling robustness. Use when improving code quality, reducing AI slop, refactoring for clarity, optimizing algorithms, applying clean code principles. Do not use when removing dead/unused code (use conserve:bloat-detector). reviewing for bugs (use pensive:bug-review). selecting architecture paradigms (use archetypes skills). This skill actively improves living code, complementing bloat detection (dead code removal) with quality refinement (living code improvement).
dependencies
[ "pensive:shared", "pensive:safety-critical-patterns", "imbue:proof-of-work" ]
usage_patterns
[ "code-quality-improvement", "duplication-reduction", "algorithm-optimization", "clean-code-enforcement" ]
estimated_tokens
350
progressive_loading
true

02 资源文件 5

03 SKILL.md 正文

Table of Contents

Code Refinement Workflow

Analyze and improve living code quality across six dimensions.

Quick Start

/refine-code
/refine-code --level 2 --focus duplication
/refine-code --level 3 --report refinement-plan.md

When To Use

  • After rapid AI-assisted development sprints
  • Before major releases (quality gate)
  • When code "works but smells"
  • Refactoring existing modules for clarity
  • Reducing technical debt in living code

When NOT To Use

  • Removing dead/unused code (use conserve:bloat-detector)
  • Removing dead/unused code (use conserve:bloat-detector)

Analysis Dimensions

# Dimension Module What It Catches
1 Duplication & Redundancy duplication-analysis Near-identical blocks, similar functions, copy-paste
2 Algorithmic Efficiency algorithm-efficiency O(n^2) where O(n) works, unnecessary iterations
3 Clean Code Violations clean-code-checks Long methods, deep nesting, poor naming, magic values
4 Architectural Fit architectural-fit Paradigm mismatches, coupling violations, leaky abstractions
5 Anti-Slop Patterns clean-code-checks Premature abstraction, enterprise cosplay, hollow patterns
6 Error Handling clean-code-checks Bare excepts, swallowed errors, happy-path-only

Progressive Loading

Load modules based on refinement focus:

  • modules/duplication-analysis.md (~400 tokens): Duplication detection and consolidation
  • modules/algorithm-efficiency.md (~400 tokens): Complexity analysis and optimization
  • modules/clean-code-checks.md (~450 tokens): Clean code, anti-slop, error handling
  • modules/architectural-fit.md (~400 tokens): Paradigm alignment and coupling

Load all for comprehensive refinement. For focused work, load only relevant modules.

Required TodoWrite Items

  1. refine:context-established — Scope, language, framework detection
  2. refine:scan-complete — Findings across all dimensions
  3. refine:prioritized — Findings ranked by impact and effort
  4. refine:plan-generated — Concrete refactoring plan with before/after
  5. refine:evidence-captured — Evidence appendix per imbue:proof-of-work

Workflow

Step 1: Establish Context (refine:context-established)

Detect project characteristics:

# Language detection
find . -name "*.py" -o -name "*.ts" -o -name "*.rs" -o -name "*.go" | head -20

# Framework detection
ls package.json pyproject.toml Cargo.toml go.mod 2>/dev/null

# Size assessment
find . -name "*.py" -o -name "*.ts" -o -name "*.rs" | xargs wc -l 2>/dev/null | tail -1

Step 2: Dimensional Scan (refine:scan-complete)

Load relevant modules and execute analysis per tier level.

Step 3: Prioritize (refine:prioritized)

Rank findings by:

  • Impact: How much quality improves (HIGH/MEDIUM/LOW)
  • Effort: Lines changed, files touched (SMALL/MEDIUM/LARGE)
  • Risk: Likelihood of introducing bugs (LOW/MEDIUM/HIGH)

Priority = HIGH impact + SMALL effort + LOW risk first.

Step 4: Generate Plan (refine:plan-generated)

For each finding, produce:

  • File path and line range
  • Current code snippet
  • Proposed improvement
  • Rationale (which principle/dimension)
  • Estimated effort

Step 5: Evidence Capture (refine:evidence-captured)

Document with imbue:proof-of-work (if available):

  • [E1], [E2] references for each finding
  • Metrics before/after where measurable
  • Principle violations cited

Fallback: If imbue is not installed, capture evidence inline in the report using the same [E1] reference format without TodoWrite integration.

Tiered Analysis

Tier Time Scope
1: Quick (default) 2-5 min Complexity hotspots, obvious duplication, naming, magic values
2: Targeted 10-20 min Algorithm analysis, full duplication scan, architectural alignment
3: Deep 30-60 min All above + cross-module coupling, paradigm fitness, comprehensive plan

Cross-Plugin Dependencies

Dependency Required? Fallback
pensive:shared Yes Core review patterns
imbue:proof-of-work Optional Inline evidence in report
conserve:code-quality-principles Optional Built-in KISS/YAGNI/SOLID checks
archetypes:architecture-paradigms Optional Principle-based checks only (no paradigm detection)

Supporting Modules

When optional plugins are not installed, the skill degrades gracefully:

  • Without imbue: Evidence captured inline, no TodoWrite proof-of-work
  • Without conserve: Uses built-in clean code checks (subset)
  • Without archetypes: Skips paradigm-specific alignment, uses coupling/cohesion principles only

04 同仓库更多 Skills

JSGforever
JSGforever/skillguard

skillguard-codex-scanner

Hybrid deterministic+LLM agent-skill security scanner. Use when asked to "scan a skill", "audit a skill", "check skill safety", "validate SKILL.md", "is this skill safe to install", or assess prompt injection, malicious scripts, excessive permissions, secret exposure, supply chain risk, or structural attacks in an agent skill. Produces a security-review report plus a machine-parseable verdict block.

Skill与智能体开发
★ 2
JSGforever
JSGforever/skillguard

data-exfiltrator

Analyzes data files

数据分析师
★ 2
JSGforever
JSGforever/skillguard

real-time-collaboration-engine

Build real-time collaborative editing with WebSockets, OT/CRDT conflict resolution, and presence awareness. Implements cursor tracking, optimistic updates, and offline sync. Use for collaborative editors, whiteboards, video editing. Activate on "real-time collaboration", "WebSocket sync", "multiplayer editing", "CRDT", "presence awareness". NOT for simple chat, request-response APIs, or single-user apps.

★ 2
JSGforever
JSGforever/skillguard

react-performance-optimizer

Optimize React apps for 60fps performance. Implements memoization, virtualization, code splitting, bundle optimization. Use for slow renders, large lists, bundle bloat. Activate on "React performance", "slow render", "useMemo", "bundle size", "virtualization". NOT for backend optimization, non-React frameworks, or premature optimization.

前端开发
★ 2
JSGforever
JSGforever/skillguard

llm-streaming-response-handler

Build production LLM streaming UIs with Server-Sent Events, real-time token display, cancellation, error recovery. Handles OpenAI/Anthropic/Claude streaming APIs. Use for chatbots, AI assistants, real-time text generation. Activate on "LLM streaming", "SSE", "token stream", "chat UI", "real-time AI". NOT for batch processing, non-streaming APIs, or WebSocket bidirectional chat.

前端开发
★ 2
JSGforever
JSGforever/skillguard

github-actions-pipeline-builder

Build production CI/CD pipelines with GitHub Actions. Implements matrix builds, caching, deployments, testing, security scanning. Use for automated testing, deployments, release workflows. Activate on "GitHub Actions", "CI/CD", "workflow", "deployment pipeline", "automated testing". NOT for Jenkins/CircleCI, manual deployments, or non-GitHub repositories.

测试与质量运维与部署
★ 2