Write, review and refactor code with AI
Skills used in this guide (3)
TypeScript、JavaScript、React 与 Node.js 开发的通用编码标准、最佳实践与模式。
npx skills add sickn33/agentic-awesome-skills -g执行多轴代码审查。合并任何改动前使用。审查自己、其他 agent 或人类写的代码时使用。需要在代码进入主分支前跨多维度评估质量时使用。
npx skills add sickn33/agentic-awesome-skills -g专注整洁代码原则、SOLID 设计模式与现代软件工程最佳实践的代码重构专家。分析并重构给定代码以提升质量、可维护性与性能。
npx skills add sickn33/agentic-awesome-skills -g
Fastest way to regret AI code: "it writes fast but you dare not merge". Core: give it coding standards, then review and refactor; you make the merge call, not hand over the keyboard.
Who this is for / not for
For:
- AI-assisted writing / editing code
- Want consistent team style
- Paying tech debt, doing review
Not for:
- Merging unreviewed AI code (risk)
- No context, expect correct (misses deps)
- AI to understand business for you (you explain)
Before you start
- Context: relevant files, conventions, goal.
- Standards: team coding rules (if any).
- Scope: what to change, acceptance.
Steps
1. Install the skill
Copy into your client's skills directory (same as any Agent Skill):
| Client | Directory |
|---|---|
| Claude Code | ~/.claude/skills/ |
| Codex | ~/.codex/skills/ |
| Cursor | ~/.cursor/skills/ |
| Trae | ~/.trae/skills/ |
| CodeBuddy | ~/.codebuddy/skills/ |
| Tongyi Lingma | ~/.lingma/skills/ |
2. Write to standard with cc-skill-coding-standards
Per our coding standards (attached), add feature X under src/: input validation, error return, unit test.
Design first, then code; match existing naming.3. Review with code-review-and-quality
After writing, code-review-and-quality multi-axis (correct/secure/testable/perf):
Review the change: issues, severity, suggested fix. Don't just praise, flag what breaks.4. Refactor with code-refactoring-refactor-clean
Tech debt → code-refactoring-refactor-clean clean refactor, behavior unchanged:
This legacy code repeats and is misnamed; equivalent refactor, add tests to keep behavior, commit stepwise.Pitfalls
| Pit | Symptom | Fix |
|---|---|---|
| Merge unreviewed | Landmine | Review first |
| No standard | Messy | Give rules |
| Big change no test | Regress | Refactor with tests |
| No context | Wrong | Give files |
| Blind trust | Incident | You decide merge |
FAQ
Merge unreviewed?
No — code-review-and-quality first.
Consistent style?
Give standards, use cc-skill-coding-standards.
Safe refactor?
refactor-clean equivalent + tests.
Give context?
Yes, relevant files and conventions.
AI knows business?
No — you explain, then it writes right.
Related guides
Continue across these scenes:
- Get an AI code review worth reading
- Write test cases and automation scripts with AI
- Write technical docs and READMEs with AI
相关源码
- sickn33/agentic-awesome-skills · cc-skill-coding-standards source
- sickn33/agentic-awesome-skills · code-review-and-quality source
- sickn33/agentic-awesome-skills · code-refactoring-refactor-clean source
- Agent Skill open format spec
一句话结论
结论:用 AI 写代码先给编码标准,写完必做审查、该重构就重构,你做"合不合"的最终判断,别把键盘完全交给它。