AGENT SKILL

code-review

暂无简介

License 许可
MIT
最近更新
2026-09-06
Stars
★ 0
Forks
0

02 资源文件 5

03 SKILL.md 正文

These guidelines are working if: fewer unnecessary changes in diffs, fewer rewrites due to overcomplication, and clarifying questions come before implementation rather than after mistakes. backend, CLI). Use this skill whenever asked to build an app, create source files, scaffold a project, write production code, or develop any multi-file software system. Triggers on: "build an app", "create a project", "write the code for", "develop", "implement", "scaffold", "set up the codebase", or any request involving more than 3 source files. Apply even if the user says it's simple — the checklists here prevent the most common and painful mistakes. Do NOT skip this skill for "small" tasks; every phase has saved real projects.

Software Development Skill

Built from real lessons on what AI misses when coding without a live compiler. Every rule here was added because a real mistake happened without it.


CRITICAL PRINCIPLES (memorise these)

1. Define completeness before starting. Before writing a single line, list every file that must exist when the task is done. Never claim "complete" until every file on that list exists and every check passes.

2. Never hallucinate. If you don't know the exact API, class name, or syntax — stop and say so. Do not invent plausible-looking code that won't compile. A placeholder comment (// TODO: wire X here) is honest. Fake code isn't.

3. Verify, don't assume. After creating a file, verify it. After changing a file, re-verify it. "It should work" is not verification. Running a check is.

4. Claim done only when checks pass. Never say "complete", "all done", or "nothing missing" without running the verification pass in the relevant section below. If you can't run the check, say so explicitly.

5. The compiler is the floor. Static analysis catches ~70% of bugs. The remaining 30% only surface at compile time. Always tell the user what you can and cannot verify without compiling, and offer to fix compile errors when they share them.


PHASE 0 — Project manifest (do this before writing any code)

Before creating a single file, write the manifest in the conversation:

PROJECT: [name]
LANGUAGE/PLATFORM: [Kotlin/Android | HTML+CSS+JS | Node.js | etc.]
ARCHITECTURE: [MVVM | MVC | Clean | etc.]

FILE MANIFEST — every file that must exist when done:
  config/
    □ [build config files for this platform]
    □ [dependency file]
    □ [wrapper/bootstrap files]
  src/
    □ [entry point]
    □ [each module/screen/component]
  resources/
    □ [each required resource type]
  scripts/
    □ README.md
    □ .gitignore

DEFINITION OF DONE:
  □ All files in manifest exist
  □ All static checks pass (see platform section)
  □ No empty handler functions
  □ No unresolved internal references
  □ User told exactly what requires a real compiler to verify

PHASE 1 — Build

Rule: create files in dependency order

Build from bottom up: shared types → utilities → data layer → business logic → UI. Never reference a file you haven't created yet in the same session.

Rule: verify each file immediately after creation

After creating a file:

  1. Count opening/closing braces — they must balance
  2. Check every internal import resolves to an existing file
  3. Check every function call matches a defined signature
  4. Check every referenced resource/class/constant exists

Rule: never leave TODO functions as stubs

If a function body isn't implemented, write:

// PHASE 2: [what needs to go here and why it's deferred]
// Currently returns empty/no-op — safe because [reason]

Never leave a completely empty body without explanation.

Rule: one-time naming dictionary

Before coding, define names centrally:

  • Database class name (SigylDatabase, not AppDatabase in some files)
  • All color names (ElectricBlue, DeepNavy) and where they're defined
  • API service interface name
  • All route/destination names

Check every file uses the same names. Typos between files compile-fail.


PHASE 2 — Platform-specific checklists

Android / Kotlin

Read references/android-checklist.md before starting any Android project. It contains the complete file manifest, common compile errors, and verification scripts.

Must-have files (Android will NOT build without all of these):

[project-root]/
  build.gradle.kts          ← project-level
  settings.gradle.kts
  gradle.properties
  gradle/libs.versions.toml
  gradle/wrapper/gradle-wrapper.properties
  gradle/wrapper/gradle-wrapper.jar  ← binary, user downloads (see README)
  gradlew                   ← Unix launch script (make executable)
  gradlew.bat               ← Windows launch script
  local.properties          ← SDK path template
  .gitignore
  README.md
  TROUBLESHOOTING.md        ← document what the compiler will find

[app]/
  build.gradle.kts          ← module-level with applicationId, minSdk, etc.
  proguard-rules.pro
  src/main/AndroidManifest.xml
  src/main/kotlin/...       ← all source files
  src/main/res/
    drawable/
      ic_launcher_foreground.xml   ← adaptive icon foreground
      ic_launcher_background.xml   ← adaptive icon background
    mipmap-mdpi/ic_launcher.xml    ← required: ALL 5 DPI buckets
    mipmap-hdpi/ic_launcher.xml
    mipmap-xhdpi/ic_launcher.xml
    mipmap-xxhdpi/ic_launcher.xml
    mipmap-xxxhdpi/ic_launcher.xml
    mipmap-anydpi-v26/ic_launcher.xml       ← adaptive (API 26+)
    mipmap-anydpi-v26/ic_launcher_round.xml
    values/strings.xml     ← must have app_name
    values/colors.xml      ← ic_launcher_background color
    values/themes.xml      ← Theme.AppName with correct parent
    xml/network_security_config.xml
    xml/backup_rules.xml
    xml/data_extraction_rules.xml

Android mandatory checks — run before claiming done:

# Brace balance (basic compilation gate)
for kt in $(find . -name "*.kt"); do
  o=$(tr -cd '{' < $kt | wc -c)
  c=$(tr -cd '}' < $kt | wc -c)
  [ "$o" != "$c" ] && echo "IMBALANCED: $kt ($o vs $c)"
done

# No AppDatabase when class is named SigylDatabase (name-consistency)
grep -rn "AppDatabase" app/src/main/kotlin/ | grep -v "//.*comment"

# Runtime permissions wired (dangerous perms must have request flow)
grep -l "CAMERA\|CameraX\|PreviewView" app/src -r | while read f; do
  grep -l "ActivityResultContracts.RequestPermission\|hasCameraPermission" $f \
    || echo "MISSING PERM REQUEST: $f"
done

# Navigation parity (every Screen object must have a composable route)
defined=$(grep -c "object.*: Screen" navigation/Screen.kt)
routed=$(grep -c "composable(Screen\." navigation/NavGraph.kt)
[ "$defined" != "$routed" ] && echo "MISMATCH: $defined Screen objects, $routed routes"

# No private key in network layer
grep "getPrivateKey\|privKey" core/network/ && echo "SECURITY: private key in network layer"

Android security baseline — non-negotiable:

  • allowBackup="false" in manifest
  • android:roundIcon → @mipmap/ic_launcher_round (not ic_launcher)
  • clearTextTrafficPermitted="false" in network_security_config.xml
  • No http:// URLs in production source code (grep for them)
  • No hardcoded API keys (grep for AIza, sk_live, pk_live, ghp_)
  • Runtime permission request for every dangerous permission used
  • ProGuard rules for every reflection-using library (Hilt, Retrofit, Room, BouncyCastle)

Hilt DI verification:

  • Every @HiltViewModel class has @Inject constructor
  • Application class has @HiltAndroidApp
  • Entry point activities/fragments have @AndroidEntryPoint
  • Every @Inject-needed type has a @Provides method in a @Module
  • Workers using Hilt: @HiltWorker, @AssistedInject, app implements Configuration.Provider

Web (HTML + CSS + JS)

Read references/web-checklist.md before building any multi-page site.

Most common web mistakes:

  1. CSS padding shorthand kills horizontal layout

    /* WRONG — zero out left/right, breaks .wrap container padding */
    section { padding: 64px 0; }
    .hero    { padding: 120px 0 80px; }
    
    /* CORRECT — use longhand so horizontal padding from .wrap survives */
    section { padding-top: 64px; padding-bottom: 64px; }
    .hero   { padding-top: 120px; padding-bottom: 80px; }
    

    Check every padding: shorthand. Any with 0 as horizontal value breaks layout.

  2. Logo inconsistency If the same brand mark appears in an app AND a website, the SVG paths must be identical. Verify by checking path data d= values match character-for-character.

  3. Mobile menu must exist Every site needs a hamburger at <1024px viewport. Without it, nav links disappear. Test: set viewport to 390px, verify all pages navigable.

  4. Screenshot every breakpoint before shipping Required: 1440px, 1280px, 768px, 390px (portrait), 390px landscape. Use playwright or similar:

    for (const vp of [{w:1440,h:900},{w:768,h:1024},{w:390,h:844}]) {
      await page.setViewportSize({width:vp.w, height:vp.h});
      await page.screenshot({path: `screenshot-${vp.w}.png`});
    }
    
  5. JavaScript closing IIFE Every (function(){ ... })(); wrapper must have balanced braces. Count manually or run: node -e "require('./js/main.js'); console.log('OK')"

  6. Color palette — avoid default AI colors Before picking colors, check that you're not defaulting to:

    • Purple variants: #6B46C1, #8B5CF6, #A855F7
    • Neon cyan: #06B6D4, #22D3EE, #00FFFF These are overused. Default to warm earthy or monochromatic + 1 accent.
  7. Static site file list Every page must have: <meta viewport>, <meta theme-color>, favicon link, all CSS links, script at body close, mobile menu button.


Node.js / Backend

  • package.json must exist with all deps listed (no npm install <pkg> without saving)
  • package-lock.json should be committed
  • All require/import paths must resolve
  • Environment variables: .env.example committed, .env in .gitignore
  • No console.log left in production paths
  • No hardcoded credentials anywhere — use process.env.X

PHASE 3 — Final verification

The non-negotiable close-out checklist

Run this before delivering any project:

□ MANIFEST CHECK: every file in Phase 0 manifest exists (ls each one)
□ BRACE CHECK: all source files brace-balanced
□ EMPTY HANDLER CHECK: grep for onClick={} / fun X() {} / TODO in bodies
□ INTERNAL IMPORT CHECK: every import resolves to a real file + symbol
□ RESOURCE CHECK: every @drawable/X, @string/X, R.X references existing resource
□ NAMING CONSISTENCY: same class/function names across all files
□ ARCHITECTURE: UI never imports directly from Network/DB (must go through ViewModel → Repository)
□ SECRETS: no hardcoded API keys, passwords, tokens (grep: AIza / sk_live / Bearer)
□ HTTP: no insecure http:// URLs in production code
□ PERMISSIONS: every dangerous permission has runtime request flow
□ SECURITY BASELINE: platform-specific security requirements met
□ VERIFY SCRIPT: created and outputs 0 failures
□ README: explains setup, first run, and what user must do that I cannot do (e.g. download gradle wrapper)
□ KNOWN GAPS: explicitly documented what requires runtime/compiler to verify

PHASE 4 — Honesty protocol

What to say instead of "it's done"

DO say:

  • "Every static check passes. The following 3 things need a real compiler/runtime to verify: [list them]"
  • "Structurally complete. Open in [IDE/browser] and share any errors — I'll fix each one"
  • "Found [N] issues this pass. Fixed them. Running checks again now."

DO NOT say:

  • "The app is complete"
  • "Nothing is missing"
  • "All checks pass" (unless you literally ran them)
  • "I'm confident there are no issues"

When user pushes back ("are you sure?")

This means: you missed something. Do not defend. Do this instead:

  1. Design a new check — what category haven't I checked?
  2. Run it
  3. Report honestly — even if it finds nothing

Common categories to check when pushed back on:

  • Runtime permissions not requested
  • Cross-file naming inconsistency (class X in file A, class Y in file B)
  • Resource references to non-existent files
  • Static Context held (memory leak)
  • ProGuard not covering a reflected library
  • Missing platform-specific files (gradle wrapper, launch scripts)
  • Navigation route defined but no UI entry point
  • Hardcoded placeholder values documented as "replace before production"

PHASE 5 — Iterative fix protocol

When user reports a compile/runtime error:

  1. Read the exact error message — do not guess
  2. Find the file:line in the error
  3. Read the actual code at that location before fixing
  4. Fix only that issue — do not do a broad refactor
  5. Re-run the verification script after the fix
  6. Report: "Fixed [X]. Re-ran all checks. [N] passing, [0] new failures."

Common AI mistakes to avoid (from real experience)

Mistake How to avoid
Saying "complete" before verifying Run verify checklist, then say "checks pass"
Wrong class name across files Define naming dictionary in Phase 0, grep for inconsistencies
Missing gradle wrapper jar Document it, provide setup-gradle.sh, explain Android Studio handles it
Missing launcher icon DPI buckets Always create all 5 (mdpi/hdpi/xhdpi/xxhdpi/xxxhdpi) + anydpi-v26 + round
Runtime permissions not requested Grep for dangerous-permission usage, cross-check with request flow
CSS padding shorthand breaking layout Never use padding: X 0 Y — always use longhand padding-top/bottom
Logo different on app vs website Copy exact path data from one to the other, verify character-for-character
@drawable/ic_dialog_info flagged as missing android.R.drawable.* = system drawable, NOT a project resource. Don't flag.
Claiming Flow-returning functions should be suspend fun X(): Flow<T> is correct — Flow is lazy and doesn't need suspend
Flagging Workers for static Context @Assisted Context in Workers = WorkManager injects appContext, no leak
Every check passing but still issues Design new check categories. Static analysis has a ceiling at ~70% of bugs.

Quick reference: verification scripts by platform

See references/android-checklist.md for full Android verification script. See references/web-checklist.md for full web verification script.

Both include:

  • Copy-paste shell commands
  • What each check catches
  • Expected output for passing/failing
  • How to fix common failures

A note on trust

The user should trust running verify.sh more than trusting the AI's words.

Every project should ship with a verify.sh that the user can run themselves to confirm all checks pass — not just take the AI's word for it. This is not optional for any project over 5 files.

The verify script should exit 0 on success and print exactly what passed. If it exits non-zero, fix the failures before delivering.

04 同仓库更多 Skills