code-review

GitHub

提供结构化代码审查流程,涵盖读取、意图理解、问题分类及发现报告。支持Bug、安全、性能等多维度审计,包含Python与Agent常见陷阱检查清单,确保审查具体且可操作。

skills/code-review/SKILL.md FareedKhan-dev/claude-code-from-scratch

触发场景

请求审查文件或函数 检查代码质量或风格 建议代码改进或重构 审计安全性或错误处理

安装

npx skills add FareedKhan-dev/claude-code-from-scratch --skill code-review -g -y
更多选项

不安装直接使用

npx skills use FareedKhan-dev/claude-code-from-scratch@code-review

指定 Agent (Claude Code)

npx skills add FareedKhan-dev/claude-code-from-scratch --skill code-review -a claude-code -g -y

安装 repo 全部 skill

npx skills add FareedKhan-dev/claude-code-from-scratch --all -g -y

预览 repo 内 skill

npx skills add FareedKhan-dev/claude-code-from-scratch --list

SKILL.md

Frontmatter
{
    "name": "code-review",
    "description": "Use when asked to review code, audit a file for bugs, check code quality, or suggest improvements. Provides a structured review process and issue categorisation."
}

Code Review Skill

When to use this skill

Load when the user asks you to:

  • Review a file or function for bugs
  • Check code quality or style
  • Suggest improvements or refactors
  • Audit security or error handling
  • Compare two implementations

Review process

Always follow this order. Do not skip steps.

Step 1 — Read before commenting

Use the read tool to read the full file first. Use grep to find related code (callers, tests, imports). Never comment on code you haven't fully read.

Step 2 — Understand intent

Ask: what is this code trying to do? Read any docstrings, comments, and function names. If the intent is unclear, note it — don't assume.

Step 3 — Categorise issues

Use these categories consistently:

Category When to use
BUG Code that will produce wrong results or crash
SECURITY Input not validated, secrets exposed, injection risks
PERF Unnecessary work, wrong data structure, O(n²) that could be O(n)
STYLE Inconsistent naming, long functions, missing docstrings
SUGGEST Optional improvements — not required to fix

Step 4 — Write findings

Format each finding:

[CATEGORY] file.py:line_number
  Issue: one sentence describing the problem
  Why:   why this matters
  Fix:   concrete suggestion or corrected code snippet

Step 5 — Summary

End with:

  • Total issues found per category
  • The most critical issue (if any BUG or SECURITY)
  • Whether the code is safe to deploy as-is

What good code review looks like

  • Specific: cite file + line number, not "somewhere in the code"
  • Actionable: every issue has a suggested fix
  • Proportionate: distinguish blocking bugs from style nits
  • Respectful: review the code, not the author

Common bugs to look for in Python

# Mutable default argument (very common)
def append(item, lst=[]):   # BUG: lst shared across all calls
    lst.append(item)

# Exception swallowed silently
try:
    do_something()
except Exception:            # BUG: hides errors, use `except Exception as e: log(e)`
    pass

# Off-by-one in slices
items[1:len(items)]          # STYLE: prefer items[1:]

# Late binding closure
fns = [lambda: i for i in range(5)]   # BUG: all return 4
fns = [lambda i=i: i for i in range(5)]  # Fix

# Forgetting to close resources
f = open("file.txt")        # BUG: use `with open("file.txt") as f:`

Common bugs to look for in agents

  • Tool outputs not checked before use (model assumes success)
  • No timeout on subprocess calls (agent hangs forever)
  • Output not truncated (enormous tool results fill context)
  • Missing tool error handling (exception crashes the loop)
  • No dangerous command filter in bash tool

Security checklist

  • No secrets, tokens, or keys in code or comments
  • Shell commands not built from user input (injection risk)
  • File paths validated (no ../../../etc/passwd traversal)
  • External input not eval'd or exec'd
  • Dependencies pinned to versions in requirements.txt

版本历史

  • fb9709e 当前 2026-07-24 11:37

同 Skill 集合

skills/agent-builder/SKILL.md
skills/pdf/SKILL.md

元信息

文件数
0
版本
fb9709e
Hash
47c3f2b7
收录时间
2026-07-24 11:37

首页 - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-09-18 16:56
浙ICP备14020137号-1