Skip to content

ntd25022006q/deerflow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

26 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🦌 Deerflow

Production-Grade Enforcement Framework

Enforce zero-tolerance quality standards. Ship code that actually works.

9-Gate Quality Pipeline Β· Workflow Engine Β· Skill Modules Β· CLI Tool Reference

CI Pipeline License: MIT Node.js >=20 TypeScript Strict

Quick Start Β· How It Works Β· Quality Gates Β· Skill Modules Β· Problems Solved


🎯 The Problem

Modern software projects suffer from the same recurring quality issues. Whether you're a solo developer, a growing startup, or an established team β€” these 25 critical flaws keep shipping to production:

# Flaw Impact
1 Poor code quality Bugs, crashes, maintenance nightmares
2 UI doesn't match specs Wasted iterations, broken designs
3 Files lost during refactors Missing code, broken functionality
4 Incomplete bug fixes Partial solutions, recurring bugs
5 Mock/fake data in production Unusable software, security risks
6 Infinite loops & hangs Frozen applications, CPU waste
7 Unprofessional UI Bad user experience, no adoption
8 Security vulnerabilities OWASP Top 10, data breaches
9 Unverified assumptions Non-existent APIs, wrong solutions
10 No type safety Runtime errors, unpredictable behavior
11 Missing error handling Crashes, data loss
12 No tests Unverified code, regression risk
13 Hardcoded secrets Credential leaks, security breaches
14 No input validation Injection attacks, data corruption
15 Missing documentation Unmaintainable codebase
16 No CI/CD Manual processes, human error
17 No containerization Deployment failures
18 No rate limiting DoS vulnerability
19 No authentication Unauthorized access
20 Circular dependencies Build failures, runtime errors
21 Memory leaks Degraded performance, crashes
22 No observability Blind to production issues
23 Breaking changes Unstable APIs, broken consumers
24 No database patterns N+1 queries, data inconsistency
25 Non-standard commits Unreadable git history

Every single one of these is solvable through enforcement.

βœ… The Solution: Deerflow

Deerflow is a single repository you git clone that enforces production-grade standards through 3 layers:

Layer 1: Project Scaffold (Strict Configs)

  • TypeScript strict mode (zero any, no implicit anything)
  • ESLint with custom mock-data detection plugin
  • Prettier for consistent formatting
  • Vitest with 80% coverage thresholds
  • Zod for runtime validation

Layer 2: Git Hooks (Husky)

  • pre-commit: Secrets scan, mock data check, lint, type-check, tests
  • commit-msg: Conventional Commits enforcement

Layer 3: CI/CD Pipeline (GitHub Actions)

  • 5 parallel jobs: typecheck, lint, test+coverage, build, security
  • Coverage threshold check (80%)
  • npm audit + Trivy security scanning
  • Secret detection in source code

πŸš€ Quick Start

git clone https://github.com/ntd25022006q/deerflow.git
cd deerflow

npm install
cp .env.example .env.local

make enforce      # Install enforcement tools
make quality-gate # Verify everything works
npm run dev       # Start development

βš™οΈ How It Works

Workflow Engine

The 8-phase pipeline that every contributor MUST follow:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ ANALYZE │──▢│ PLAN │──▢│ SCAFFOLD │──▢│ IMPLEMENT │──▢│ VALIDATE │──▢│ TEST │──▢│ SECURITY │──▢│ QUALITY GATE β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
     β”‚            β”‚            β”‚              β”‚               β”‚            β”‚           β”‚               β”‚
  Read code   Write ADR   Use templates   Follow patterns   Type+Lint   β‰₯80%      OWASP+           9/9
  Understand  Design      Create files    Repository Pat.   Zero err   coverage   secrets          PASS
  • ANALYZE: Read requirements, understand domain, identify patterns
  • PLAN: Design solution, write DECISIONS.md entry
  • SCAFFOLD: Create files from templates/
  • IMPLEMENT: Write code following Repository Pattern
  • VALIDATE: Type-check + lint on every changed file
  • TEST: Write tests, achieve β‰₯80% coverage
  • SECURITY: Scan for OWASP Top 10, secrets, vulnerabilities
  • QUALITY GATE: All 9 gates must pass β€” DEPLOY BLOCKED if any fail

Each phase has built-in validation. Failures block progression. Max 3 retries before escalating.

Skill Modules

5 specialized modules that enforce specific quality domains:

