Reusable documentation hub for Laravel projects following the Principle → Guideline → Standard hierarchy.
Usage as Submodule
Add this repository as a Git submodule at./ai-workflow/in your Laravel project, and customize only where needed (domain‑specific guides, examples, and branding). Always usemasterbranch for stable version.
⚠️ CRITICAL: Submodule is Read-Only
NEVER modify files inside the./ai-workflow/submodule directory - NO EXCEPTIONS. To override or customize, use local documentation in./docs/directory only.Usage for AI Agents
Any AI assistant (and human) working on the project must read and follow these documents before making changes or suggesting actions.
This documentation system operates on a two-tier hierarchy:
- Location: This repository mounted as a Git submodule at
./ai-workflow/in consuming projects - Contents:
ai-workflow.md- AI development workflow (MUST FOLLOW)architecture/- Principles, flow, patternsdevelopment/- Guidelines, code qualityreference/- Standards and quick lookupguides/- Implementation guides
- Rule: MUST BE FOLLOWED - This is the source of truth for all projects using this submodule
- Purpose: Reusable, framework-level documentation applicable to any Laravel project
- Branch: Always use
masterbranch (stable).developbranch is under development and may be unstable.
- Location:
./docs/in the consuming Laravel project - SEPARATE directory from submodule - Important: Local documentation is in a different directory (
./docs/) than the global documentation submodule (./ai-workflow/). They are NOT in the same directory. - Contents:
plans/- Project-specific feature/technical plans (actual project plans)decisions/- Project-specific Architecture Decision Records (ADRs)retrospectives/- Project-specific post-mortems and lessons learned- Any project-specific guides or documentation overrides
- Rule: CAN OVERRIDE global documentation (submodule) for project-specific needs
- Purpose: Project-specific documentation that extends or customizes global standards (submodule)
- Note: If local documentation doesn't exist, follow global documentation (submodule) only
⚠️ CRITICAL: To override global standards, create local documentation in./docs/. NEVER modify files inside./ai-workflow/submodule - it is read-only (NO EXCEPTIONS).
- Global Documentation (Submodule) = Base/Default - All standards, principles, and workflows defined here MUST be followed
- Local Documentation (Project) = Override/Extension - Project-specific documentation can override global documentation (submodule) rules when needed
- Conflict Resolution: If local documentation conflicts with global documentation (submodule), local takes precedence for that specific project
- Directory Separation: Global documentation (submodule) is in
./ai-workflow/, local documentation is in./docs/- they are in separate directories ⚠️ CRITICAL RULE: NEVER modify files inside./ai-workflow/submodule - it is read-only (NO EXCEPTIONS). All overrides MUST be done via local documentation in./docs/only.
<project-root>/
├── app/ # Laravel application code
├── config/ # Laravel configuration
├── ai-workflow/ # 🌐 Global Documentation (Submodule)
│ ├── README.md # From submodule
│ ├── ai-workflow.md # From submodule (MUST FOLLOW)
│ ├── architecture/ # From submodule
│ ├── development/ # From submodule
│ ├── reference/ # From submodule
│ ├── guides/ # From submodule
│ └── plans/ # Template structure only (examples)
└── docs/ # 📁 Local Documentation (Project-Specific)
├── plans/ # Actual project plans
│ ├── features/ # Feature plans
│ └── technical/ # Technical plans
├── decisions/ # Project-specific ADRs
└── retrospectives/ # Project-specific issues
┌─────────────────────────────────────────────────────────────┐
│ Laravel Project Root │
│ │
│ ┌──────────────────┐ ┌──────────────────┐ │
│ │ ./ai-workflow/ │ │ ./docs/ │ │
│ │ (Submodule) │ │ (Project) │ │
│ │ │ │ │ │
│ │ 🌐 GLOBAL │ │ 📁 LOCAL │ │
│ │ MUST FOLLOW │ │ CAN OVERRIDE │ │
│ │ │ │ │ │
│ │ • ai-workflow │ │ • plans/ │ │
│ │ • architecture/ │ │ • decisions/ │ │
│ │ • development/ │ │ • retrospectives│ │
│ │ • reference/ │ │ │ │
│ │ • guides/ │ │ │ │
│ │ • plans/ (template)│ │ │ │
│ └──────────────────┘ └──────────────────┘ │
│ │ │ │
│ │ │ │
│ └──────────┬───────────────────┘ │
│ │ │
│ ┌──────────▼──────────┐ │
│ │ Precedence Rules: │ │
│ │ 1. Global = Base │ │
│ │ 2. Local = Override │ │
│ │ 3. Local wins if │ │
│ │ conflict exists │ │
│ └─────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
Important:
- AI agents MUST read both global documentation (submodule) and local documentation (project) when available
- If local documentation (
./docs/) doesn't exist, follow global documentation (submodule) only- Global documentation (submodule) provides the foundation; local documentation provides project-specific context and overrides
- Directory Separation: Global documentation (submodule) is in
./ai-workflow/, local documentation is in./docs/- completely separate directories⚠️ CRITICAL: NEVER modify files inside./ai-workflow/submodule - it is read-only (NO EXCEPTIONS). All overrides MUST be done via local documentation in./docs/only.- How to Override: See CUSTOMIZATION.md for detailed examples and procedures
If you're cloning a Laravel project that already uses this documentation submodule:
# Clone the project with submodules initialized
git clone --recursive <project-repo-url>
# Or if you already cloned without --recursive:
cd <project-directory>
git submodule update --init --recursiveWhat This Does:
- Clones the main project repository
- Initializes and updates the
ai-workflow/submodule automatically - Ensures you have the complete documentation structure
After Cloning:
- Global documentation (submodule) is in
./ai-workflow/- READ-ONLY (NEVER modify) - Create local documentation in
./docs/if needed (see "Documentation Hierarchy" section above) - Remember: Never modify files inside
./ai-workflow/submodule - it is read-only (NO EXCEPTIONS)
-
Documentation for AI & humans
This global documentation (submodule) defines how work should be done in a Laravel codebase: architecture, module structure, quality gates, testing, and commit discipline. AI agents are expected to treat it as the source of truth for behavior and implementation patterns. -
Reusable in any Laravel project
The global documentation (submodule) is framework‑level, not app‑specific. You can mount this submodule at./ai-workflow/in any Laravel project and layer your own plans/ADRs/retrospectives in./docs/(local documentation). -
Modules are optional, but strongly recommended
The architecture and examples assume:- A Core area for cross‑cutting technical concerns (logging, responses, base services, etc.).
- One module per business domain (e.g., Billing, Catalog, Accounts), each with its own controllers, services, repositories, and models.
If your project doesn’t use a formal modules package, you can still follow the same modular boundaries in your folder structure.
-
Principles
What & Why – Engineering principles with embedded guidelines and standards:- Type safety and PHP version policy
- Modular architecture (core vs domain modules)
- Service / repository / SDK layering
- Testing, quality gates, and coverage
- Security, performance, and documentation standards
-
Flow
How the app works – Request/response flow and high‑level patterns:- HTTP → Middleware → FormRequest → Controller → Service → Repository/SDK → Database/External API
- When to use Resources vs raw JSON
- Example end‑to‑end flows across modules
-
Guidelines
How to implement – Step‑by‑step workflows and examples for:- Adding strict types and improving type safety
- Git & commit workflow (atomic commits, review flow, AI commit rules)
- Pull Request (PR) workflow (always from
develop, one feature per PR, plan-based) - Using the quality pipeline (Pint, PHPCS, PHPMD, PHPStan)
- Module creation and API development patterns
- Frontend patterns (Vue/TypeScript/Inertia if used)
-
Code Quality
Tools & configuration – How to run and configure quality tooling:- Tool stack (Pint, PHPCS, PHPMD, PHPStan, PHPUnit)
- Command shortcuts and recommended usage patterns
- Non‑negotiable rules around violations and suppressions
- Standards
Quick lookup – All concrete rules and exact requirements:- Type safety rules and PHPStan configuration
- Coverage targets by layer
- Naming conventions (classes, methods, variables) and module standards
- API response envelope and logging standards
- Git/commit message format, AI commit metadata, and pre‑commit checks
| Question | Document | Purpose |
|---|---|---|
| "What must we do?" | architecture/principles.md |
Understand the engineering standards |
| "Why do we do this?" | architecture/principles.md |
Learn the rationale behind requirements |
| "How do I implement this?" | development/guidelines.md |
Get step‑by‑step procedures |
| "What's the exact requirement?" | reference/standards.md |
Quick lookup for numbers/configs |
| "How does a request flow?" | architecture/flow.md |
See layer responsibilities & examples |
- New to the project? → Read
architecture/principles.mdto understand what we do and why. - Need to implement something? → Use
development/guidelines.mdfor step‑by‑step instructions. - Need specific numbers? → Check
reference/standards.mdfor quick lookup. - Understanding the architecture? → Review
architecture/flow.mdfor request/response and module patterns.
🎯 Principle (What & Why)
├─ 📋 Guidelines (How – Approach / Workflow)
└─ ⚙️ Standards (How – Exact / Numbers / Config)
Example:
- Principle: Type Safety – All code must be type‑safe with no implicit coercion.
- Guideline: Use strict types, explicit declarations, readonly dependencies.
- Standard:
declare(strict_types=1);in all PHP files, PHPStan at your chosen max level, no unsuppressed errors.
- AI Workflow – START HERE for AI agents. Multi‑agent pipeline, commit rules, and plan update protocol.
- AI Infrastructure Setup – Example local/hybrid AI dev setup (optional; adapt or ignore as needed).
Step‑by‑step tutorials and how‑to documentation (enable what you need per project):
- Writing Plans – Creating implementation plans with DoD, risks, and metrics.
- RESTful API Design – RESTful API design, UUIDs, status codes, pagination, filtering.
- Laravel Components & Patterns – All Laravel components (FormRequest, Resource, Service, Repository, Job, Event, Command, etc.).
- Testing Patterns – Unit/feature testing strategies and patterns.
- Security Best Practices – Validation, CSRF, rate limiting, credential management.
- Performance Optimization – N+1 prevention, caching, async processing.
- Module Creation – How to create and structure modules (core vs domain).
- Frontend Patterns – Vue 3 + TS + Inertia + Bootstrap dark theme (optional; only if your stack uses it).
- Directory Structure – How the documentation is organized.
Note: Modules and Inertia.js are optional, but the documentation assumes a modular architecture and provides guidance for it. Use or adapt depending on your project.
- Writing Plans Guide – How to write implementation plans.
In each project, keep your own plans under docs/plans/ in the parent repo (not in the submodule):
docs/plans/features/– Feature/product plans.docs/plans/technical/– Technical/refactor/infrastructure plans.
Note: The
ai-workflow/plans/folder in the submodule is a template structure only. Your actual project plans go indocs/plans/(local).
Architecture Decision Records (ADRs) documenting major architectural choices.
Keep project‑specific ADRs under docs/decisions/ in the parent repo.
Post‑mortems and lessons learned from production issues.
Keep project‑specific retrospectives under docs/retrospectives/ in the parent repo.
Note: Global retrospectives in
ai-workflow/retrospectives/(submodule) contain general lessons. Local retrospectives indocs/retrospectives/contain project-specific issues.
- Understand requirements →
architecture/principles.mdfor engineering standards. - Follow workflow →
development/guidelines.mdfor step‑by‑step implementation. - Check exact rules →
reference/standards.mdfor coverage targets, naming conventions. - Understand data flow →
architecture/flow.mdfor Controller → Service → Repository/SDK patterns and module boundaries.
- Run tools in order →
reference/standards.mdfor tool execution sequence. - Fix common issues →
development/guidelines.mdfor fixing quality pipeline errors. - Understand tool config →
development/code-quality.mdfor detailed tooling setup.
- Decide module placement →
architecture/principles.mdmodular architecture section (core vs domain). - Follow creation steps →
guides/module-creation.mdfor module creation workflow. - Check naming rules →
reference/standards.md(module and component naming). - Wire services & repositories →
architecture/flow.mdandguides/laravel-components-patterns.md.
- Understand coverage requirements →
reference/standards.mdfor coverage targets by layer. - Follow test patterns →
guides/testing-patterns.mdfor unit and feature test examples. - Learn testing principles →
architecture/principles.mdcomprehensive testing section.
- Follow integration patterns →
architecture/principles.mdthird‑party integration section. - Use SDK contracts →
architecture/flow.mdfor SDK patterns (no raw HTTP in services). - Check exact requirements →
reference/standards.md(integration and security standards).
The platform follows these core patterns:
HTTP Request → Middleware → FormRequest → Controller → Service → Repository/SDK → Database/External API
Core (Technical Infrastructure)
├─ Logging / audit helpers
├─ API response helpers
└─ Shared base services / support
Domain Modules (Business Logic)
├─ {DomainModule1} (e.g. Billing)
├─ {DomainModule2} (e.g. Catalog)
└─ {DomainModule3} (e.g. Accounts)
Modules Optional, But Recommended:
Even if you don’t use a modules package, follow the same principle: keep shared infrastructure in a “core” area and separate business domains into clearly bounded areas with their own services/controllers/repos.
Pint → PHPCS → PHPMD → PHPStan
Unit Tests (many) → Integration Tests (fewer) → E2E Tests (minimal)
composer install
npm install
php artisan serve # Laravel dev server
npm run dev # Frontend dev build (if applicable)composer lint # Run quality pipeline (Pint, PHPCS, PHPMD, PHPStan)
composer test # Run tests
composer test:coverage-check # Enforce coverage thresholds
npm run typecheck # TypeScript validation (if applicable)
npm run build # Production buildphp artisan module:make Blog # Create a new domain module (example)
php artisan migrate # Run migrations- Architecture – Long‑lived system design documents (principles, flow).
- Development – Workflow and tooling documentation (guidelines, code quality).
- Reference – Quick lookup specifications (standards, APIs, naming).
- Guides – Step‑by‑step tutorials (REST APIs, modules, testing, security, performance, frontend).
- Features / Technical (in parent project) – Implementation plans for user‑facing features and technical work.
- Decisions (in parent project) – ADRs documenting architectural choices.
- Retrospectives (in parent project) – Post‑mortems and lessons learned.
Documentation Quality Standards:
- All examples should be realistic and runnable (or clearly marked as pseudo‑code).
- Include both positive and negative examples (✅/❌) where helpful.
- Explain the “why” behind requirements, not just the “what”.
- Provide quick reference sections and link related documents instead of duplicating rules.
Copyright (c) 2025 Viet Vu
Company: JOOservices Ltd
Licensed under the MIT License.