solid-code-synthesizer
Skill2 starsChanged 18 days agoMITView on GitHub
Synthesize and refactor C# 14 / .NET 10 domain models, Onion ports/adapters, workflow rules, and spatial/topology services using a 5-stage SOLID and Categorical invariant pipeline. Use when designing, implementing, or reviewing production C# code (Branch 2A or /implement-ticket) in GeoAssets.
In this repository12 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- code-gen-dagSkill
- outer-loop-dag-orchestratorSkill
- plan-gen-dagSkill
- solid-code-synthesizerSkill
- csharp-conventionsSkill
- jira-conventionsSkill
- observability-conventionsSkill
- outer-loop-dag-orchestratorSkill
- ui-ux-pro-maxSkill
- solid-code-synthesizerSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 2 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 20
Keep one axis of domain mutation per class (cyclomatic complexity $< 10$.
- Very specific: line 31
Never instantiate concrete infrastructure (new *DbContext(...), new HttpClient(...), new Postgres*(...)) inside domain or application …
- Very specific: line 37
LSP: Every concrete backend (EF*, Postgres*, Rest*, Shapefile*, InMemory*) must honor identical behavioral postconditions and event …
- Distinctive: line 43
Inline Validation / Rule Outcomes: Use explicit result/error-collector records where callers branch inline on expected validation outcomes.
- Very specific: line 50
Before reporting completion (or moving a Jira ticket to In Review), run both deterministic verifiers inside the active worktree:
≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
SOLID & Categorical C# 14 Code Synthesizer (Claude Code Specialist)
Complements csharp-conventions with an executable 5-stage synthesis and static-verification workflow tailored for Claude Code's Deep Reasoning & Domain Architecture role in GeoAssets.
5-Stage Synthesis Workflow
Execute domain synthesis in five progressive stages where each stage's output satisfies the next stage's preconditions ($g \circ f$):
1. SRP & Category Objects — Pure Domain Modeling
- Model immutable values, coordinates, bounding boxes, and typed IDs as
readonly record struct; model commands, events, and DTO payloads assealed record; reserveclassfor stateful services and entities with identity/lifecycle. - Keep one axis of domain mutation per class (cyclomatic complexity $< 10$; cohesive methods).
- Spatial Invariant: RFC 7946
[longitude, latitude]coordinate arrays (SRID 4326) remain the serialized JSON source of truth onGeoPoint/GeoLineString/GeoPolygon;NtsGeometryis lazily derived. - Onion Purity:
core/*assemblies must have zero references toMicrosoft.EntityFrameworkCore,Npgsql,GeoAssets.Provider.*,HttpClient, orapps/*(ArchitectureTests.cs).
2. ISP & Limit Projections ($\pi_k$) — Segregated Role Interfaces
- Design narrow, consumer-specific interfaces (
<= 5cohesive members per new port). Split query and mutation responsibilities (I*Readervs.I*Writer) so read-only consumers never depend on write operations or bloated test mocks. - Project cross-service payloads (
apps/GeoAssets.Server$\leftrightarrow$*.Rest) into minimal DTO records (JsonSerializerContextfor high-throughput GeoJSON/REST paths). - Enforce Razor separation: every component/page ships as markup-only
.razor+.razor.cspartial class (sole exception:apps/GeoAssets.MAUI/Pages/MauiLogin.razor).
3. DIP & Natural Transformations — Abstractions & DI Lifetimes
- Inject all collaborators via primary/constructor DI over
core/interfaces (IAssetProvider,IGeoAuthorizationService,IServiceOrderRepository) andSystem.TimeProvider(neverDateTime.Now/UtcNoworDateTimeOffset.Now/UtcNow—RS0030). - Never instantiate concrete infrastructure (
new *DbContext(...),new HttpClient(...),new Postgres*(...)) inside domain or application services. - Choose explicit DI lifetimes (
Transientstateless,Scopedper-request/DbContext,Singletonthread-safe only) and prevent captive dependencies (SingletoncapturingScoped). - Forward
CancellationTokento every async call and apply.ConfigureAwait(false)across non-UI library layers (core/,providers/,workflow/).
4. OCP & LSP — Pluggable Extension & Behavioral Substitutability
- OCP: Extend capabilities via pluggable contracts (
IServiceOrderRulechains,IProviderPlugin,IExternalProviderFactory,[ExportGeoCommand], and event-forwarding decorators likeActiveAssetProvider/ObservableServiceOrderRepository) instead of adding ad-hoc conditionals to core orchestrators. - LSP: Every concrete backend (
EF*,Postgres*,Rest*,Shapefile*,InMemory*) must honor identical behavioral postconditions and event semantics (FeatureAdded/Updated/Deleted/CollectionChanged) with zeroNotImplementedExceptionstubs. - Pair multi-backend repository/provider contracts with shared abstract contract test suites (modeled on
ServiceOrderRepositoryContractTestsinGeoAssets.Workflow.TestKit).
5. Categorical Effect & Boundary Error Semantics
Follow csharp-conventions/references/error-handling-and-result-pattern.md:
- Expected Absence: Return
Task<T?>(null/ HTTP404) orTry*shapes for routine lookup misses — never throw exceptions for control flow. - Inline Validation / Rule Outcomes: Use explicit result/error-collector records where callers branch inline on expected validation outcomes.
- Cross-Boundary Write Invariants (LSP Bijection): Throw specific domain exceptions on write/state-machine violations (
InvalidServiceOrderTransitionException,ServiceOrderConcurrencyException,ServiceOrderAttributeValidationException) and maintain bidirectional HTTP status + payload translation betweenapps/GeoAssets.Serverminimal APIs and*.Restclient repositories so remote and in-process implementations behave identically.
Mandatory Self-Verification Gate
Before reporting completion (or moving a Jira ticket to In Review), run both deterministic verifiers inside the active worktree:
python3 scripts/verify-solid-contracts.py --target .
./scripts/verify-agent-worktree.sh .Resolve all reported Exit 10, 20, and 30 diagnostics in source — never add #pragma warning disable, [SuppressMessage], or <NoWarn>.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

