Skip to main content
ClaudeWave
Skill490 repo starsupdated 3d ago

code-quality

Agents should invoke this skill for code reviews, linting/formatting setup, maintainability checks, complexity concerns, warning cleanup, coding standards, or quality gates in Rust, TypeScript, Python, shell, and mixed repos.

Install in Claude Code
Copy
git clone --depth 1 https://github.com/waybarrios/opencode-power-pack /tmp/code-quality && cp -r /tmp/code-quality/skills/code-quality ~/.claude/skills/code-quality
Then start a new Claude Code session; the skill loads automatically.

SKILL.md

# Code Quality

Structured code review and quality enforcement across common tech stacks. Checklists, linting strategies, and metrics to keep codebases healthy.

## Quick Start

### Run a Code Quality Check

1. **Run static analysis:** Linters, type checkers, formatters
2. **Review against checklist:** Language-specific items below
3. **Check complexity metrics:** Cyclomatic < 25, data flow < 25
4. **Report findings:** Structured output with severity and recommendations

---

## Linting Configurations

### Rust — Clippy Config

Standard clippy configuration (in `Cargo.toml` or `.clippy.toml`):

```toml
[lints.clippy]
cognitive_complexity = "warn"
pedantic = { level = "deny", priority = -1 }
nursery = { level = "deny", priority = -1 }
unwrap_used = "deny"
```

**Standard commands:**

```bash
cargo fmt
cargo clippy --all-targets --all-features -- -D warnings
cargo check
cargo test -- --test-threads=1
```

**Key rules to enforce:**
- No `.unwrap()` in non-test code (use `?` or `.expect("reason")`)
- All public items have rustdoc (`#[warn(missing_docs)]`)
- `#[must_use]` on functions that return values that should be checked
- When using `#[allow(...)]`, always add a comment explaining why
- If no good explanation exists for `#[allow(...)]`, fix the issue instead

### TypeScript — ESLint + Strict Mode

**Recommended `tsconfig.json` strictness:**

```json
{
  "compilerOptions": {
    "strict": true,
    "noUncheckedIndexedAccess": true,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true,
    "exactOptionalPropertyTypes": true
  }
}
```

**Key rules to enforce:**
- No `any` — use `unknown` and type guards instead
- No `// @ts-ignore` — fix the type issue or use `// @ts-expect-error` with explanation
- Prefer `const` over `let`, never use `var`
- Use discriminated unions for state modeling
- Explicit return types on exported functions

### Python — Ruff + Mypy

**Recommended `pyproject.toml`:**

```toml
[tool.ruff]
target-version = "py312"
line-length = 88

[tool.ruff.lint]
select = ["E", "F", "W", "I", "N", "UP", "ANN", "B", "A", "C4", "DTZ", "ISC", "PIE", "PT", "RET", "SIM", "TCH", "ARG", "PTH", "ERA"]

[tool.mypy]
strict = true
warn_return_any = true
warn_unreachable = true
```

**Key rules to enforce:**
- Type hints on all public functions and methods
- Docstrings on all public classes, functions, and methods
- Use `pathlib.Path` over `os.path`
- Use `uv` as package manager
- No bare `except:` — always catch specific exceptions

---

## Code Review Checklists

### Universal Checklist (All Languages)

**Correctness:**
- [ ] Does the code do what it claims to do?
- [ ] Are edge cases handled (empty collections, null/None, zero, negative)?
- [ ] Are error paths handled gracefully?
- [ ] Are there any off-by-one errors?

**Clarity:**
- [ ] Can you understand the code without the PR description?
- [ ] Are variable/function names descriptive and consistent?
- [ ] Are complex sections commented with "why" (not "what")?
- [ ] Is the code self-documenting where possible?

**Architecture:**
- [ ] Does this change respect existing module boundaries?
- [ ] Is the change at the right abstraction level?
- [ ] Are dependencies reasonable (not pulling in a huge lib for one function)?

**Testing:**
- [ ] Are new functions/methods covered by tests?
- [ ] Do tests cover edge cases and error paths?
- [ ] Are tests readable and maintainable?

**Security (flag for a security follow-up if concerns found):**
- [ ] No hardcoded secrets or credentials
- [ ] User input is validated before use
- [ ] No SQL injection, XSS, or path traversal vectors

### Rust-Specific Checklist

- [ ] `cargo fmt` applied
- [ ] `cargo clippy` clean (pedantic + nursery)
- [ ] No `.unwrap()` outside tests
- [ ] Error handling uses `?` with proper error types
- [ ] Public items have rustdoc comments
- [ ] `#[allow(...)]` includes explanatory comment
- [ ] New functions have unit tests
- [ ] Cyclomatic complexity < 25 per function
- [ ] Data flow complexity < 25 per function

