codex/skills/universalist/SKILL.md
Use when repeated validation, policy branching, protocol/state-machine drift, generated provenance loss, callback/effect boundaries, or semantic-consumer context point to structural refactor over local polish. Select one signal, one world boundary, and the smallest honest construction: typed state, free syntax, observations/projections, lifted interpreter/handler, explicit IR, law tests, canonical boundary artifact, Composition Certificate, Boundary Normal Form step, or Exact Context/Context Certificate. Prefer adapter-first staging and one falsifiable proof signal; escalate to Kan/codensity/free-builder mechanics only after a real cross-world boundary is identified.
npx skillsauth add tkersey/dotfiles universalistInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Use this skill when the highest leverage comes from changing the shape of truth in a codebase, not from adding another ordinary feature branch.
This is an inner lens for choosing the right structural move. It is not a generic implementation skill. Use it to decide and stage the structure, then let the repo's normal implementation flow carry the change.
The enriched slogan is:
Universal architecture is the practice of designing software around canonical boundary artifacts: free syntax, coherent observations, transported semantics, lifted implementations, free builders behind projections, obstruction reports, behavioral coalgebras, effect signatures with handlers, explicit IRs, and law tests.
Core discipline:
Allow arbitrary domain primitives, but do not allow arbitrary composition across architecture boundaries.
Ordinary code may live inside a boundary: I/O, math, parsing, vendor APIs, database drivers, model calls, clocks, randomness, local algorithms, and low-level loops. Composition boundaries should be explicit artifacts: syntax, observations, projections, transports, lifts, handlers, state transitions, IRs, or law tests.
Maxim:
Allow arbitrary primitives. Forbid arbitrary composition.
A software system is universally architected when every meaningful composition boundary between worlds factors through a canonical boundary artifact, and every such artifact has an interpreter, projection, lowering, handler, or law-test witness.
Use this doctrine to separate two questions:
Can the primitive compute? Ordinary implementation question.
Can the boundary compose? Universal architecture question.
A Composition Certificate is the unit of universal architecture. It records:
worlds
boundary
unknown location
canonical artifact
interpreter / projection / lowering / handler
law witness
falsifier
bypass policy
A codebase is in Boundary Normal Form when all meaningful cross-world composition boundaries have Composition Certificates, and all bypasses are removed or explicitly justified as primitive effects.
Engineering law:
No boundary without an artifact.
No artifact without an interpreter.
No interpreter without a law.
No law without a falsifier.
Use Track E when the user wants to move a codebase toward Boundary Normal Form, or when the main output should be a Composition Certificate rather than an immediate implementation.
The codensity transcript adds one more architectural question: not only what canonical artifact owns the boundary, but how that artifact is presented. Complex artifacts need presentation strategies.
Use this extension of the engineering law stack:
No boundary without an artifact.
No artifact without a presentation.
No presentation without an interpreter / projection / reconstruction.
No reconstruction without a law.
No law without a falsifier.
Presentation modes:
New doctrine sentence:
Primitives compute. Boundaries compose. Presentations compress. Contexts prepare. Witnesses certify.
Dense-Dual Presentation principle:
When a semantic artifact is too large, infinitary, observational, or completion-like to present by generators and equations, try to present it by a small dense world of probes plus a duality or observation bridge into the semantic world.
Reject canonical-but-useless presentations. Prefer small, testable, dense presentations that separate generic boundary machinery from domain-specific representation assumptions.
Maxim:
Allow arbitrary sources. Forbid uncertified semantic consumption.
Exact Context Doctrine is the context-preparation layer of Universal Composition. It applies whenever a model, human, policy engine, planner, scheduler, workflow, tool selector, compiler pass, or other semantic consumer is about to decide, act, rank, classify, answer, approve, execute, or infer.
A semantic consumer should not receive raw retrieved material, raw tool output, stale memory, untyped chunks, or unconstrained summaries. It should receive a task-indexed, schema-shaped, constraint-closed, provenance-preserving, freshness-valid, observationally minimal context instance.
Use this pipeline:
Task q
-> task-specific context schema T_q
-> task observables Obs_q
-> candidate source instance I_candidate
-> source-to-context mapping M_q
-> migrated context instance
-> chase / deterministic constraint closure
-> provenance + missingness + contradiction structure
-> observational core relative to Obs_q
-> rendered decision packet
-> semantic consumer
Compact formula:
Context(q) = core_Obs(chase(migrate_{M_q}(I_candidate)))
DecisionPacket(q) = render(Context(q))
The prompt is not the context. A prompt, dashboard, JSON payload, tool argument, review packet, or decision brief is only a rendering of the semantic context.
Engineering law:
No semantic consumption without certified context.
No context without a schema.
No schema without observables.
No observables without provenance and freshness.
Use Track F when the main issue is having just the right data at just the right time.
Exact Context is universal, not agent-specific. The general boundary is:
Prepared Context -> Semantic Consumer
A semantic consumer may be a model, human reviewer, policy engine, compiler pass, workflow scheduler, deployment controller, planner, ranker, classifier, BI dashboard, auditor, test harness, action selector, or agent runtime.
Use this plane split:
Operational Source Plane
mutable systems of record, logs, documents, APIs, event streams, tools, live stores
Candidate Plane
retrieved / observed / sampled / extracted candidate source instances
Verified Context Plane
schemas, mappings, constraints, provenance, normalization, reconciliation
Publication Plane
stable task-indexed context snapshots and Context Certificates
Rendering Plane
prompt, JSON packet, dashboard, report, tool args, policy input, review packet
Semantic Consumption Plane
consumer decision, action, approval, execution, ranking, inference, or audit
Rule:
Operational stores own mutation.
Verified context planes own semantic publication.
CQL and categorical databases are reference technologies for the verified context plane when schemas, mappings, constraints, integration, and provenance matter. Do not treat CQL as a default live-memory substrate. Pair it with operational stores when low-latency mutation, distributed writes, access control, or streaming are central.
Before choosing Track A/B/C/D/E/F for any non-trivial structural request, inventory the worlds and boundaries. This prevents fake category labels and keeps the response anchored in repo reality.
A world is a structured domain where some objects, transformations, invariants, observations, primitives, and composition rules make sense.
A boundary is a map between worlds: embedding, projection, forgetful API, interpreter, compiler, serializer, view/query, handler, observer, migration, or adapter.
For each candidate world, record:
World:
Objects:
Transformations:
Invariants:
Observations:
Primitives:
Composition rules:
Equality/coherence notion:
For each candidate boundary, record:
Boundary:
Kind:
Source world:
Target world:
Preserved:
Forgotten:
Generated:
Observed:
Unknown location:
Candidate artifact:
Law test:
Falsifier:
If this inventory cannot be filled for the seam, do not escalate to Track D or Track F.
Classify boundary maps before choosing canonical artifacts.
| Boundary kind | Software shape | Usually suggests |
| --- | --- | --- |
| Embedding | old/core included in new/target | transported semantics, Lan, Delta, compatibility witness |
| Projection | internals observed as public behavior | lifted implementation, residual obligations, Freyd/AFT diagnostic |
| Forgetful map | rich structure erased to raw view | free builder / left adjoint question |
| Interpreter | syntax/program/effect -> behavior | free syntax, algebra/handler/fold |
| Compiler/lowering | source syntax/IR -> target IR/code | transported semantics, Coyoneda path, lowering law |
| Serializer/codec | internal model -> wire/storage | adapter, projection law, round-trip/invariant preservation |
| View/query | model -> read/report/client view | coherent observations, Yoneda observation vocabulary |
| Handler | effect syntax -> runtime behavior | effect signature, handler laws, defunctionalized operations |
| Observer | subject -> observation result | Yoneda vocabulary, law-test oracle |
| Migration | old schema/world -> new schema/world | Delta, Lan/Sigma, Ran/Pi, provenance path |
| Context compiler | source worlds -> task context schema | Exact Context, data exchange, chase/closure, observational core |
| Semantic consumer | prepared context -> decision/action/inference | Context Certificate, rendering law, freshness law |
Do not skip this taxonomy. It decides whether the seam is an extension, a lift, a free-builder question, a coalgebra, an effect handler, or just an adapter.
A module or domain deserves to be treated as a world only if it has enough structure to support boundary laws.
A proposed world is too weak if:
When a world is too weak, use ordinary refactoring language and strengthen the model before applying universal architecture.
Boundary drift means two worlds communicate through uncoordinated paths or hidden assumptions.
Common drift signals:
Map drift to artifacts:
semantic drift -> transported semantics / Lan-style artifact
observation drift -> coherent observations / Ran / Yoneda vocabulary
implementation drift -> lifted implementation / Freyd diagnostic
creation drift -> free builder behind projection or obstruction report
generation drift -> Coyoneda-style generation path vocabulary
control-flow drift -> defunctionalized explicit IR
behavioral drift -> behavioral coalgebra / protocol observation law
effect drift -> effect signature + handler laws
context drift -> task-indexed context instance + Context Certificate
Use these named law shapes when designing proof signals:
| Boundary | Law shape |
| --- | --- |
| Embedding law | new(embed(old)) == old(old) |
| Projection law | observe(project(internal)) == expectedPublicBehavior |
| Forgetful law | forget(combineRich(a,b)) == combineRaw(forget(a), forget(b)) |
| Interpreter law | interpret(translate(syntax)) == oldBehavior(syntax) |
| Serializer law | decode(encode(internal)) preserves public invariants |
| Migration law | oldReport(old) == oldReport(restrict(migrate(old))) |
| Handler law | run(handler(program)) satisfies operation observations |
| Coalgebra law | observe(step(state,input)) satisfies protocol trace expectations |
| Generation law | lowerGenerated(payload,path) == directInterpret(path,payload) |
| Observation law | runObservation(obs,repack(subject)) == runObservation(obs,subject) |
| Defunctionalization law | apply(encodedCase,x) == oldFunction(x) |
| Context schema law | Context(q) satisfies task schema T_q |
| Observable preservation law | every required observable is answered, missing, contradicted, or unsupported explicitly |
| Provenance law | every evidence-bearing claim has a path to source or assumption marker |
| Freshness law | sources satisfy task freshness requirements at semantic consumption time |
| Rendering law | render(Context(q)) preserves required observables under loss/token limits |
Every Track D artifact should have one positive law test and one falsifier/negative witness.
Use when the user wants analysis, design review, refactor advice, or a structural reading of the current code.
Deliver:
Use when the user wants code changes, but the right move is narrow and reviewable.
Deliver:
Use when the internal model should improve while API, JSON, DB row, or message shapes stay stable for now.
Deliver:
.universalist-plan.md update.Use when the smell is no longer just “choose a better type” but “choose the canonical artifact at a boundary.”
Deliver:
Use Track D for:
P : internals -> observable behavior is vague, lossy, or intended to support a canonical implementation builder.Use this kernel for Track D decisions:
K, projection P, interpreter, serializer, handler, report/view, compiler, observer.P : B -> C supports canonical construction back into B.Choose by where the unknown lives:
| Unknown lives... | Default artifact | First proof signal |
| --- | --- | --- |
| In independent fields | Product | projections round-trip |
| In exclusive cases | Coproduct | exhaustive handling, invalid cases rejected |
| In a stable predicate | Refined type / equalizer | constructor accepts valid and rejects invalid |
| In shared projection agreement | Pullback witness | mismatches rejected, projections preserved |
| In configurable supplied behavior | Exponential / strategy | fixture parity with old branch |
| In structured syntax from generators | Free construction / initial algebra | interpreter agrees with old evaluator |
| In ongoing behavior over time | Behavioral coalgebra | traces/unfolds satisfy observations |
| In effectful operations with handlers | Effect signature / free effect syntax | test and production handlers agree on declared observations |
| After a source-to-target boundary K | Transported semantics / Lan-style | identity or embedding path preserves behavior |
| In coherent behavior under observations | Coherent observations / Ran/Yoneda-style | overlapping observations commute |
| Behind a projection P | Lifted implementation / Kan-lift-style | project(realize(case)) == required(case) |
| Behind P, but canonical construction is possible | Free builder behind projection | project(free(required(case))) satisfies required behavior |
| Behind P, but construction is impossible | Obstruction report | named loss of evidence/template/constraint |
| In internal checks implied by public behavior | Residual obligations | missing obligation fails projection |
| In generated payloads and deferred maps | Generation path vocabulary / Coyoneda-style | lowering equals direct interpretation |
| In duplicated selectors/projections | Observation vocabulary / Yoneda-style | representation change preserves observations |
| In callbacks/functions crossing boundaries | Explicit first-order IR / defunctionalization | apply(encodedCase, x) == oldCallback(x) |
| In data needed before semantic consumption | Task-indexed context instance / Context Certificate | schema constraints, observables, provenance, freshness, and rendering laws hold |
| In heterogeneous mutable sources needing semantic publication | Verified Context Snapshot / Publication Boundary | source snapshot, mapping, constraints, provenance, and publication law hold |
| In overlapping contexts from several systems | Pushout Reconciliation / explicit overlap | overlap identities are explicit, conflicts preserved, provenance survives |
Use when the user wants to certify a boundary, audit uncertified composition, or move a codebase toward Boundary Normal Form one seam at a time.
Deliver:
Use Track E for:
Use when the main problem is whether a semantic consumer has exactly the right prepared data at exactly the right time. Semantic consumers include models, humans, policy engines, compilers, workflow schedulers, deployment controllers, planners, rankers, BI dashboards, auditors, test harnesses, approval gates, and agent runtimes.
Deliver:
q and consumer type;T_q;Obs_q;I_candidate;M_q;Use Track F for:
Do not frame this as only an inference problem. The general boundary is:
Prepared Context -> Semantic Consumer
Inference is one semantic-consumption mode.
Use this sub-practice only after a lift-shaped boundary appears:
A --?--> B
| |
F P
v v
C C
Software reading:
A: public cases, contract tests, workflows, requirements, or obligations.B: internal implementation world.C: observable behavior world.P : B -> C: projection, serializer, public API runner, trace observer, report extractor, or forgetful/observational API.F : A -> C: required public behavior.? : A -> B: implementation realizer, implementation template, or residual obligation artifact.The lift asks:
Can we find L : A -> B such that P(L(a)) satisfies F(a)?
The Freyd/AFT diagnostic asks:
Is P disciplined enough that required behavior in C has a canonical free builder Free : C -> B?
Use it to decide whether the seam needs:
P, not vague “observable behavior”;B;P;Free builder, realizer, or obligation artifact;Do not teach Freyd’s theorem in full inside ordinary responses. Translate it to this operational question:
Does this observation boundary support a canonical implementation builder, or is it too lossy/ad hoc?
P : B -> C concrete before proposing implementation changes.P, include a Freyd/AFT-style obstruction check: constraint structure, preservation, and bounded templates..universalist-plan.mdThis file is the progress record for the current run.
Create it in the project root for Track B, Track C, or Track D. Use scripts/init_universalist_plan.sh if helpful.
Minimum fields:
# Universalist Plan
## Track:
## Signal:
## Construction:
## Canonical boundary artifact:
## Worlds / boundaries inventory:
## Boundary kind:
## Boundary law:
## Freyd/AFT boundary diagnostic:
## Composition Certificate:
## Boundary Normal Form status:
## Why this construction:
## Seam / files:
## Public boundaries touched:
## Wire/storage compatibility plan:
## Verification command(s):
## Runtime-only leftovers:
## Status: planned / editing / verified / staged
## Next seam:
If context compacts, read this file first and resume from its status line.
Inspect repo reality
Find candidate signals
Start from code smells and pressure, not category labels:
Pick one seam
Choose the smallest stable seam where the stronger shape can land with low blast radius.
Good first seams:
P for a lift-shaped refactor;Choose the smallest honest construction
Default ladder:
Escalate to canonical boundary artifacts only when needed
Use the unknown-location selector and the canonical boundary artifact matrix. Escalate only when it produces:
Plan the boundary
Decide whether the seam can change in place or needs:
6a. Create the Composition Certificate
For Track D or Track E, write the certificate before broad edits:
The certificate is the reviewable unit. Do not let a categorical name substitute for the certificate.
Run the Freyd/AFT diagnostic when appropriate
For a lift-shaped Track D refactor, answer:
P : B -> C in code?P forget, observe, serialize, erase, or project?B express combined constraints, equalities, products, pullbacks, validations, or workflow composition?P preserve those constraints when observed in C?Free : C -> B, realizer, or obligation artifact is suggested?Encode idiomatically
Use the strongest encoding the repo can actually support:
runObservation;lowerGenerated;project/satisfy;observe;Verify with the fastest credible proof signal
Prefer:
Stop or name the next seam
Do not turn one structural insight into a repo-wide rewrite. Verify one seam, record it, and stop unless the user asked for a broader sweep.
.universalist-plan.mdRecord:
| Repo smell | Default construction | Nearby alternative to reject first | First seam | Proof signal |
| --- | --- | --- | --- | --- |
| status, booleans, and nullable fields describe one lifecycle | Coproduct | Product with optional fields | Decoder + core state type | exhaustive handling + invalid legacy fixture tests |
| Same input predicate repeated at controllers, services, serializers | Refined type / equalizer | Raw primitive plus helper validation | Parse / constructor boundary | accept valid, reject invalid, normalization idempotence |
| customer.accountId != subscription.accountId appears repeatedly | Pullback witness | Plain pair + scattered assertions | checked constructor | mismatch rejection + preserved projections |
| Large branch decides pricing, rendering, or policy | Exponential | Bigger state machine | function / strategy seam | fixture parity against old branch |
| Rule syntax mixed with execute / explain / log | Free construction | More conditionals inside existing class | AST + one interpreter | interpreter consistency + differential tests |
| Several fields always travel together and are consumed independently | Product | Coproduct | record / struct / object | constructor and projection consistency |
| Several old views must agree on new internals | Coherent observations | Independent adapters | read-model/projection boundary | overlapping observation coherence |
| Generated artifacts lose provenance | Generation path vocabulary | anonymous callbacks | generation/lowering boundary | lowering equals direct interpretation |
| Public contract determines implementation | Lifted implementation | ad hoc service design | one contract case | projection matches required behavior |
| Public contract determines implementation but projection loses evidence | Free builder or obstruction report | pretending a lift exists | one projection function | project(free(required)) passes or obstruction named |
| Public policy implies internal checks | Residual obligations | ad hoc validators | one policy case | missing obligation fails projection |
| Callbacks carry architecture behavior | Explicit IR | hidden closure registry | plugin/handler seam | apply/interpreter equivalence |
| Stateful behavior is duplicated across handlers | Behavioral coalgebra | scattered mutation branches | one transition + observer | trace law and invalid transition rejection |
| Operation syntax needs multiple runtimes | Effect signature + handlers | callbacks embedded in workflow | one operation + test handler | handler observation parity |
For any non-trivial response, produce these headings in order:
For Track D, also include:
For Track E, also include:
For lift-shaped Track D or Track E, also include:
P : B -> CP is vague, lossy, or intended to support a free builderFor behavioral Track D, also include:
For effect-handler Track D, also include:
For Track F, also include:
T_qObs_qFor Track B, Track C, Track D, or Track F, also update .universalist-plan.md.
kan only after universalist has identified the signal, seam, worlds, boundary kind, candidate artifact, witness slice, and proof signal; then use kan for detailed Kan extension/lift, Freyd/AFT, Yoneda/Coyoneda, codensity, or defunctionalization mechanics.kan until universalist has identified the signal, seam, candidate artifact, witness slice, and proof signal.invariant-ace when the main job is discovering or pinning down invariants before choosing structure.accretive-implementer after the construction is chosen and the task becomes ordinary implementation.repeatedly-apply-skill when sweeping the repo for multiple seams or doing a multi-pass campaign.Core references:
references/universalist-overview.mdreferences/discovery-signals.mdreferences/language-encoding-matrix.mdreferences/framework-boundaries.mdreferences/cost-model-and-false-positives.mdreferences/structures-and-laws.mdreferences/testing-playbook.mdreferences/migration-playbooks.mdreferences/case-studies.mdreferences/sources.mdUniversal architecture references:
references/universal-architecture-kernel.mdreferences/universal-architecture-ecosystem.mdreferences/artifact-selection-by-unknown-location.mdreferences/canonical-boundary-artifacts.mdreferences/kan-boundaries-for-universalist.mdreferences/freyd-aft-boundary-diagnostic.mdreferences/effects-and-coalgebras.mdreferences/yoneda-coyoneda-defunctionalization.mdreferences/universal-architecture-law-tests.mdreferences/universal-composition-doctrine.mdreferences/composition-certificates.mdreferences/boundary-normal-form.md references/presentation-strategies.md references/dense-dual-presentation.md references/semantic-compression.mdscripts/init_universalist_plan.shscripts/detect_signals.pyscripts/emit_scaffold.pyscripts/emit_boundary_adapter.pyscripts/emit_verification_plan.pyscripts/emit_law_test_stub.shscripts/emit_universal_artifact_matrix.shscripts/emit_canonical_artifact_plan.shscripts/emit_universal_architecture_prompt.shscripts/emit_freyd_boundary_diagnostic.shscripts/emit_composition_certificate.shscripts/emit_boundary_normal_form_plan.sh scripts/emit_presentation_diagnostic.shscripts/emit_context_certificate.shscripts/emit_context_compiler_plan.shscripts/emit_exact_context_prompt.shscripts/check_universalist.shtemplates/universalist-plan.mdtemplates/universalist-report.mdtemplates/universal-architecture-report.mdtemplates/freyd-boundary-diagnostic.mdtemplates/composition-certificate.mdtemplates/boundary-normal-form-report.mdtools
Convert markdown plans into beads with dependencies using br CLI. Use when creating task graphs, polishing beads before implementation, or bridging planning to agent swarm execution.
development
Orchestrate Codex skill optimization during active sessions through $cas goal control, $shadow single-session evidence, $tune diagnosis/refinement briefs, and the skill-optimizer custom subagent. Trigger for $opt, skill optimization loops, session-driven skill tuning, meta-skill audits, or explicit validated skill edits. Do not use for general code optimization, product optimization, or performance tuning.
development
Run a targeted fresh-eyes blunder pass over code, specs, plans, adjudications, closure gates, skill edits, or negative-evidence ledgers. Trigger when asked to reread with fresh eyes, find obvious bugs, catch mistakes/oversights/omissions, check for embarrassing misses, or perform a second independent blunder pass before closure. Do not use as a substitute for implementation, adjudication, or verification; use it as the final falsification/check pass for those workflows.
development
Explicitly shadow, tail, watch, follow, monitor, supervise, or companion exactly one Codex session id/path through `$seq`, then apply a named target skill as an interpretation/reporting/proposal/action lens until the watched session stops.