AgentSkillsCN

gemini-fix

借助Gemini开展严苛的代码审查,所有问题均须逐一修复,绝不姑息。

SKILL.md
--- frontmatter
name: gemini-fix
description: Hard-ass code review via Gemini. ALL issues must be fixed. No exceptions.

/gemini-fix [path]

Hard-ass code review using Gemini. Finds issues AND fixes them. Senior Google engineer style - no handholding, no false praise, no excuses.

First: Activate Workflow

bash
mkdir -p .claude && echo '{"skill":"gemini-scan-fix","started":"'$(date -Iseconds)'"}' > .claude/active-workflow.json

Craft Standards (MANDATORY)

Fix code toward what a master craftsperson would be proud of.

When fixing issues, ensure the result looks like it was written by a skilled human engineer, not generated by AI.

AI Antipatterns to ACTIVELY FLAG AND FIX

Gemini is instructed to find these, and you MUST fix them:

  • Over-abstraction (factories/wrappers used once → inline or remove)
  • Defensive paranoia (impossible null checks → remove)
  • Reimplementing stdlib (custom utils when libraries exist → use the library)
  • Comment spam (obvious comments → delete)
  • Speculative features (unused config → remove)
  • Enterprise patterns in simple code → simplify

Human Craft Standard for Fixes

After fixing, code should:

  • Have no line a senior engineer would question
  • Be simpler than before, not more complex
  • Solve actual problems, not imaginary ones

The best fix often removes code rather than adding it.


Target

If a path argument is provided, review that file/directory. If no argument, review recently modified files (git diff/log).

Process (Two Steps)

Step 1: IDENTIFY Issues (Do Not Fix Yet)

1a. Find Code to Review

Find target files:

  • If path provided, use that
  • Otherwise, find recently modified files using git diff or git log
  • Look in: src/, lib/, app/, and project root

If NO code exists, output "no code to review" and stop.

1b. Read All Target Code

Read ALL files in scope completely. Do not skim.

1c. Call Gemini (MANDATORY)

For each file or logical group:

code
mcp__gemini-reviewer__gemini_review
  code: <paste the source code>
  focus: "general"
  context: "You are a senior Google engineer doing a hard-ass code review. No handholding, no false praise. Find: bugs, edge cases that crash, logic errors, performance problems, poor naming, unclear code, missing error handling. Flag AI-generated antipatterns: over-abstraction (factories/wrappers used once), features not requested, defensive checks for impossible cases, reimplementing stdlib, copy-paste that should be extracted, over-commenting obvious code, unnecessary config options, over-engineered types. If it wouldn't pass Google code review, flag it. Be direct and critical."

If tool unavailable, output: GEMINI_ERROR: tool not available

1d. List All Issues

Output issues in this format:

code
ISSUES_FOUND:
1. [CRITICAL] description (file:line)
2. [HIGH] description (file:line)
3. [MODERATE] description (file:line)
...

IDENTIFICATION_COMPLETE: yes

Step 2: FIX All Issues

For EACH issue:

  1. Read the file
  2. Understand the issue
  3. Use Edit tool to fix
  4. Verify fix compiles: run npm run build or npx tsc --noEmit or language-appropriate check
  5. Mark as FIXED

If you cannot fix an issue:

Document with specific reason (e.g., "requires architectural change", "in third-party code")

Maximum unfixed issues:

  • CRITICAL/HIGH: 0 allowed (must fix ALL)
  • MODERATE/LOW: 2 allowed maximum

Output Format

markdown
## Gemini Scan + Fix: [target]

### Summary

| Metric | Value |
|--------|-------|
| Files scanned | N |
| Issues found | N |
| Issues fixed | N |
| Cannot fix | N |

### Issues Fixed ✅

1. **[file:line]** [SEVERITY] — description
   - Fix applied: [what was changed]

### Cannot Fix ⚠️

1. **[file:line]** [SEVERITY] — description
   - Reason: [specific reason]

### Files Modified

| File | Changes |
|------|---------|
| path/to/file.ts | Fixed 3 issues |

---
GEMINI_RESULT: called - [N] issues found
ISSUES_FIXED: N
CANNOT_FIX: N
FIX_COMPLETE: yes

Final: Record Lessons Learned

After fixing all issues, record NEW findings so earlier phases learn from them.

Write to TWO files:

1. Project-local: .claude/phase-loop-lessons.md

Append the specific finding with file paths and context:

markdown
## {date} - {target path}
### Gemini Found (phase 6)
- {CATEGORY}: {specific description with file:line} → {which earlier phase should catch this and how}

2. Universal: workflow-skills/phase-loop-lessons.md

Read this file first. If the general pattern is already listed, skip. If it's a NEW general pattern not already covered, append it to the appropriate section (LOGIC Patterns, DESIGN Patterns, CODE_QUALITY Patterns, DUPLICATION Patterns, or Gemini False Positive Patterns). Write the general rule, not the project-specific instance:

markdown
### {Pattern Name}
- {General description of the pattern, not tied to specific files} → {how to avoid it}

Categories: LOGIC, DESIGN, CODE_QUALITY, DUPLICATION, AI_SMELL

Also record false positive patterns that Gemini consistently flags incorrectly:

markdown
- **"{pattern description}"** — {why it's not applicable in this context}

If no new lessons were learned (already in both files), skip this step.

Rules

  • MUST CALL GEMINI - This skill requires the Gemini MCP tool
  • MUST FIX - All CRITICAL and HIGH issues must be fixed
  • VERIFY - Check each fix compiles before moving on
  • NO EXCUSES - "Requires architectural change" is only valid for truly massive refactors
  • COMPLETE - Review and fix all files in scope

Forbidden

  • Marking issues as "application-level concern"
  • Saying "requires application code" without trying
  • Punting to "future work"
  • Skipping because it's "operational"
  • Making judgment calls about what's worth fixing
  • Leaving CRITICAL or HIGH issues unfixed

When to Use

  • Pre-commit quality gate
  • Before PR submission
  • After implementing a feature
  • Code cleanup with teeth

Comparison

SkillReviewsFixes
/gemini-scan✗ (read-only)
/gemini-fix✓ (mandatory)
/adversarial-review✓ (security focus)