### TypeScript/React-Specific Checklist

- [ ] No `any` types
- [ ] Strict mode compliance
- [ ] Components have clear prop types
- [ ] Hooks follow rules of hooks
- [ ] No unnecessary re-renders (check memo/callback usage)
- [ ] Bundle impact considered for new dependencies

### Django/Python-Specific Checklist

- [ ] Type hints present on public interfaces
- [ ] Ruff + mypy clean
- [ ] No N+1 queries (use `select_related`/`prefetch_related`)
- [ ] Migrations are reviewed and reversible
- [ ] No business logic in views (use service layer)

---

## Complexity Metrics

### Cyclomatic Complexity

Measures the number of independent paths through code. Recommended threshold: **< 25**.

| Complexity | Risk Level | Action |
|---|---|---|
| 1-10 | Low | Simple, well-structured code |
| 11-20 | Moderate | Consider simplification if growing |
| 21-24 | High | Refactoring recommended |
| 25+ | Violation | Must refactor before merge |

**How to reduce:**
- Extract helper functions for each branch
- Use early returns / guard clauses
- Replace complex conditionals with lookup tables or pattern matching
- Use strategy pattern for variant-dependent behavior

### Data Flow Complexity

Measures how many variables interact within a function. Recommended threshold: **< 25**.

**How to reduce:**
- Extract pure functions that take fewer parameters
- Group related parameters into structs/objects
- Split functions that transform data in multiple stages

### Measurement Tools

| Language | Tool | Command |
|---|---|---|
| Rust | `cargo clippy` (cognitive_complexity) | Built into clippy config |
| TypeScript | `eslint-plugin-sonarjs` | Configure `complexity` rule |
| Python | `radon` | `radon cc <file> -s -a` |
| Python | `ruff` | Rule `C901` (mccabe complexity) |

---

## Review Output Format

When delivering a code review:

```markdown
## Code Review: [PR/File/Module]

**Date:** YYYY-MM-DD

### Summary
[1-2 sentences: overall quality assessment]

### Findings

| # | Severi
agents-md-improverSkill

Audit and improve project-rules files (AGENTS.md, CLAUDE.md, .agents/instructions, local overrides) so the agent keeps accurate project context. Use when the user asks to check, audit, review, update, improve, or fix their AGENTS.md or CLAUDE.md, mentions "project rules maintenance" or "agent context optimization", or when the codebase has changed enough that the rules file may be stale. Scans the repository for every rules file, grades each against a quality rubric, outputs a quality report, and applies targeted edits only after user approval.

agents-md-reviseSkill

Capture learnings from the current session into the project-rules file (AGENTS.md, CLAUDE.md, or local override) so future sessions benefit. Use when the user says "revise the rules", "update AGENTS.md / CLAUDE.md with what we just learned", "save this to project memory", "remember this for next time", or at the end of a productive session when valuable context has emerged that is not yet documented. This complements agents-md-improver — improver audits, while this one captures.

code-architectSkill

Design a feature architecture by analyzing existing codebase patterns and conventions, then provide a comprehensive implementation blueprint with specific files to create or modify, component designs, data flows, and a build sequence. Use this skill when the user asks for an architecture design, an implementation plan for a non-trivial feature, or when dispatched as a sub-task during feature-dev architecture phase.

code-explorerSkill

Deeply analyze an existing codebase feature by tracing execution paths, mapping architecture layers, understanding patterns and abstractions, and documenting dependencies. Use this skill when you need to understand how a feature works before modifying or extending it, when dispatched as a sub-task during feature-dev exploration, or when the user asks "how does X work in this codebase".

code-reviewSkill

Review a pull request or a set of code changes for bugs, logic errors, and project-convention violations using a confidence-filtered, multi-agent process. Use this skill when the user asks to review a PR, audit pending changes, or inspect a diff for problems before merging.

code-reviewerSkill

Review code for bugs, logic errors, security vulnerabilities, code quality issues, and adherence to project conventions, using confidence-based filtering to report only high-priority issues that truly matter. Use this skill when reviewing a small set of changes locally (such as unstaged diff), when dispatched as a sub-task during feature-dev quality review, or when the user wants a critique of a specific file or function.

feature-devSkill

Guide a feature implementation through a structured seven-phase workflow with deep codebase understanding, clarifying questions, parallel architecture design, and quality review. Use this skill when the user asks to build a new feature, add functionality, or wants a methodical approach to implementation rather than diving straight to code.

frontend-designSkill

Create distinctive, production-grade frontend interfaces with high design quality and accessible markup. Use this skill when the user asks to build or beautify web components, pages, applications, landing pages, dashboards, artifacts, or React/HTML/CSS UI. Generates creative, polished code that avoids generic AI aesthetics, then self-checks it against an objective accessibility and quality rubric.