AI Critic

AI Critic

A critic hook that validates agent-generated code against coding patterns, style rules, and security checks defined in .md knowledge files before final output.

typescriptnodejsopenaimarkdown

Architecture

AI Critic architecture

Problem it solves

Even with strict coding rules in the prompt, agents often ignore instructions and generate code in inconsistent styles — leading to review debt, type-safety gaps, and security oversights.

How it works

After the agent generates code, a critic mini-agent receives the output along with pattern .md files (arrow-function rules, type-safety checks, security guidelines). It compares the generated code against these patterns and returns a fix list before the code is finalized.

Approach

Treats code quality as a separate evaluation step rather than hoping the generator gets it right in one shot. Rules are stored as plain .md files so non-devs can edit them and the critic can reason over them with full context.