Token导航 LogoToken导航TokenDH.com
研究检索操作浏览器github未标认证来源可访问许可证需确认审计通过

refactor代码重构

Agent Skill

refactor 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

275

周安装

11

GitHub Stars

公开资料未说明

下载量

89
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:refactor(代码重构)
来源仓库:https://github.com/cerico/macfair
仓库路径:skills/refactor
安装命令:
npx skills add https://github.com/cerico/macfair --skill refactor
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/cerico/macfair --skill refactor

简介

Refactor 审查当前分支代码变更质量,迭代优化至达到 90/100 评分阈值。

  • 适用于 PR 前的代码质量提升,涵盖正确性、可读性和测试覆盖检查。
  • 结合 Vitest 测试结果动态调整评分,但不运行 Playwright 端到端测试。
  • 安装前需确认项目是否配置了 pnpm vitest,否则无法执行评估。
  • 输出为改进建议列表,需人工确认后再实施具体修改。

SKILL.md

Refactor

Review code changes in current branch against main, grade the quality, and iteratively refactor until the code meets a minimum quality threshold of 90/100.

Instructions

1. Get Changed Files

git diff main --name-only

Get the full diff for context:

git diff main

2. Run Vitest

Run Vitest in CI mode before grading:

pnpm vitest run --reporter=verbose

If tests fail, factor that into the grade (deduct from Test Coverage score). Don't run Playwright - ask the user to run those manually if needed.

3. Review and Grade

Review the code changes for:

  • Correctness: Does the code do what it's supposed to?
  • TypeScript: No any, proper types, strict mode compliance (see TypeScript Check below)
  • React patterns: Proper hooks usage, client/server boundaries
  • Code style: Follows project conventions (no semicolons, proper imports)
  • Error handling: Appropriate error boundaries and handling
  • Performance: No obvious N+1 queries, unnecessary re-renders
  • Security: No vulnerabilities (XSS, injection, etc.)
  • Accessibility: Proper aria attributes, semantic HTML
  • Test coverage: New logic/features have tests, edge cases covered (checks tests exist, doesn't run them). See Test Coverage Deep Check below.
  • DRY: No unnecessary duplication
  • Clarity: Code is readable and self-documenting

Also include all checks from /preflight (dead code, git hygiene, env vars, imports, dates, etc.). A score of 90+ means preflight would pass.

Assign a letter grade (A-F) and a score out of 100.

4. Branch Logic

If score >= 90

  1. Output to terminal: "Good enough, let's ship it!"
  2. List what could have made the score higher (but don't block on it)
  3. Get the current branch name: git branch --show-current
  4. Create tmp/ directory in project root if it doesn't exist
  5. Write suggestions to tmp/{branch-name}.md with:

- Final grade and score - Summary of what's good - List of potential improvements (nice-to-have)

If score < 90

  1. Identify the issues bringing the score down
  2. Refactor the code to fix those issues
  3. After refactoring, re-review and grade again
  4. Repeat until score >= 90
  5. Then follow the >= 90 flow above

Grading Scale

GradeScore RangeMeaning
A+97-100Exceptional - production ready, exemplary code
A93-96Excellent - minor nitpicks only
A-90-92Very Good - meets quality bar
B+87-89Good - small issues to address
B83-86Above Average - some improvements needed
B-80-82Satisfactory - multiple issues
C+77-79Adequate - significant issues
C73-76Acceptable - needs work
C-70-72Below Average - substantial issues
D60-69Poor - major problems
F<60Failing - fundamental issues

Output Format

Terminal Output (always)

## Code Review: {branch-name}

> **Tests:** Vitest ran in CI mode. Playwright skipped - run manually if needed.

**Grade: {grade}** ({score}/100)

### Summary
{Brief description of what the changes do}

### What's Good
- {positive point 1}
- {positive point 2}

### Issues Found
- {file}:{line} - {issue description}

### Score Breakdown
- Correctness: {x}/15
- TypeScript: {x}/10
- React Patterns: {x}/10
- Code Style: {x}/10
- Error Handling: {x}/10
- Performance: {x}/10
- Security: {x}/10
- Test Coverage: {x}/10
- Accessibility: {x}/5
- DRY: {x}/5
- Clarity: {x}/5

{If score >= 90: "Good enough, let's ship it!"}
{If score < 90: "Refactoring to improve score..."}

Markdown File (tmp/{branch-name}.md)

Only written when score >= 90 (either initially or after refactoring):

# Code Review: {branch-name}

**Date:** {date}
**Final Grade:** {grade} ({score}/100)

## Summary
{What the changes accomplish}

## What's Good
{List of positive aspects}

## Potential Improvements
{Things that could have pushed the score higher - nice to have, not blockers}

## Refactoring History (if applicable)
{If refactoring was needed, list what was changed and score progression}

TypeScript Check

Some projects have legacy type errors in unrelated files. To check only changed files:

# Check if 'types' target is available in make output
make 2>/dev/null | grep -q 'types' && make types || pnpm tsc --noEmit

Use make types if available (checks changed files only), otherwise fall back to pnpm tsc --noEmit.

Test Coverage Deep Check

Don't just check if new helper functions have tests - trace the code path:

  1. Integration over unit: If you add a helper function getX(), find where it's called (e.g., calculateY()) and verify calculateY() has tests covering the new logic
  2. Follow the call chain: New code in utils/foo.ts → used by calculateBar() → verify calculateBar.test.ts covers the new behavior
  3. Test the behavior, not just the function: A test for getMonthsInBillingInterval() returning 3 is good, but a test proving calculateLettingInvoiceCosts() actually multiplies by 3 for quarterly is better

Example gap to catch:

  • ❌ "Added tests for getMonthsInBillingInterval()" (tests the helper)
  • ✅ "Added tests for calculateLettingInvoiceCosts() with QUARTERLY billing" (tests the integration)

Edge Case Analysis

Actively question defensive code patterns:

  1. Fallback values: When you see x?? defaultValue or x? fn(x): fallback, ask:

- What happens when the fallback is used? - Is the fallback correct for all scenarios? - Should this be an error instead of a silent default?

  1. Optional chaining: When you see obj?.prop, trace what happens when obj is null:

- Does downstream code handle the undefined correctly? - Are there tests for the null case?

  1. Type narrowing: When interfaces allow null/undefined, verify the code handles both branches

Example to catch:

const months = billing?.interval ? getMonths(billing.interval) : 1
const cost = new Decimal(billing?.rate || 0).mul(months)

Ask: "If billing is null, we get 0 * 1 = 0. Is that correct, or should this throw?"

Notes

  • Focus on meaningful improvements, not bikeshedding
  • Each refactoring iteration should target the highest-impact issues first
  • Don't over-engineer - fix what's wrong, don't add unnecessary complexity
  • If stuck in a loop (same issues keep appearing), break out and explain why
  • Maximum 5 refactoring iterations to prevent infinite loops

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

33.85%
按下载量换算30

Claude

29.11%
按下载量换算26

Cursor

20.8%
按下载量换算19

Gemini CLI

9.41%
按下载量换算8

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills