code-quality

GitHub

用于静态Web服务器项目的代码质量审查与自测技能,涵盖正确性、并发、可维护性等标准。在PR审查、实现完成或重构时加载,确保符合工程规范与检查清单。

.agents/skills/code-quality/SKILL.md static-web-server/static-web-server

触发场景

审查代码差异或PR 完成功能实现后自检 规划代码重构

安装

npx skills add static-web-server/static-web-server --skill code-quality -g -y
更多选项

非标准路径

npx skills add https://github.com/static-web-server/static-web-server/tree/master/.agents/skills/code-quality -g -y

不安装直接使用

npx skills use static-web-server/static-web-server@code-quality

指定 Agent (Claude Code)

npx skills add static-web-server/static-web-server --skill code-quality -a claude-code -g -y

安装 repo 全部 skill

npx skills add static-web-server/static-web-server --all -g -y

预览 repo 内 skill

npx skills add static-web-server/static-web-server --list

SKILL.md

Frontmatter
{
    "name": "code-quality",
    "description": "Review or self-check a change to the Static Web Server (SWS) project before it is called done — correctness, invariants, API design, concurrency, maintainability, and an SWS-specific review checklist. Use when reviewing a PR or diff, finishing an implementation, or refactoring."
}

Code Quality and Review

The engineering principles in AGENTS.md (correctness first, every change has a test, explicit invariants, own regressions, evidence over assumptions) apply to every change. This skill turns them into review criteria. Coding mechanics live in rust-backend/SKILL.md.

When to load: reviewing a diff or PR, finishing a change before reporting it done, or planning a refactor.

Definition of Done

A change is done when all of these hold, verified by running them, not by inspection:

  1. cargo fmt --all -- --check tests/*.rs passes
  2. cargo clippy with -D warnings passes for --features all and --no-default-features, with and without --tests
  3. cargo test --features all and cargo test --no-default-features pass
  4. A new or changed test fails without the change and passes with it
  5. Public items have doc comments (#![deny(missing_docs)])
  6. User-visible behavior changes have a CHANGELOG.md entry and a note about the docs repo update
  7. The commit message follows docs/COMMITS.md

If a step was skipped or fails, say so in the report with the output.

Principles

Correctness and Invariants

  • Encode invariants in types where practical (enums over boolean pairs, newtypes for validated values)
  • Validate external input at the boundary: config at startup, request data in the step that parses it
  • Fail fast on impossible states during startup; on the request path, map them to a status code and log
  • Don't mask a defect with a defensive fallback. If a branch "can't happen", say why in a comment or make it unrepresentable

Explicitness

  • Control flow, ownership, and side effects are visible at the call site
  • No hidden defaults: a default lives in settings/cli.rs and is documented in --help
  • Same input, same output. Time, filesystem state, and randomness are explicit inputs

Concurrency

  • No locks held across .await. Keep critical sections short
  • Shared config is immutable (Arc<RequestHandlerOpts>); per-thread state uses thread_local!
  • Cancellation (client disconnect, shutdown) leaves no partial state: caches insert only complete entries

Maintainability

  • Small functions with one job; modules organized by feature, matching the existing layout
  • Remove duplication with a real abstraction, not indirection. Three similar call sites are fine; a shared helper with flags is not
  • Refactor when a fix needs another special case; don't stack conditions
  • Keep refactors out of bug-fix PRs

SWS Review Checklist

Pipeline and HTTP

  • New steps sit at a justified position in the pipeline (design/SKILL.md), after basic auth if they expose data
  • Post-processing remains additive; custom headers still apply last
  • HEAD mirrors GET headers; OPTIONS and disallowed methods behave as before
  • Error statuses are deliberate: 404 for traversal/hidden, 403 only for symlink policy

Configuration

  • New options work via CLI, env, and TOML, and TOML-over-CLI precedence holds
  • Validation runs at startup with a clear error message
  • Defaults are secure and match the docs

Features and Build

  • Optional code is feature-gated, including fields, constructors, imports, and tests
  • --no-default-features builds without dead-code or unused-import errors
  • New dependencies are justified and within the binary-size budget

Security and Performance

  • Every request-derived path goes through sanitize_path() and security::enforce()
  • No panics reachable from request input (unwrap, indexing, overflow)
  • No new per-request syscalls, allocations, or regex/glob compilation without a measurement

Tests and Docs

  • Tests cover the change, its error path, and the feature-off path
  • Doc comments explain why for non-obvious code; no commented-out code
  • CHANGELOG and commit message follow project conventions (prose/SKILL.md)

Writing Review Feedback

  • Lead with correctness and security findings; style last
  • Cite file:line and give a concrete failing input or scenario for each bug
  • Separate "must fix" from "suggestion"
  • Verify a suspected bug with a test or a reproduction before reporting it as confirmed

版本历史

  • a1500d4 当前 2026-10-20 05:08
  • 21dc11b 2026-08-20 17:42

同 Skill 集合

.agents/skills/design/SKILL.md
.agents/skills/issue-tracking/SKILL.md
.agents/skills/performance/SKILL.md
.agents/skills/prose/SKILL.md
.agents/skills/rust-backend/SKILL.md
.agents/skills/security/SKILL.md
.agents/skills/static-file-serving/SKILL.md
.agents/skills/testing/SKILL.md

元信息

文件数
0
版本
a1500d4
Hash
248591c9
收录时间
2026-08-20 17:42

首页 - Wiki
Copyright © 2011-2026 iteam. Current version is 2.156.0. UTC+08:00, 2026-11-27 09:43
浙ICP备14020137号-1