UISampleSpark: Constitution-Driven Development
For nearly seven years, UISampleSpark operated on implicit rules. In February 2026, a constitution-driven approach powered by AI agents analyzed the codebase, surfaced unwritten conventions, formalized 11 principles with 30 enforceable requirements, and resolved three critical compliance gaps.
UISampleSpark: Constitution-Driven Development
Part 3 of the UISampleSpark Series — Governance and AI
From Implicit Rules to Explicit Governance
For nearly seven years, UISampleSpark operated on implicit rules. Experienced contributors knew that all data access went through repository interfaces. They knew that
FromSqlRawIn early February 2026, that changed. Over the course of roughly 48 hours, the project underwent its most significant transformation since its founding — not in features or framework versions, but in governance, compliance, and development workflow. The catalyst was a new approach called Constitution-Driven Development, powered by AI agents that could analyze a codebase and surface its unwritten rules.
Discovering the Constitution
The transformation began with a fundamental question: "What are the implicit rules governing this codebase?"
Using the
speckit.discover-constitution- 94 C# source files across 6 projects
- 10 configuration files (,
.csproj,global.json).editorconfig - 5 GitHub Actions workflows
- 4 documentation files (README, CHANGELOG, CONTRIBUTING, SECURITY)
The analysis identified 16 high-confidence patterns — conventions the codebase followed with 100% consistency:
| Pattern | Consistency |
|---|---|
| Nullable reference types enabled | 100% |
| 100% |
| Repository pattern for data access | 100% |
| DTO/Entity separation | 100% |
| No raw SQL (EF Core LINQ only) | 100% |
| Async/await for all I/O | 100% |
| Code analysis at strictest level | 100% |
| Dependency injection everywhere | 100% |
But the analysis also revealed gaps. Two stood out:
- ILogger usage: 0% of service classes used structured logging. They operated silently, with no way to trace execution flow in production.
- XML documentation: Only about 40% of public APIs had XML doc comments, leaving Swagger UI incomplete.
The Educational Scope Decision
One of the most consequential discoveries was what the analysis initially flagged as a deficiency: the project had no authentication or authorization.
Through interactive discussion, this was reframed not as a bug but as a feature. The project's educational mission required that authentication be absent — its presence would obscure the CRUD patterns that were the project's reason for existing. This decision was formalized as Principle IV: Security Posture (Educational Scope):
"This is an educational/reference project demonstrating ASP.NET Core patterns. It intentionally omits authentication, authorization, and other production-hardening features to focus on core CRUD patterns."
The Eleven Principles
From 16 discovered patterns and 10 interactive questions, the team synthesized 11 Core Principles into a formal constitution document:
- Code Quality and Safety — Nullable types enabled, latest C# language version, strictest analysis level.
- Architecture and Design Patterns — Repository pattern, dependency injection, async/await, in libraries, no raw SQL.
ConfigureAwait(false) - Error Handling and API Contracts — Global exception handler, RFC 7807 ProblemDetails, proper HTTP status codes.
- Security Posture — Educational scope with explicit limitations documented. HTTPS in non-development environments.
- Testing Standards — MSTest framework, Arrange-Act-Assert pattern, 25% code coverage baseline.
- CI/CD and DevOps — Three required GitHub Actions workflows: test-and-build, security scanning, Docker build-and-push.
- Observability and Health — Structured logging with , health checks at
ILogger<T>, Swagger/OpenAPI documentation./health - Documentation Standards — README maintained, CHANGELOG updated, XML documentation on public APIs.
- Dependency Management — Latest .NET version adopted, quarterly package audits, enforces SDK version.
global.json - Docker and Containerization — Multi-stage builds, Alpine base images, non-root user, Hadolint compliance.
- AI-Assisted Development — Session work organized under , drafts and audit reports structured.
/.documentation/copilot/
Each principle was classified by enforcement level: MUST (mandatory, blocking), SHOULD (strongly recommended), or MAY (optional best practice). The constitution contained 30 MUST requirements in total.
The Compliance Gap
With the constitution formalized, an audit revealed the codebase was at 82% compliance. Twenty-seven of 30 MUST requirements were met. Three critical violations were identified:
Violation 1: Missing Test/Build CI Workflow
Despite having Docker and CodeQL workflows, the project had no GitHub Actions workflow that ran
dotnet testViolation 2: No Global Exception Handler
The project lacked an
IExceptionHandlerViolation 3: Insufficient Security Documentation
The existing
SECURITY.mdThe Sprint to 100%
Each fix was implemented with the rigor the constitution demanded:
Fix 1: Test and Build Workflow
A new
.github/workflows/test-build.ymlFix 2: Global Exception Handler
A new
GlobalExceptionHandlerFix 3: Security Documentation
The
SECURITY.mdBonus: Structured Logging
ILogger<T>GlobalUsings.csNullLogger<T>.InstanceAll 240 tests passed after the update.
SpecKit Spark: AI Agents for Lifecycle Management
The constitution work revealed gaps in AI-assisted development tooling. Three new agents were created:
The Evolve Constitution Agent
Analyzes pull request review patterns for recurring violations. When multiple PRs show an uncovered pattern, it generates a Constitution Amendment Proposal with change history tracking.
The Quick Fix Agent
Provides a lightweight workflow for small changes that don't justify full specification overhead. Bug fixes and configuration changes receive constitution compliance validation without the full spec/plan/tasks ceremony.
The Release Agent
Archives completed development artifacts, generates Architecture Decision Records from key decisions, creates CHANGELOG entries, and prepares a clean slate for the next development cycle.
These three agents expanded SpecKit Spark from 13 to 16 specialized agents, covering the complete project lifecycle.
The Final Audit
After all fixes were implemented, a final compliance audit confirmed:
| Metric | Before | After |
|---|---|---|
| Constitution Compliance | 82% (27/30) | 100% (30/30) |
| Critical Violations | 3 | 0 |
| Build Warnings | 0 | 0 |
| Test Pass Rate | 100% (240/240) | 100% (240/240) |
| Line Coverage | 93.2% | 94.1% |
| Branch Coverage | N/A | 77.3% |
| Method Coverage | N/A | 95.9% |
Lessons from the Transformation
Constitution First, Implementation Second
Having a formal constitution revealed gaps that would have remained as technical debt indefinitely. The codebase already exhibited 80%+ consistency across most patterns — formalization made implicit rules explicit and exposed the critical gaps.
Educational Scope Is a Feature, Not a Bug
Authentication omission was initially flagged as incomplete. Reframing it as an intentional design decision, prominently documented, transformed a perceived weakness into a governance strength.
ILogger Breaks Tests — Plan for It
Adding
ILogger<T>AI Agents Need Lifecycle Support
Feature development workflows (spec, plan, tasks) are necessary but insufficient. Projects also need support for quick fixes, constitution evolution, and release management.
What Changed in 48 Hours
- 1 formal constitution with 11 principles and 30 MUST requirements
- 3 critical fixes (CI workflow, exception handler, security docs)
- 4 service classes updated with structured logging
- 3 new AI agents for lifecycle management
- 14 files changed with +12,600 lines added
- 0 regressions — all 240 tests passing throughout
Additional Resources
- UISampleSpark Constitution on GitHub
- SpecKit Spark Documentation
- RFC 7807 — Problem Details for HTTP APIs
UISampleSpark Series
This is part 3 of a five-part series tracing the evolution of UISampleSpark from a simple CRUD tutorial to a comprehensive web UI exploration platform.
- A Developer's Swiss Army Knife — The founding philosophy and core architecture
- Seven Years of .NET Modernization — Navigating the annual .NET upgrade cycle
- Constitution-Driven Development (this article) — How governance and AI transformed project quality
- Seven UI Paradigms, One Backend — Comparing seven frontend approaches side by side
- Modern DevOps as a Living Reference — Containerization, CI/CD, and cloud deployment
Project Links: GitHub | Live Demo | Docker Hub


