Analyze code quality

From brianwestphal/glassbox · View interactive version

Analyze code quality is an AI agent skill from the GitHub repository brianwestphal/glassbox. Run all tests and linters, check for anti-patterns, generate a quality report

How to use this skill

Skill file

Analyze the overall quality of the source code by running all available checks and looking for known anti-patterns. Generate a comprehensive quality report.

Process

1. Run automated checks

Run these commands and capture the results:

# Unit tests with coverage
npm test 2>&1

# Linter
npm run lint 2>&1

# TypeScript type checking
npm run typecheck 2>&1

# E2E tests (if server not already running)
npm run test:e2e 2>&1

# Smoke tests — run the BUILT dist/cli.js, so they catch ESM-bundle-only
# runtime failures the tsx-based e2e suite can't (e.g. a bundled CJS dep
# calling require()). Requires a prior `npm run build`.
npm run test:smoke 2>&1

2. Analyze test coverage — treat 100% as a floor, not a ceiling

Read the coverage output from step 1. Identify:

Then explicitly state the limit of what this number proves. Line/branch coverage shows every line ran — it does not show that every behavior or every sequence of behaviors is asserted. A stateful module can sit at 100% line/branch/function/statement coverage and still ship basic bugs, because each individual operation was tested from a clean initial state while the transitions between internal states were never exercised. So do not treat a high coverage number as a stopping point: a module at 100% coverage is exactly where the behavioral / state-transition audit (step 3) earns its keep. Use the coverage report to trigger that audit, not to skip it.

3. Behavioral / state-transition audit

Line coverage is structurally blind to a whole class of bugs: a missing behavior, or a valid sequence of operations that was never run together. This step finds them.

Identify the stateful modules. Scan the source for modules that carry internal state across calls or branch on an internal mode/flag/phase. Heuristics — any module that:

For each stateful module, enumerate its states and the transitions between them, then check the tests for transition coverage — not just single-operation-from-clean-state. For every transition edge that matters, ask: is there a test that drives the module through this sequence and asserts the result? Concretely, look for tests that exercise:

Flag any stateful module whose tests only cover each operation from a clean initial state. For each flagged module, recommend an adversarial transition-matrix test: name the states, and list the specific out-of-order / interleaved / repeated / empty-then-refill sequences that should be added. A module at 100% line coverage with no transition tests is a finding, not a pass.

4. Check for documented anti-patterns

Read CLAUDE.md and the requirements docs (docs/*.md) for documented conventions and anti-patterns. Then scan the codebase for violations:

5. Generate the report

Present findings in this structure:

Automated Check Results
Coverage Gaps
Behavioral / Transition-Coverage Gaps

A per-stateful-module table: module → states → transition-test coverage (yes / partial / none) → recommended sequences to add. List every stateful module found in step 3, and mark as a finding any that is well-covered by line count but has untested transitions. This section must be able to flag a module sitting at 100% line/branch coverage whose transitions are untested — that is the whole point of the audit.

Anti-Pattern Violations

For each violation found:

Quality Metrics Summary

Present the report directly to the user. Be concise — group similar issues rather than listing every instance.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.