Get the FREE Ultimate OpenClaw Setup Guide →

code-review

Scanned
npx machina-cli add skill Weaverse/.agents/code-review --openclaw
Files (1)
SKILL.md
3.8 KB

Perform a comprehensive code review on $ARGUMENTS. This is a read-only review - do NOT modify any files. Only output findings.

Review Categories

1. Dead Code Detection

  • Unused imports
  • Unused variables, functions, components, hooks
  • Unreachable code paths
  • Commented-out code that should be removed
  • Unused type definitions / interfaces

2. Code Duplication

  • Duplicated logic that could be extracted to a shared utility
  • Similar components that could be consolidated
  • Repeated patterns that warrant a custom hook
  • Copy-pasted code blocks across files

3. Coding Pattern Violations

Check against these rules:

  • Collocation > Distribution: Related code should live together, not scattered
  • let > const: Prefer let over const for variable declarations
  • Named exports > Default exports: Use export function Foo not export default
  • Function declarations > Function expressions: Use function foo() not const foo = () =>
  • No useMemo: Flag any usage of useMemo
  • No useCallback: Flag any usage of useCallback
  • ALL_CAPS for constants: Constants should be SCREAMING_SNAKE_CASE

4. Bugs & Memory Leaks

  • Missing cleanup in useEffect
  • Event listeners not removed
  • Subscriptions not unsubscribed
  • Stale closures
  • Race conditions in async code
  • Missing error handling
  • Null/undefined access risks
  • Incorrect dependency arrays

5. Optimization Opportunities

  • Unnecessary re-renders
  • Heavy computations in render path
  • Missing keys in lists
  • Inefficient data structures
  • N+1 query patterns
  • Bundle size concerns (large imports)

Output Format

For each finding, output with numbered indexes wrapped in brackets for easy reference:

CATEGORY NAME

[1] `file:line` - Short description
    Brief explanation if needed (4-space indent)

[2] `file:line` - Short description
    Explanation with 4-space indent

Important formatting rules:

  • Use ALL CAPS for category names
  • Use sequential numbering wrapped in brackets [1], [2], etc. across ALL categories
  • Highlight file references with backticks: filename:line
  • Indent explanations with 4 spaces for readability
  • For Coding Pattern Violations: If multiple items with the same problem occur in the same file, list only ONCE (e.g., "5 usages of const" instead of listing each). No fix suggestions needed - these are easy fixes.

Example:

DEAD CODE

[1] `src/utils/helpers.ts:42` - Unused function `formatDate`
    Not imported anywhere in the codebase

[2] `src/components/Modal.tsx:3` - Unused import `useEffect`

CODING PATTERN VIOLATIONS

[3] `src/hooks/useAuth.ts` - Using `const` instead of `let` (7 occurrences)

[4] `src/components/Button.tsx:1` - Default export used

[5] `src/api/client.ts` - Function expressions instead of declarations (3 occurrences)

End of Review

After listing all findings, ask the user:

Found [N] items. Which would you like me to address?
- Enter number(s) to fix specific items (e.g., "1, 3, 5" or "1-5")
- "all" to fix everything
- "none" to skip
- Or describe what you'd like to do

Instructions

  1. Thoroughly explore the target files/directory
  2. Cross-reference imports and usages across the codebase
  3. Check for pattern violations against the coding rules
  4. Look for subtle bugs and memory leak patterns
  5. Identify optimization opportunities
  6. Output ALL findings grouped by category
  7. Be specific: always include filename:line references
  8. Be concise: short descriptions, no lengthy explanations
  9. DO NOT make any changes - this is review only

Source

git clone https://github.com/Weaverse/.agents/blob/main/skills/code-review/SKILL.mdView on GitHub

Overview

code-review performs a thorough, read-only audit of code focusing on dead code, duplication, pattern violations, bugs, and optimization opportunities. It analyzes a target file, directory, or scope and outputs actionable findings without altering any source.

How This Skill Works

The tool scans the specified ARGUMENTS using allowed-tools (Read, Grep, Glob), classifies findings into categories (Dead Code, Duplication, Coding Pattern Violations, Bugs & Memory Leaks, Optimizations), and returns a structured list of issues with file:line references.

When to Use It

  • Before merging a PR to catch regressions and maintainability issues
  • When auditing a legacy or unfamiliar module
  • To surface dead imports, unused vars, and duplicated logic
  • When enforcing coding patterns (const/let, named exports, etc.)
  • For early detection of bugs, memory leaks, and performance hotspots without modifying code

Quick Start

  1. Step 1: Run code-review on a target (file, directory, or scope) using ARGUMENTS
  2. Step 2: Read the generated findings categorized by Dead Code, Duplication, etc.
  3. Step 3: Share findings in your PR comments; no code is changed

Best Practices

  • Run on a well-scoped target (file or directory) to keep findings focused
  • Cross-check findings across the codebase to avoid duplicates
  • Prioritize high-impact items like bugs and memory leaks
  • Correlate findings with tests and CI to validate impact
  • Document and share findings in PR reviews; avoid suggesting fixes

Example Use Cases

  • Audit a React app for unused imports and stale hooks
  • Review a Node service for duplicate logic and missed cleanup
  • Inspect a Python data pipeline for memory leaks and error handling gaps
  • Validate naming, exports, and module boundaries in a microservice
  • Identify N+1 queries and large bundle imports in a frontend app

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers