AgentSkillsCN

clean-code

构建全面的“整洁代码”工作流程,对代码库进行分析,推荐最佳实践,并在 React、Next.js 以及现代开发工具中贯彻整洁代码原则。

SKILL.md
--- frontmatter
name: clean-code
description: Comprehensive clean code workflow that analyzes codebase, recommends best practices, and applies clean code principles for React, Next.js, and modern tooling.
argument-hint: "[-a] [-e] [-s] [-r <id>] <feature/file>"
<objective> Fast, systematic clean code improvements using parallel agents. </objective>

<quick_start> Basic usage (analyze and apply clean code principles):

bash
/clean-code auth feature

Auto mode (skip confirmations):

bash
/clean-code -a dashboard

With save (output to .claude/output/clean-code/):

bash
/clean-code -s -a refactor api

What it does:

  1. Scans codebase for issues (React, Next.js, Zustand, TanStack Query)
  2. Loads relevant best practices docs
  3. Applies clean code improvements
  4. Verifies with build and tests
  5. Commits changes </quick_start>
<parameters>
FlagDescription
-aAuto mode: skip confirmations
-eEconomy mode: no subagents, direct tools only
-sSave mode: output to .claude/output/clean-code/
-rResume mode: continue from previous task
--reactForce load React 19 patterns
--nextjsForce load Next.js 15/16 patterns
--zustandForce load Zustand v5 patterns
--queryForce load TanStack Query v5 patterns
<examples> ```bash /clean-code auth feature # Basic /clean-code -a dashboard # Auto mode /clean-code -e -a fix types # Economy + auto /clean-code -s refactor api # Save outputs /clean-code -r auth-feature # Resume /clean-code --nextjs --query data # Force docs ``` </examples> </parameters> <workflow> ``` SCAN → APPLY → VERIFY │ │ │ │ │ └─ Build, test, commit │ └─ Load docs, recommend, apply └─ Parse flags, detect tech, find issues ``` </workflow>

<state_variables>

VariableTypeDescription
{task_description}stringWhat to analyze
{task_id}stringKebab-case identifier
{auto_mode}booleanSkip confirmations
{economy_mode}booleanNo subagents
{save_mode}booleanSave outputs
{detected_tech}objectTechnologies found
{issues}arrayIssues found

</state_variables>

<reference_files>

FileWhen Loaded
references/general-clean-code.mdAlways
references/react-clean-code.mdReact detected / --react
references/nextjs-clean-code.mdNext.js detected / --nextjs
references/zustand-best-practices.mdZustand detected / --zustand
references/tanstack-query-best-practices.mdNo data fetching / --query

</reference_files>

<entry_point>

Load steps/step-01-scan.md

</entry_point>

<step_files>

StepFilePurpose
01step-01-scan.mdInit + analyze
02step-02-apply.mdLoad docs + apply
03step-03-verify.mdBuild + commit

</step_files>

<execution_rules>

  • Load one step at a time
  • Use parallel agents in step-01 (unless economy mode)
  • Always run build before completing
  • Follow patterns from reference files exactly </execution_rules>

<success_criteria>

  • Technologies correctly detected (React, Next.js, Zustand, TanStack Query)
  • Issues identified and documented
  • Relevant reference docs loaded
  • Clean code improvements applied
  • Build passes without errors
  • Tests pass (if tests exist)
  • Changes committed with clear message
  • No hacks or shortcuts used </success_criteria>