Skill Purpose Key Checks
πŸ” code-review Code quality enforcement Zero any, no mock data, proper patterns, no empty catches
πŸ”’ security OWASP Top 10 scanning SQL injection, XSS, secrets, CORS, auth, npm audit
πŸ§ͺ test Test coverage validation Missing tests, empty tests, weak assertions, coverage β‰₯80%
🎨 ui UI/UX quality Accessibility (WCAG 2.1), responsive design, design system
πŸ”Ž search Verify before coding API docs, security advisories, best practices, version checks

πŸ›‘οΈ Quality Gates

The 9 gates that ALL must pass before any code is accepted:

Gate Check Command Blocking
1 Build npm run build βœ… Yes
2 Lint eslint . --max-warnings=0 βœ… Yes
3 Type Check tsc --noEmit βœ… Yes
4 Test + Coverage vitest run --coverage (β‰₯80%) βœ… Yes
5 Security Audit npm audit --audit-level=moderate βœ… Yes
6 Docker Build docker build . βœ… Yes
7 Smoke Test Health endpoint check βœ… Yes
8 Format Check prettier --check . βœ… Yes
9 Secret Detection Regex scan for hardcoded secrets βœ… Yes

Result: JSON report at .agent/reports/quality-report.json Exit code: 0 = DEPLOY APPROVED, 1 = DEPLOY BLOCKED

πŸ“ Project Structure

deerflow/
β”œβ”€β”€ .github/workflows/     # CI/CD pipelines
β”‚   β”œβ”€β”€ ci.yml             # Main CI (typecheck, lint, test, build, security)
β”‚   └── release.yml        # Release pipeline with changelog
β”œβ”€β”€ .husky/                # Git hooks
β”‚   β”œβ”€β”€ pre-commit         # Secrets + mock + lint + type-check + tests
β”‚   └── commit-msg         # Conventional Commits enforcement
β”œβ”€β”€ deerflow/              # 🦌 Core Framework
β”‚   β”œβ”€β”€ workflow.ts        # Workflow Engine (8 phases)
β”‚   β”œβ”€β”€ skills/            # Skill Modules
β”‚   β”‚   β”œβ”€β”€ code-review.skill.ts
β”‚   β”‚   β”œβ”€β”€ security.skill.ts
β”‚   β”‚   β”œβ”€β”€ test.skill.ts
β”‚   β”‚   β”œβ”€β”€ ui.skill.ts
β”‚   β”‚   └── search.skill.ts
β”‚   └── index.ts           # Framework entry point
β”œβ”€β”€ scripts/
β”‚   └── quality-gate.sh    # 9-gate quality check script
β”œβ”€β”€ src/                   # Application source code
β”‚   β”œβ”€β”€ services/          # Business logic
β”‚   β”œβ”€β”€ controllers/       # Request handlers
β”‚   β”œβ”€β”€ routes/            # API route definitions
β”‚   β”œβ”€β”€ models/            # Domain entities & schemas
β”‚   β”œβ”€β”€ middleware/         # Auth, validation, error handling
β”‚   β”œβ”€β”€ utils/             # Helper functions
β”‚   β”œβ”€β”€ types/             # Shared TypeScript types
β”‚   └── config/            # Configuration management
β”œβ”€β”€ templates/             # Code templates (copy & rename)
β”‚   β”œβ”€β”€ service.template.ts  # Repository Pattern template
β”‚   β”œβ”€β”€ route.template.ts    # API route with validation + auth
β”‚   └── component.template.ts # React component with a11y
β”œβ”€β”€ tests/                 # Test files
β”‚   β”œβ”€β”€ unit/              # Unit tests
β”‚   β”œβ”€β”€ integration/       # Integration tests
β”‚   └── e2e/               # End-to-end tests
β”œβ”€β”€ docker/                # Docker configuration
β”‚   └── nginx.conf         # Nginx reverse proxy config
β”œβ”€β”€ AGENT_RULES.md         # 🚨 12 Mandatory Rules for contributors
β”œβ”€β”€ DECISIONS.md           # Architecture Decision Records
β”œβ”€β”€ CODEOWNERS             # Code ownership rules
β”œβ”€β”€ cli-tools.json        # CLI tool reference (NOT MCP servers)
β”œβ”€β”€ docker-compose.yml     # Dev environment (app + postgres + redis + nginx)
β”œβ”€β”€ Dockerfile             # Multi-stage build (deps β†’ builder β†’ runner)
β”œβ”€β”€ Makefile               # Central command hub
β”œβ”€β”€ package.json           # Dependencies & scripts
β”œβ”€β”€ tsconfig.json          # Strict TypeScript config
β”œβ”€β”€ eslint.config.js      # ESLint flat config + custom mock detection
β”œβ”€β”€ .prettierrc            # Code formatting rules
└── vitest.config.ts       # Test config with 80% coverage threshold

