# code-review

Adopt this skill: https://proskills.md/skills/other/kapitecsoluciones-openclaw-skills-code-review

Page: https://proskills.md/skills/other/kapitecsoluciones-openclaw-skills-code-review
This document is the public skill bundle for that page. It contains SKILL.md and every helper file the catalog carries. No login is required.

## File: code-review/SKILL.md
size: 4055
sha: f6414f6ac14d5c354d93d75c97365155412e15b1
upstream: https://github.com/kapitecsoluciones/openclaw-skills/blob/master/code-review/SKILL.md

````text
---
name: code-review
description: Pre-deploy code review. Analyzes diffs or entire files for SQL safety, N+1 queries, race conditions, trust boundary violations, error handling gaps, and structural issues. Auto-fixes obvious problems, escalates ambiguous ones. Use when asked to "review this code", "review before deploy", "pre-landing review", "check this diff", "audit this file", or before any deploy/push. Proactively suggest when user is about to deploy or merge.
---

# Code Review

Systematic pre-deploy review. Goal: catch real bugs, not style nits.

## When to Trigger

- User says "review", "check this", "audit", "before I deploy"
- User is about to rsync/push/deploy (suggest proactively)
- After a subagent completes work (verify before deploy)

## Review Process

### Phase 1: Scope

1. Identify what changed: `git diff`, `git diff --staged`, or read specified files
2. List changed files with line counts
3. If >500 lines changed, prioritize: API endpoints > auth > data mutations > UI

### Phase 2: Automated Checks

Run these checks (skip if not applicable):

```bash
# Syntax validation
find . -name "*.ts" -newer .git/index | head -20 | xargs -I{} npx tsc --noEmit {} 2>&1 | head -30
find . -name "*.py" -newer .git/index | head -20 | xargs -I{} python3 -m py_compile {} 2>&1
find . -name "*.php" -newer .git/index | head -20 | xargs -I{} php -l {} 2>&1 | grep -v "No syntax"

# Security quick scan
grep -rn "eval\|exec\|dangerouslySetInnerHTML\|innerHTML\|__proto__\|constructor\[" --include="*.{ts,tsx,js,jsx,py,php}" . | grep -v node_modules | grep -v ".git"

# Hardcoded secrets
grep -rn "sk-\|sk_live\|sk_test\|password.*=.*['\"]" --include="*.{ts,tsx,js,jsx,py,php,env}" . | grep -v node_modules | grep -v ".git" | grep -v ".example"
```

### Phase 3: Manual Analysis

Check each changed file for:

**P0 — Blocks deploy:**
- SQL injection (string concatenation in queries)
- Auth bypass (missing middleware, unchecked tokens)
- Data loss (DELETE/DROP without WHERE, missing transactions)
- Secrets in code (API keys, passwords, tokens)
- Infinite loops / unbounded recursion
- Missing error handling on external calls (DB, API, file I/O)

**P1 — Fix before users notice:**
- N+1 queries (loop with DB call inside)
- Race conditions (shared state without locks, concurrent writes)
- Missing input validation on user-facing endpoints
- Unhandled promise rejections / uncaught exceptions
- CORS misconfiguration
- Missing rate limiting on public endpoints

**P2 — Fix this sprint:**
- Dead code / unreachable branches
- Console.log left in production code
- Missing TypeScript types (any, unknown)
- Inconsistent error response formats
- Missing loading/error states in UI
- Accessibility issues (missing alt, aria labels)

**P3 — Nice to have:**
- Naming clarity
- Code duplication (>10 lines identical)
- Missing comments on complex logic

### Phase 4: Report

Format the report as:

```
## Review: [files/scope]

### 🔴 P0 — Must fix (blocks deploy)
[item]: [file:line] — [what's wrong] — [fix]

### 🟡 P1 — Should fix
[item]: [file:line] — [what's wrong] — [fix]

### 🟢 P2 — Improve
[item]: [file:line] — [what's wrong]

### Summary
- Files reviewed: X
- Issues: X P0, X P1, X P2
- Verdict: ✅ SHIP IT / ⚠️ FIX THEN SHIP / 🛑 DO NOT SHIP
```

### Phase 5: Auto-fix

If user agrees (or for P0 issues):
- Fix P0 issues immediately
- Fix P1 issues if straightforward (<5 lines each)
- Show diff of changes before applying

## Rules

- **Be concrete.** "auth.ts:47 — token check returns undefined when session expires" not "there's an auth issue"
- **Connect to users.** "User will see a 3s spinner on every page load" not "this might be slow"
- **Real numbers.** "N+1 here means ~200ms per page with 50 items" not "could be slow"
- **No style nits** unless they cause bugs. Don't bikeshed semicolons.
- **Auto-fix the obvious.** Missing error handling, console.logs, hardcoded strings — just fix them.
- **Escalate the ambiguous.** If you're not sure it's a bug, ask. Don't silently skip.
````

## File: README.md
upstream: https://github.com/kapitecsoluciones/openclaw-skills/blob/master/README.md

````text
# 🛠️ OpenClaw Skills — Software Quality Toolkit

