fix-quality

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

/fix-quality

/fix-quality

Fix the highest priority quality infrastructure gap.
修复最高优先级的代码质量基础设施短板。

What This Does

功能说明

  1. Invoke
    /check-quality
    to audit quality gates
  2. Identify highest priority gap
  3. Fix that one issue
  4. Verify the fix
  5. Report what was done
This is a fixer. It fixes one issue at a time. Run again for next issue. Use
/quality-gates
for full setup.
  1. 调用/check-quality审核代码质量门禁
  2. 识别最高优先级的短板
  3. 修复该问题
  4. 验证修复效果
  5. 报告处理内容
这是一个修复工具,每次仅修复一个问题。如需处理下一个问题,请再次运行。使用/quality-gates进行完整配置。

Process

操作流程

1. Run Primitive

1. 运行基础命令

Invoke
/check-quality
skill to get prioritized findings.
调用/check-quality工具获取按优先级排序的问题列表。

2. Fix Priority Order

2. 修复优先级顺序

Fix in this order:
  1. P0: Missing test runner, missing CI workflow
  2. P1: Coverage, git hooks, linting, strict TypeScript
  3. P2: Commitlint, coverage in PRs
  4. P3: Tool upgrades
按以下顺序修复:
  1. P0:缺失测试运行器、缺失CI工作流
  2. P1:测试覆盖率、Git Hooks、代码检查、严格模式TypeScript
  3. P2:Commitlint、PR中的覆盖率检查
  4. P3:工具版本升级

3. Execute Fix

3. 执行修复

No test runner (P0):
bash
pnpm add -D vitest @vitest/coverage-v8
Create
vitest.config.ts
:
typescript
import { defineConfig } from 'vitest/config';

export default defineConfig({
  test: {
    globals: true,
    environment: 'node',
    coverage: {
      provider: 'v8',
      reporter: ['text', 'json', 'html'],
    },
  },
});
Add scripts to package.json:
json
{
  "scripts": {
    "test": "vitest",
    "test:run": "vitest run",
    "coverage": "vitest run --coverage"
  }
}
No CI workflow (P0): Create
.github/workflows/ci.yml
:
yaml
name: CI
on: [push, pull_request]
jobs:
  quality:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: pnpm/action-setup@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 22
          cache: 'pnpm'
      - run: pnpm install
      - run: pnpm typecheck
      - run: pnpm lint
      - run: pnpm test:run
No git hooks (P1):
bash
pnpm add -D lefthook
pnpm lefthook install
Create
lefthook.yml
:
yaml
pre-commit:
  parallel: true
  commands:
    lint:
      glob: "*.{ts,tsx}"
      run: pnpm eslint {staged_files}
    typecheck:
      run: pnpm tsc --noEmit

pre-push:
  commands:
    test:
      run: pnpm test:run
TypeScript not strict (P1): Update
tsconfig.json
:
json
{
  "compilerOptions": {
    "strict": true
  }
}
无测试运行器(P0):
bash
pnpm add -D vitest @vitest/coverage-v8
Create
vitest.config.ts
:
typescript
import { defineConfig } from 'vitest/config';

export default defineConfig({
  test: {
    globals: true,
    environment: 'node',
    coverage: {
      provider: 'v8',
      reporter: ['text', 'json', 'html'],
    },
  },
});
在package.json中添加脚本:
json
{
  "scripts": {
    "test": "vitest",
    "test:run": "vitest run",
    "coverage": "vitest run --coverage"
  }
}
无CI工作流(P0): 创建
.github/workflows/ci.yml
yaml
name: CI
on: [push, pull_request]
jobs:
  quality:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: pnpm/action-setup@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 22
          cache: 'pnpm'
      - run: pnpm install
      - run: pnpm typecheck
      - run: pnpm lint
      - run: pnpm test:run
无Git Hooks(P1):
bash
pnpm add -D lefthook
pnpm lefthook install
创建
lefthook.yml
yaml
pre-commit:
  parallel: true
  commands:
    lint:
      glob: "*.{ts,tsx}"
      run: pnpm eslint {staged_files}
    typecheck:
      run: pnpm tsc --noEmit

pre-push:
  commands:
    test:
      run: pnpm test:run
TypeScript未启用严格模式(P1): 更新
tsconfig.json
json
{
  "compilerOptions": {
    "strict": true
  }
}

4. Verify

4. 验证修复

After fix:
bash
undefined
修复完成后:
bash
undefined

Test runner works

测试运行器正常工作

pnpm test --run
pnpm test --run

Hooks installed

Hooks已安装

[ -f ".git/hooks/pre-commit" ] && echo "✓ pre-commit hook"
[ -f ".git/hooks/pre-commit" ] && echo "✓ pre-commit hook"

CI file exists

CI文件已存在

[ -f ".github/workflows/ci.yml" ] && echo "✓ CI workflow"
undefined
[ -f ".github/workflows/ci.yml" ] && echo "✓ CI workflow"
undefined

5. Report

5. 报告示例

Fixed: [P0] No test runner configured

Installed:
- vitest
- @vitest/coverage-v8

Created:
- vitest.config.ts
- Added test scripts to package.json

Verified: pnpm test runs successfully

Next highest priority: [P0] No CI workflow
Run /fix-quality again to continue.
已修复:[P0] 未配置测试运行器

已安装:
- vitest
- @vitest/coverage-v8

已创建:
- vitest.config.ts
- 已在package.json中添加测试脚本

验证结果:pnpm test运行成功

下一个最高优先级问题:[P0] 无CI工作流
再次运行/fix-quality继续处理。

Branching

分支管理

Before making changes:
bash
git checkout -b infra/quality-$(date +%Y%m%d)
修改前执行:
bash
git checkout -b infra/quality-$(date +%Y%m%d)

Single-Issue Focus

单问题聚焦

This skill fixes one issue at a time. Benefits:
  • Small, reviewable changes
  • Easy to verify each fix
  • Clear commit history
Run
/fix-quality
repeatedly to work through the backlog.
该工具每次仅修复一个问题,优势如下:
  • 更改内容小,便于代码评审
  • 易于验证每个修复效果
  • 提交历史清晰
重复运行/fix-quality逐步处理所有问题。

Related

相关工具

  • /check-quality
    - The primitive (audit only)
  • /log-quality-issues
    - Create issues without fixing
  • /quality-gates
    - Full quality setup workflow
  • /check-quality
    - 基础工具(仅审核)
  • /log-quality-issues
    - 仅记录问题不修复
  • /quality-gates
    - 完整的代码质量配置流程