πŸ—ΊοΈ Problems β†’ Solutions Map

Problem Deerflow Solution Enforcement
Poor code quality Repository Pattern templates + strict TypeScript ESLint + type-check
UI mismatches UI Skill (accessibility + responsive checks) ui.skill.ts
Files lost during refactors Full file read rule (Rule #7) AGENT_RULES.md
Incomplete fixes Quality Gate blocks until ALL pass quality-gate.sh
Mock/fake data Custom ESLint plugin detects mock patterns eslint.config.js + pre-commit
Infinite loops Performance lint rules lint:perf
Unprofessional UI UI Skill + design system consistency ui.skill.ts
Security flaws Security Skill (OWASP Top 10 scanner) security.skill.ts + CI
Unverified assumptions Search Skill (verify APIs before use) search.skill.ts + Rule #10
No type safety TypeScript strict mode + zero any rule tsconfig.json + ESLint
Missing error handling Route template with typed error handling route.template.ts
No tests Test Skill + 80% coverage threshold vitest.config.ts
Hardcoded secrets Secret detection in pre-commit + CI .husky/pre-commit + CI
No input validation Zod schemas in all templates route.template.ts
No CI/CD GitHub Actions with 5 parallel jobs .github/workflows/
No Docker Multi-stage Dockerfile + compose Dockerfile + Gate 6
No rate limiting Nginx config with rate limiting docker/nginx.conf
No authentication Route template with auth checks route.template.ts
Circular dependencies ESLint import/no-cycle rule eslint.config.js
Memory leaks Performance lint + review skill code-review.skill.ts
Non-standard commits Conventional Commits enforcement .husky/commit-msg

πŸ› οΈ Available Commands

# Quality & Enforcement
make enforce          # Install all enforcement tools
make quality-gate     # Run all 9 quality gates
make verify           # Verify rules compliance
make fix              # Auto-fix lint and format issues

# Development
npm run dev           # Start development server
npm run build         # Build for production
npm run start         # Run production build

# Testing
make test             # Run all tests with coverage
make test:unit        # Run unit tests
make test:integration # Run integration tests
make test:e2e         # Run e2e tests

# Code Quality
make lint             # Run linter
make lint:fix         # Fix lint issues
make type-check       # TypeScript type checking
make format           # Format code with Prettier
make format:check     # Check formatting without fixing

# Security
make security         # Run security audit

# Docker
make docker:build     # Build Docker image
make docker:up        # Start all services
make docker:down      # Stop all services

# Release
make release:patch    # Bump patch version (1.0.x)
make release:minor    # Bump minor version (1.x.0)
make release:major    # Bump major version (x.0.0)

# Utilities
make clean            # Remove build artifacts
make fresh            # Clean install from scratch
make help             # Show all available commands

πŸ”Œ CLI Tool Reference

Deerflow includes a reference configuration for CLI tools commonly used in development. These are standard CLI tools invoked via subprocess, NOT MCP (Model Context Protocol) servers. MCP servers require JSON-RPC 2.0 over stdio or HTTP/SSE β€” see https://modelcontextprotocol.io for the MCP specification.

Tool Purpose
Docker Build, run, manage containers and services
PostgreSQL Execute queries, run migrations, inspect schema
Redis Cache operations, pub/sub, health checks
Git Commits, branches, tags, diffs
Vitest Run unit/integration/e2e tests with coverage
NPM Audit Audit, secret scanning, OWASP checks
ESLint Lint, format, type-check code

πŸ“„ License

This project is licensed under the MIT License β€” see the LICENSE file for details.


🦌 Clone it. Quality is non-negotiable.

⬆ Back to Top

About

🦌 Deerflow β€” The Enforcement Framework that forces AI Agents to build production-grade software. 9-Gate Quality Pipeline, Agentic Workflow Engine, Agent Skills, MCP Integration, and Zero-Tolerance for mock data, type errors, and security flaws. Clone it. Agents comply.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors