Skip to content

Repository files navigation

Code Quality Gate — BMad Module

BMad-compliant CI/CD module for automated PR quality enforcement via GitHub Actions

Server-side AI gatekeeper that automatically scans pull requests for security vulnerabilities, repository impact, and platform-specific best practices. Blocks the merge button when violations are found.


Quick Start

For BMad Users

# Install the module
npx bmad-method install --module https://github.com/dept/dtin-commit-agent
# Get setup guidance
bmad-help setup-code-guardian
# Or invoke the workflow directly
workflows/setup-pr-gate/workflow.md

Without BMad

See SETUP.md for traditional deployment.


What This Module Provides

BMad Integration

ComponentTypeAccess Code
Code Guardian SkillAutomationCG
Setup WorkflowGuided ProcessSETUP-CG

Supported Platforms & Violations Caught

PlatformFile TriggersWhat It Detects
AEM Core & EDS/apps/, /libs/, /blocks/, .java, .jsp, .xmlUnclosed ResourceResolver, HTL context security, native DOM in EDS blocks
Modern Frontend.js, .jsx, .ts, .tsx, .html, .css, .scssdangerouslySetInnerHTML, missing React keys, broken useEffect deps
Magento & PHP/app/code/, /vendor/magento/, .php, .phtmlDirect ObjectManager calls, raw SQL, N+1 collection loops

Security Overlay (always evaluated): XSS, SQL injection, hardcoded secrets, path traversal, weak crypto


Supported AI Providers

ProviderModelsSecret NamesCost (est. per PR)
Anthropic Claudeclaude-sonnet-4, claude-opus-4, claude-haiku-4AI_PROVIDER=claude
ANTHROPIC_API_KEY
$0.03-0.05
OpenAI ChatGPTgpt-4o, gpt-4-turbo, gpt-3.5-turboAI_PROVIDER=openai
OPENAI_API_KEY
$0.05-0.10
GitHub Copilotgpt-4oAI_PROVIDER=copilot
COPILOT_PAT (or GitHub App)
Included in seat
Azure OpenAIYour deploymentAI_PROVIDER=azure
AI_API_KEY + AI_BASE_URL
Varies
Custom (Groq, etc)OpenAI-compatibleAI_PROVIDER=custom
AI_API_KEY + AI_BASE_URL
Varies

Quick Configuration

Just set 2-3 GitHub secrets:

# For Claude (recommended)
gh secret set AI_PROVIDER --body "claude"
gh secret set AI_MODEL --body "claude-sonnet-4-20250514"
gh secret set ANTHROPIC_API_KEY --body "sk-ant-..."# For OpenAI
gh secret set AI_PROVIDER --body "openai"
gh secret set AI_MODEL --body "gpt-4o"
gh secret set OPENAI_API_KEY --body "sk-..."# For Copilot (legacy, still works)
gh secret set COPILOT_PAT --body "ghp_..."

Backward compatible: Existing COPILOT_PAT secrets still work without any changes.


Architecture

Hybrid BMad + GitHub Actions Design:

  • BMad Layer: Skills, workflows, documentation, configuration
  • Runtime Layer: TypeScript orchestrator executing on GitHub Actions runners
  • AI Layer: Multi-provider support (Copilot, Claude, OpenAI, Azure, custom)
Developer opens PR
↓
GitHub Actions triggers (via .github/workflows/code-guardian.yml)
↓
Runner executes TypeScript orchestrator (src/)
↓
Orchestrator loads prompts from skills/code-guardian/prompts/
↓
AI analyzes each code chunk (via selected provider)
↓
Aggregated verdict → exit code 0 (pass) or 1 (fail)
↓
GitHub blocks merge if failed

Module Structure

code-quality-gate/
├── module-help.csv ← BMad catalog
├── module.config.yaml ← BMad configuration
├── skills/
│ └── code-guardian/
│ ├── SKILL.md ← Skill definition (BMad)
│ ├── prompts/ ← AI prompts (runtime)
│ └── schemas/ ← Output validation
├── workflows/
│ └── setup-pr-gate/ ← Installation workflow (BMad)
├── .github/workflows/ ← GitHub Actions (runtime)
├── src/ ← TypeScript orchestrator (runtime)
│ ├── ai-client.ts ← Multi-provider AI client
│ ├── copilot-client.ts ← Legacy Copilot client
│ └── ...
└── package.json ← Node.js dependencies (runtime)

Key Insight: BMad layer provides documentation and discoverability; TypeScript layer provides execution.


Configuration

Via module.config.yaml or environment variables:

OptionDefaultDescription
ai_providercopilotUse copilot, claude, openai, azure, or custom
ai_model(auto)Specific model (e.g., claude-sonnet-4, gpt-4o)
concurrency4Parallel chunk analysis
slack_enabledfalseSend failure notifications to Slack
email_enabledfalseSend failure notifications via email

License

UNLICENSED — Internal use only


Links

  • Setup Guide:SETUP.md
  • Architecture:docs/ARCHITECTURE.md
  • Troubleshooting:docs/TROUBLESHOOTING.md
  • BMad Workflow:workflows/setup-pr-gate/workflow.md
  • Changes Log:CHANGES.md

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages