Skip to main content
IntermediateQuality & SecurityEst. Time: 15-20 min

Code Review & Standards Audit

Perform automated architectural, security, and contract audits on pull requests and local working trees before merge.

The Problem

Human reviewers miss subtle edge cases (unhandled async rejections, SQL injection vulnerabilities, broken API contract changes), while manual review bottlenecks release velocity.

Who It Is For

Tech leads, senior engineers, and PR reviewers automating pre-merge code reviews.

Prerequisites & Tools

Prerequisites Checklist:
  • Git repository with staged or uncommitted changes
  • Configured DevWorkflow MCP
Tool / CommandTypeRole in Tutorial
auditmcpAudit working tree, diffs, API contracts, and security against engineering standards
analyze_changemcpExplain rule violations, change impact, and recommended tests
apply_safe_fixmcpApply worktree-fenced deterministic AF-0/AF-1 fixes with rollback

Example Task Contract

Exact start_task payload representing this workflow in DevWorkflow local-first governance.

AI Tool Call: start_task payload
{
  "description": "Audit checkout service pull request for API contract stability and security compliance",
  "type": "refactor",
  "plan": [
    "Audit modified endpoint schemas in routes/checkout.js",
    "Verify absence of unparameterized database queries",
    "Confirm backward compatibility for mobile clients"
  ],
  "definitionOfDone": [
    "Zero SQL injection or secret leak vulnerabilities detected",
    "API contract audit passes without breaking existing schema",
    "Automated review summary posted to PR notes"
  ]
}

Step-by-Step Tutorial Workflow

Follow these sequential actions with validated copyable commands and expected outputs.

1

Run Code & Contract Audit

Instruct the AI to inspect current changes for standards violations and security flaws.

Code / Tool Payload
Execution Payload
{
  "target": "HEAD~1..HEAD"
}
2

Review Audit Report

Examine detected smells, contract breaking changes, and cyclomatic complexity warnings.

Copyable Command
Terminal Command
git diff --stat HEAD~1
Expected Terminal Output
4 files changed, 112 insertions(+), 18 deletions(-)
Audit: 0 critical vulnerabilities · 0 contract breaks · 1 refactor opportunity
3

Apply Safe Automated Fixes

Use apply_safe_fix or refactor the highlighted regions before committing.

Copyable Command
Terminal Command
npm test
Expected Terminal Output
All tests passed.

Verification Steps

Verify that your work genuinely satisfies the task contract before closing.

Run `audit` with `category: 'report'` to generate a structured JSON and formatted audit summary
Confirm clean static analysis and zero linting errors

Limitations & Troubleshooting

Issue: Audit flags legacy files outside PR scope
Resolution: Target specific commit ranges (e.g. `origin/main...HEAD`) to constrain audits to touched files.