Universal Agent Rules (AGENTS.md)
Mandatory architectural guidelines and execution rules for AI coding assistants.
Collaboration and Workflow Discipline
Proactive Clarification and Git Flow
- Proactive Clarifying Questions: Steven's conceptual designs evolve during development. Always ask insightful clarifying questions to define requirements, edge cases, and architectural constraints.
- Traditional Git Flow Discipline (see Traditional Git Flow Discipline):
main: Production tagged releases only (vX.Y.Z). Direct pushes are forbidden.develop: Primary integration branch for ongoing work. Merge feature branches here through Pull Requests.feature/*: Dedicated branches created offdevelop(feature/feature-name) for isolated work. Merge back todevelopafter Tier 2 and Tier 3 gates pass.release/*: Created offdevelop(release/vX.Y.Z) for version bumping, changelog finalization, and release verification before merging intomainanddevelop.hotfix/*: Created directly offmain(hotfix/vX.Y.Z) to fix critical production defects before merging into bothmainanddevelop.- Commit work using atomic Conventional Commits (
feat:,fix:,test:,docs:,chore:). - Open a Pull Request and verify that all Multi-Stage CI/CD Pipeline gates pass before merging.
Technical Writing and Living Documentation
Write all user-facing documentation, README files, architectural specs, and living guides according to our Technical Writing Standards, combining ASD-STE100 (Simplified Technical English) and the Google Developer Documentation Style Guide:
- Keep sentences short, concise, and direct (≤ 25 words per sentence).
- Use active voice and second-person imperative mood for instructions.
- Organize dense topics into scannable
H2andH3headings and scope cross-links to exact#sectionanchors. - Use standard Unicode symbols (
≥,≤) instead of raw LaTeX math syntax in prose. - Render architecture, sequence, state, and branching diagrams using native Mermaid syntax (
flowchart TD,sequenceDiagram autonumber,stateDiagram-v2,gitGraph). - Publish living documentation via VitePress deployed to GitHub Pages.
APIs First and Container Immutability
- APIs First, MCP Later (see APIs First, MCP Later):
- Implement domain logic and workflows inside clean, typed, self-contained libraries and REST/gRPC APIs before exposing them via Model Context Protocol (MCP).
- Keep MCP tools strictly as lightweight wrappers that forward requests to underlying service interfaces.
- Ensure core capabilities remain 100% testable through CLI, direct API calls, or integration harnesses without requiring MCP.
- Container Immutability:
- Never edit files or hot-patch code inside live running containers.
- Always rebuild via standard compose commands (
docker compose up -d --build) or pull official images.
- Container Target Architecture:
- Standardize strictly on native
linux/amd64for all container builds and CI workflows. - Do not include QEMU emulation or multi-architecture (
arm64) build steps in CI/CD pipelines.
- Standardize strictly on native
Core Code and Architectural Discipline
Modularity, Interfaces, and DRY
- SOLID and File Size Limit: Decompose files and classes exceeding 500 lines of code (≤ 500 LOC) into partial classes or focused sub-services (see SOLID and Modularity).
- Interfaces by Default: Build client-focused interfaces (
I*in C#) even for single implementations to ensure loose coupling and testability. - DRY vs. YAGNI:
- Rule of Three: Permit duplication across two instances; refactor into a shared abstraction on the third occurrence.
- Do not invent speculative multi-tier frameworks (YAGNI).
Semantic Naming and Anti-Pattern Bans
- Banned: Never create
*Manager,*Helper,*Util, or*Datajunk-drawer classes (see Semantic Naming and Anti-Pattern Bans). - Enforced: Use role- and action-based names (
DatabaseSeederService,UserAuthenticator,ServerStatusCard,use*Store.ts).
Database, Frontend, and Error Handling
- Database Efficiency: Consolidate operations requiring three or more database round-trips or complex multi-table joins into a single Stored Procedure (
.sqlfile) or batch query. - Frontend Selectors: Use granular Zustand selectors (
useServerStore(s => s.servers.length)) to prevent render cascades. - Error Handling and Diagnostics: Never leak raw stack traces to API clients. Log structured debug payloads with the exact inputs and state that triggered the failure.
Polyglot Language Matrix
| Stack | Core Conventions & Tooling | Archetype Blueprint |
|---|---|---|
| C# (.NET 10) | .slnx, System.CommandLine, full DI, Dapper + Stored Proc .sql files, SQLite WAL / MSSQL, native C# UIs (WPF/WinForms/Avalonia, no Electron), full CancellationToken propagation. | Fullstack (.NET + React) • .NET Console & CLI |
| Python (3.12+) | uv, pyproject.toml, FastAPI + FastMCP, Pydantic v2 schemas, asyncio, pytest (≥ 80% coverage), ruff. | Python FastAPI & FastMCP |
| TypeScript / React | React + strict TS + Vite, Zustand domain stores, pure CSS Modules + custom properties, playwright-layout-inspector 4-point audit. | React, TS & Vite UI |
| C++ (C++20/23) | MSBuild (Win) / CMake (Linux), vcpkg, strict RAII, smart pointers, GoogleTest (gtest), ASan/UBSan, Benchmark, C# [LibraryImport] / Python pybind11 interop. | C++ Native Algorithms |
Testing and Agent Verification Protocol
Observable Systems and Tiered Cadence
- Software as an Observable Dynamic System:
- Model critical workflows, boundary crossings, and stateful protocols with diagnostic tap points, metrics, and health probes.
- Build closed-loop simulation harnesses with high-volume stress loops, parameter sweeps, and synthetic disturbance ingestion.
- Tiered Testing Cadence (see Tiered Testing Cadence):
- Tier 1 (Inner Loop): Run fast, isolated in-memory unit tests on demand during active development.
- Tier 2 (Stabilization Gate): Run unit and targeted integration suites once feature interfaces stabilize, immediately before manual verification.
- Tier 3 (Pre-PR & CI Gate): Execute the full test matrix, multi-provider integration suites, simulation stress loops, and Playwright layout audits before merging.
The Four Pillars of Anti-Test Theatre
Never write Test Theatre (mock-heavy tests that verify method calls instead of real system state). Enforce the Four Pillars of Anti-Test Theatre and the 12-dimension Banned and Mandated Patterns Matrix:
- Pillar 1: Real Over Mock: Test software with real components and in-memory SQLite (WAL mode) databases instead of mocking
IRepository<T>orDbContext. Mock only unmanageable external third-party network boundaries. - Pillar 2: Outcomes Over Calls: Assert observable state deltas (database records, generated files, response payloads, emitted events). Never use
mock.Verify()as primary proof of success. - Pillar 3: Representative Dogfooding: Execute a real CLI subprocess or full HTTP request-response roundtrip for every feature before claiming completion.
- Pillar 4: Value Over Numeric Vanity: Prioritize boundary conditions, disturbances, and concurrency over shallow line coverage. Do not write tests for boilerplate POCOs, DTOs, or auto-properties.
Deterministic Test Budget Formula
Analyze the function or feature Abstract Syntax Tree (AST) before authoring tests to compute the exact required budget (see Deterministic Test Budget Formula):
Test Budget = 1 (Nominal) + N_Branches + N_Boundaries (0-1-N) + N_Disturbances- Nominal Path (1 test): One test exercising the happy path with valid nominal data.
- Decision and Guard Branches (1 test per branch): One test per independent branch (
if,switch, validation guard, or explicitthrow). - 0-1-N Boundary Conditions (1 to 3 tests):
0(empty/null/zero),1(single item/minimum), andN(large batch/maximum). - Disturbances and Lifecycle (1 test if async or stateful): One test validating
CancellationTokenpropagation, timeout recovery, or state idempotency.
Deterministic Five-Question Mock Decision Tree
Pass every candidate collaborator through the Five-Question Mock Decision Tree before creating any mock or stub:
- Is the dependency internal to the current solution? If yes, use the real component via dependency injection or direct instantiation.
- Is it a database or persistent store? If yes, use a real in-memory database (SQLite WAL or ephemeral instance).
- Is it the system clock or non-deterministic time? If yes, use a time abstraction (
TimeProviderortime-machine). - Is it an external third-party HTTP API (such as Stripe or SendGrid)? If yes, use a contract stub (
WireMock.Netorrespx). Never mock internal interfaces. - Is it child process STDIO or an OS pipe? If yes, use a synthetic transport (
mock_stdio.js) with fault injection.
If you answer "No" to all five questions, mocking is forbidden. Use the real implementation.
Coverage, UI Layout Audits, and Feedback Envelopes
- Coverage Target: Maintain ≥ 80% code coverage across unit, integration, and end-to-end suites, excluding trivial POCO and DTO boilerplate.
- UI Layout Inspection: Verify that frontends pass the 4-point
playwright-layout-inspectoraudit (zero overflow, mobile fit, ≥ 24px touch targets, ≥ 85 layout score; see UI Layout Stability and Ergonomics Auditing). - Six-Part Agent Feedback Envelope: Format all harness or test failures using the Six-Part Agent Feedback Envelope (
inputs,assumptions,active_settings,action_history,output_delta,captured_logs, andreproduction_command). - Empirical Verification: Never claim a task is complete without running builds, executing tests, inspecting logs, and probing
/health.
Multi-Lens Code Review and Operational Guardrails
The Six Reviewer Foci and Requirements Traceability
- Six Reviewer Foci: Before opening or finalizing any Pull Request, evaluate the diff across all six lenses in Multi-Lens Code Review and The Six Reviewer Foci:
- Focus 1: Requirement Traceability and Feature Preservation (
[Requirement(...)]/@requirementannotations usingAUTH,DB,GUARD,MCP,SEC,TRANS,UItaxonomy; zero feature deletions without instruction). - Focus 2: Architecture, Modularity, and Safe Serialization (
≤ 500LOC cap,I*interfaces, APIs First/MCP wrapper, andJsonNode/Pydantic manipulation instead ofstring.Replace). - Focus 3: Anti-Test-Theatre and Live-Executor Isolation (real SQLite WAL / in-process transport,
0-1-Nboundaries, AST test budget,pytest -m "not live"). - Focus 4: Security, Subprocess Safety, and Container Immutability (sanitized argument arrays without
shell=True,100% CancellationTokenpropagation, AES-256-GCM encrypted secrets, immutable containers). - Focus 5: UI Consistency, Layout Stability, and Real Screenshots (CSS variables,
scrollbar-gutter: stable, 4-point Playwright layout audit, and real Playwright/Puppeteer screenshots in UI PRs). - Focus 6: Living Documentation, Atomic Commits, and Release Sync (
README.md/ARCHITECTURE.md/docs/updated, atomic Conventional Commits, lockstep version bump with the docs-only exception).
- Focus 1: Requirement Traceability and Feature Preservation (
- Requirements Traceability: Annotate all new and modified tests and keep
REQUIREMENTS.mdsynchronized with zero drift (see Requirements Traceability and Living SRS Catalogs).
Context Hygiene, Subprocess Safety, and Release Gates
- Targeted File Search: Never run unbounded
greporripgrepacross a repository root. Always scope searches using path prefixes or file globs (include_pattern) to avoid scanning build artifacts or lockfiles (see Scoped Search and Context Window Hygiene). - Lockstep Version Sync and Docs-Only Exception: Bump all project manifests, frontend version stores, and
CHANGELOG.mdsimultaneously for code changes; skip version bumps and container rebuilds for documentation-only changes (see Lockstep Version Sync and the Documentation-Only Exception). - Post-CI Verification and Dedicated Component Repos: Always wait for GitHub Actions CI checks (
gh pr checks --watch) to pass before finalizing PRs or pulling images, verify/healthafter container recreation, and always commit/PR standalone components from their dedicated repositories in~/Repos/(see Post-CI Verification and Container Health Gates).