Four skills that make AI agents build better software. Built for [OpenClaw](https://github.com/openclaw/openclaw), the open-source AI agent platform.

Inspired by real production experience deploying AI agents + ideas from [gstack](https://github.com/garrytan/gstack). Zero dependencies, pure methodology.

## Skills

| Skill | What it does | When it triggers |
|-------|-------------|-----------------|
| **[code-review](./code-review/)** | Pre-deploy review with P0→P3 priorities, auto-fix | "review this", "check before deploy" |
| **[debugger](./debugger/)** | Root cause investigation — no fix without proof | "debug this", "why is this broken" |
| **[security-audit](./security-audit/)** | OWASP Top 10 + STRIDE + secrets scan | "security audit", "check for secrets" |
| **[kapilot](./kapilot/)** | Autonomous dev pipeline — plan to code while you sleep | "kapilot", "build while I sleep" |

## How They Work Together

```
You have a plan
    │
    ▼
┌──────────┐    Autonomous? ──▶ Kapilot (orchestrates everything)
│  Build    │         │
│  Code     │         │    Kapilot runs these automatically:
└────┬─────┘         │    ├── code-review (R1)
     │                │    ├── security-audit (R2)
     ▼                │    └── debugger (when tests fail)
┌──────────┐         │
│  Review   │◀────────┘
│  Code     │──▶ code-review
└────┬─────┘
     │
     ▼
┌──────────┐
│ Security  │──▶ security-audit
│  Check    │
└────┬─────┘
     │
     ▼
┌──────────┐
│  Bug?     │──▶ debugger
│  Debug    │
└────┬─────┘
     │
     ▼
   Ship it 🚀
```

**Individually:** Each skill works standalone. Ask for a review, debug a bug, or run a security audit anytime.

**Together via Kapilot:** The autonomous pipeline uses all three as quality gates. Code review (R1) → Security scan (R2) → Debug if broken → Commit → Next phase.

## Installation

### OpenClaw (recommended)

Copy the skill folders to your OpenClaw workspace:

```bash
# Clone this repo
git clone https://github.com/kapitecsoluciones/openclaw-skills.git

# Copy skills to your workspace
cp -r openclaw-skills/code-review ~/.openclaw/workspace/skills/
cp -r openclaw-skills/debugger ~/.openclaw/workspace/skills/
cp -r openclaw-skills/security-audit ~/.openclaw/workspace/skills/
cp -r openclaw-skills/kapilot ~/.openclaw/workspace/skills/
```

OpenClaw auto-discovers skills in `~/.openclaw/workspace/skills/`. No config needed.

### Claude Code

These work with any agent that reads SKILL.md files. For Claude Code, drop them in your project's `.claude/skills/` directory.

### Other Agents

Each skill is a self-contained Markdown file. Any agent that can read instructions from a file can use them. No binaries, no config files, no lock-in.

## Quick Start

### Code Review

Just ask your agent to review before deploying:

> "Review the code before I deploy"

It will:
1. Identify changed files (via git diff or specified files)
2. Run automated checks (syntax, secrets, security patterns)
3. Analyze each file for P0 (blocks deploy) through P3 (nice to have) issues
4. Auto-fix obvious problems (P0 + simple P1)
5. Give a verdict: ✅ SHIP IT / ⚠️ FIX THEN SHIP / 🛑 DO NOT SHIP

### Debugger

When something breaks:

> "Debug why login returns 500"

It will:
1. **Investigate** — Reproduce, read logs, check timeline
2. **Analyze** — Narrow scope, read code, check assumptions
3. **Hypothesize** — State root cause, prove it
4. **Implement** — Minimal fix, fix siblings, verify

**Iron Law:** No fix without confirmed root cause. If it can't explain the bug in one sentence, it goes back to investigating.

### Security Audit

Two modes:

> "Quick security check" → 5 min, high-confidence findings only

> "Deep security audit" → 20 min, OWASP Top 10 + STRIDE + dependencies

Checks: hardcoded secrets (including git history), SQL injection, XSS, auth bypass, CORS misconfiguration, debug mode in production, default credentials, outdated dependencies.

### Kapilot (Autonomous Pipeline)

Give it a plan file and let it run:

> "Activate kapilot with PLAN.md"

It sets up a cron job that:
1. Reads the current phase from the plan
2. Implements it
3. Reviews (code-review + security-audit)
4. Checks scope (did it build what the plan says?)
5. Verifies (build + tests pass)
6. Commits with detailed message
7. Advances to next phase
8. Notifies you

Runs every 15-30 minutes. You wake up to commits.

**Stop conditions:** All phases done, critical security issue, build fails 3x, or you say stop.

## Design Principles

1. **Methodology over code.** These skills are instructions, not programs. They teach the agent *how to think* about quality, not just what commands to run.

2. **Composable.** Each skill works alone. Together they're a pipeline. Mix and match.

3. **No dependencies.** Pure Markdown + standard CLI tools (grep, git, curl). No npm packages, no binaries, no config files.

4. **Fail loud.** When something's wrong, stop and tell the human. Don't bury errors in logs.

5. **Evidence-based.** Every finding has a file:line reference. Every bug fix has a root cause. Every security issue has a concrete grep result.

## Contributing

PRs welcome. Keep skills as pure Markdown methodology — no binaries, no build steps, no telemetry.

## License

MIT — Use however you want.

---

Built by [Kapitec Soluciones](https://kapitec.pro) 🤙
````
