Generic AI advice
Without a codebase-specific rule, general-purpose advice can miss internal dependency boundaries, mandatory audit logging, or required exception handling.
Outcome: Valid code can still violate team intent.
Write your review policy in Markdown. ScanDrix evaluates the changed code against that rule and returns a focused, actionable review on the pull request.
Markdown rule
State the standard in a reviewable file.
AST-aware analysis
Match the changed code to the rule scope.
PR comment
Explain the finding and the path forward.
01 — The mental model
Policy as Code Review means writing an engineering standard as a Markdown rule, scoping where it applies, and evaluating changed code against its instructions during pull-request review.
A general checklist reminds a reviewer what to remember. A broad prompt gives a model room to interpret. A policy rule is narrower: it pairs an explicit standard with a path, language, severity, and review behavior—so the team can inspect, revise, and enforce it through Git.
02 — Why codify it
The risk starts when a team’s standards cannot be expressed, scoped, and checked consistently at the point of change.
Without a codebase-specific rule, general-purpose advice can miss internal dependency boundaries, mandatory audit logging, or required exception handling.
Outcome: Valid code can still violate team intent.
Linters and pattern scanners are precise for known syntax. Requirements that depend on intent or cross-file context need another layer.
Outcome: Known patterns pass while policy gaps remain.
Standards held by a few people are difficult to apply consistently, repeat, and change safely as the codebase evolves.
Outcome: Reviews vary and important context stays hidden.
03 — Workflow
The rule is the durable source. Automated review makes the repeatable check; human reviewers still own judgment and exceptions.
Write the standard as Markdown, with frontmatter for the parts that control when and how it runs.
Limit the rule by file path, language, review scope, and the minimum severity worth reporting.
ScanDrix evaluates changed code against the rule, using structural analysis for known code shapes and additional reasoning when context matters.
The review connects the finding to the rule, points to the changed code, and provides remediation guidance when it can be supported.
04 — Rule explorer
Choose a sample to see the Markdown source beside a simulated pull-request finding and code remediation. Every example on this page is illustrative.
Selected rule
Security
.scandrix/rules/prevent-raw-sql.md
---
title: "Enforce parameterized SQL queries"
scope: "file"
path: ["src/repositories/**/*.ts"]
severity_min: "critical"
languages: ["typescript"]
enabled: true
---
## Instructions
Flag database queries built with string interpolation or concatenation
when they include request data. Require parameterized queries or
the repository's query builder.src/repositories/user-repo.ts:48
Example finding
Dynamic SQL is built from request input. The value must be passed to the database client as a parameter instead of interpolated into the query string.
Suggested fix: Keep the SQL text constant and pass untrusted values separately to the database client.
Illustrative code remediation
- const query = `SELECT * FROM users WHERE id = '${req.query.id}'`;
+ const query = 'SELECT * FROM users WHERE id = $1';
+ await db.query(query, [req.query.id]);Showing Prevent raw SQL concatenation.
05 — Evaluation model
ScanDrix uses a hybrid model rather than asking one mechanism to solve every policy problem. The rule defines the boundary; analysis and reasoning help apply it to the changed code.
For explicit syntax and code-shape requirements, AST-aware analysis is more reliable than matching raw text alone.
Path, language, and severity settings narrow evaluation to the changes and findings the rule is meant to govern.
When intent crosses files or depends on domain behavior, AI reasoning adds context to the structural signals already available.
A useful finding identifies the changed location, explains the connection to the rule, and suggests a concrete fix when one is available.
06 — Rule anatomy
The instruction stays in Markdown. YAML frontmatter supplies the structured fields used to scope and run it.
The human-readable name used in the rule and its review output.
Example: "Enforce parameterized SQL queries"
Controls whether the rule is evaluated against an individual changed file or pull-request-wide context.
Example: "file"
Glob patterns that limit the files where the rule applies.
Example: ["src/repositories/**/*.ts"]
The minimum finding severity the rule should report.
Example: "high"
Programming languages the rule should evaluate.
Example: ["typescript", "javascript"]
Turns the rule on or off without removing its source.
Example: true
Start with one enforceable standard, review how it behaves, then expand the policy as your team learns.