Write, review and refactor code with AI

Updated 2026-11-26 20 分钟(含审查) Difficulty ★★☆☆☆Author Skills 编辑部

Skills used in this guide (3)

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

  1. Context: relevant files, conventions, goal.
  2. Standards: team coding rules (if any).
  3. Scope: what to change, acceptance.

Steps

1. Install the skill

Copy into your client's skills directory (same as any Agent Skill):

ClientDirectory
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

text
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):

text
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:

text
This legacy code repeats and is misnamed; equivalent refactor, add tests to keep behavior, commit stepwise.

Pitfalls

PitSymptomFix
Merge unreviewedLandmineReview first
No standardMessyGive rules
Big change no testRegressRefactor with tests
No contextWrongGive files
Blind trustIncidentYou 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:

相关源码

一句话结论

结论:用 AI 写代码先给编码标准,写完必做审查、该重构就重构,你做"合不合"的最终判断,别把键盘完全交给它。

References