07ad98ec12
## Summary - **CLAUDE.md optimization:** Move engineering guidelines to AGENTS.md only (governance lock) - Removed: Governance, Testing Strategy, Observability details, Common Workflows, Guardrails - Kept: Project status, timeline, architecture high-level overview, quick reference - Result: 47KB → 12.1KB (75% reduction, well within 40KB limit) - **AGENTS.md expansion:** Add 5 missing engineering procedure sections - v16.0 Testing Strategy (xUnit/Vitest/Playwright organization, commands, rules) - v16.0 Backend Architecture (Vertical Slice, Database/Migrations, Hangfire Job Design) - v16.0 Frontend Architecture (Registry-driven screens, KBX contracts, UI adapter boundary) - v16.0 Observability (Logging, Tracing, Dashboards, Metrics) - v16.0 Common Workflows (Adding Vertical Slices, Refactoring, Creating Jobs) - **New companion docs** (no duplication, supplement AGENTS.md): - docs/ARCHITECTURE_DETAILED.md — Deep dive on backend/frontend patterns - docs/COMMON_WORKFLOWS.md — Workflow procedures with examples - docs/GITEA_API_REFERENCE.md — Gitea API + External data sources ## Governance (enforced) - All engineering procedures now in AGENTS.md ONLY - CLAUDE.md = project context only (status, timeline, overview) - Companion docs reference AGENTS.md (no duplicate guidance) - No conflicting guidance across multiple sources ## Result - CLAUDE.md: 12.1KB ✅ (within 40KB limit) - AGENTS.md: 44.8KB (comprehensive procedures) - Single source of truth for all engineering guidelines Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
4.4 KiB
4.4 KiB
Common Workflows
Reference: For quick commands, see CLAUDE.md "Quick Start" section.
Governance: All work follows AGENTS.md v16.0 and VIBE Coding Guardrails.
Adding a New Vertical Slice
-
Scaffold the structure:
python tools/scaffold_vertical_slice.py --name MyFeature --module ModelOperations -
Define the contract (before code):
- Request/Response DTOs in
Contracts/ - Event schema in
Contracts/Events/if async coupling needed - Validation rules (vee-validate schema on FE, Fluent on BE)
- Request/Response DTOs in
-
Implement backend slice:
Handler.cs: Orchestration, transaction handlingPolicy.cs: Pure business logicSql.cs: Dapper queries (schema-qualified, no SELECT *)Endpoint.cs: HTTP routing & status codesREADME.md: Traceability link to requirement/ADR
-
Write tests:
- Unit: Policy, Mapper logic
- Integration: Handler + Dapper + real DB
- Verify Outbox events are created if async
-
Implement frontend feature:
- Feature module under
features/<feature>/ - Use
features/<feature>/pages/for route-level components - Use
shared/ui/adapter/for any UI component usage - Form validation with vee-validate + Zod schema from BE contract
- Feature module under
-
Validation gates (pre-merge):
- Architecture tests pass
- DB migration is idempotent (fresh/upgrade test)
- No SELECT *, no direct cross-module queries
- Outbox/Inbox tests if async
- Frontend typecheck + test + build
- E2E smoke test (if user-facing)
Refactoring (Characterized, Isolated, Verified)
- Characterize: Lock current behavior with tests + perf baseline + Golden data.
- Isolate: Separate I/O (Dapper queries, HTTP) from logic (Policy).
- Transform: One small change at a time (rename, extract, move).
- Verify: All tests pass, no perf regression, backtest algorithm changes against Golden.
- Simplify: Delete dead abstractions, feature flags, branches.
- Observe: Post-release SLO/DQ/model drift monitoring.
- Close Debt: Update Debt ID, leave ADR for future maintainers.
Creating a Background Job
-
Define the command:
public class MyJobCommand : ICommand { public Guid IdempotencyKey { get; set; } public Guid CorrelationId { get; set; } public string InputData { get; set; } } -
Implement the handler:
- Idempotent: Re-run should be safe and produce same result.
- Classify failures: transient/permanent/dq/business-hold.
- Emit events to Outbox for async notifications.
-
Schedule via Hangfire:
await backgroundJobClient.EnqueueAsync<MyJobHandler>(h => h.Handle(command)); -
Test retry & replay scenarios:
- Job runs successfully.
- Job fails and is retried (verify idempotency).
- Job is replayed from cold state (verify determinism).
Testing Strategy
xUnit Backend Tests
dotnet test KArtSell.sln -c Release
dotnet test --filter "Category=Integration" -c Release
dotnet test --filter "FullyQualifiedName~UnitTests" -c Release --verbosity quiet
Test Levels:
- Unit: Pure functions (Policy, Mapper), no I/O. Fast, deterministic.
- Integration: Handler + Dapper + real PostgreSQL. Validates transaction boundaries, Outbox/Inbox.
- Data: SQL query validation, schema conformance, index effectiveness.
- E2E: Full HTTP stack; used sparingly for critical paths.
- Golden/Frozen OOS: Before merging algorithm changes, lock baseline and diff against new run.
Vitest Frontend Tests
cd frontend
pnpm test # Run all tests
pnpm test -- --reporter=verbose # Verbose output
pnpm test -- <test-file-pattern> # Run subset
pnpm test -- --coverage # Coverage report
Playwright E2E
cd frontend
pnpm e2e # Run all E2E tests headless
pnpm e2e -- --debug # Debug mode (browser stays open)
pnpm exec playwright test --headed # Run with browser UI
Tools & Scripts
Scaffolding
python tools/scaffold_vertical_slice.py --name MyFeature --module ModelOperations
python tools/scaffold_ui_screen.py --name MyScreen --feature MyFeature
Validation
python tools/validate_v16.py # Full v16 validation (contracts, migrations, Python tests)
python -m unittest discover # Run all Python unit tests