SkilVaultSign inStart free

Catalogue / explicit-problem-modeling

explicit-problem-modeling

Older skill: source not recordedSignedBuilds a written problem model covering data shapes, state, operations with preconditions and effects, invariants, and open questions, then freezes that model as a fixed agreement before any implementation code is written. Use when the user asks to model or specify before coding, or when a task invo…
---
name: explicit-problem-modeling
description: >
  Builds a written problem model covering data shapes, state, operations
  with preconditions and effects, invariants, and open questions, then
  freezes that model as a fixed agreement before any implementation code
  is written. Use when the user asks to model or specify before coding,
  or when a task involves state machines, business rules, constraint
  systems, or multi-step logic where correctness matters. Not for quick
  one-file scripts, simple text edits, or exploratory work with no rules
  to enforce.
---

Explicit Problem Modeling

Most wrong answers on rule-heavy coding tasks are not failures of logic — they are failures of the picture underneath the logic. When the entities, state, allowed operations, and invariants live only in your head, they drift as a task grows longer: constraints get dropped, invented behavior sneaks in, and every step looks fine while the whole quietly contradicts the request. This skill forces that picture out into the open first and then treats it as fixed.

Split all work into two stages:

  • Stage M — model. Describe the problem completely. No code, no solution steps.
  • Stage B — build. Plan, code, and test using nothing beyond what Stage M defined.

Stage B is never allowed to invent what Stage M should have said.

When to use it

Reach for this method when the task involves state machines with legal and illegal transitions, business rules that must never be violated, data transforms with strict input and output contracts, or any multi-step workflow where later steps depend on earlier state. It earns its keep where bugs are expensive.

Skip it for trivial single-function changes, formatting work, or open-ended exploration with no rules to enforce — the modeling overhead buys nothing there. Also expect longer outputs: that extra length is the price of checkability.

Ground rules

  1. Stage M produces description only — no implementation, not even sketchy solution steps.
  2. Stage B may not introduce a new entity, state variable, operation, or rule.
  3. Never guess at missing information. Put it on the open-questions list and stop to ask.
  4. Never fabricate an API, library, or method signature that was not supplied. Either raise it as an open question or write a placeholder that is unmistakably labeled as a stub.

The original methodology ships a JSON template and a validation script beside the skill; this single-file version folds both into the schema and checklist below.

Stage M — draft the model

Write it as JSON or a tightly indented outline; the format matters less than the result being explicit, inspectable, and stable. Cover every section:

| Section | What goes in it | Why it exists | |---|---|---| | build_target | One-line description plus the files you intend to create | Bounds the scope of the work | | data_shapes | The nouns: each entity and its fields | Stops Stage B from inventing types | | state | Variables that change, with initial values | Makes state tracking explicit instead of latent | | operations | Each action with parameters, preconditions, and effects | Defines the only moves you may make | | rules | Numbered invariants with a statement and a kind (always / before / after) | Carries the constraints that must never break | | starting_point | Conditions at the beginning | Removes ambiguity about initial state | | done_when | Acceptance criteria | Tells you when you are finished | | assumed | Things you are taking as given | Makes silent assumptions visible and challengeable | | open_questions | Anything unanswered | The stop condition for this stage | | requirement_map | Each requirement, quoted verbatim, pointing at its rule, operation, or done_when item | Proves nothing from the request was dropped | | checks | For each rule, how to demonstrate it holds or breaks | Forces testability now rather than later |

If open_questions is not empty, Stage M is where you stop. Present the model and the questions, then wait — do not start building.

Worked example. The user asks for a room reservation module where rooms cannot be double-booked, each team is capped at three hours of bookings per day, and all bookings must sit on half-hour boundaries:

{
  "build_target": {
    "summary": "In-memory reservation registry for three meeting rooms",
    "files": ["src/rooms/registry.ts", "src/rooms/registry.test.ts"]
  },
  "data_shapes": [
    { "name": "Reservation", "fields": ["room", "team", "startMinute", "endMinute"] }
  ],
  "state": [
    { "name": "reservations", "kind": "Reservation list", "initial": "empty", "notes": "kept sorted by startMinute" }
  ],
  "operations": [
    {
      "name": "reserve",
      "parameters": ["room", "team", "startMinute", "endMinute"],
      "requires": [
        "room is one of Aurora, Borealis, Corona",
        "requested window is free",
        "team's daily total stays at or under 180 minutes",
        "startMinute and endMinute are multiples of 30"
      ],
      "produces": ["reservation appended to the list"]
    },
    {
      "name": "release",
      "parameters": ["room", "team", "startMinute"],
      "requires": ["a matching reservation exists"],
      "produces": ["reservation removed from the list"]
    }
  ],
  "rules": [
    { "id": "R1", "statement": "no two reservations for the same room overlap in time", "kind": "always" },
    { "id": "R2", "statement": "a team's bookings total at most 180 minutes per day", "kind": "always" },
    { "id": "R3", "statement": "all reservation times fall on 30-minute boundaries", "kind": "always" }
  ],
  "starting_point": [
    "no reservations exist; rooms are Aurora, Borealis, Corona; room capacity was not requested"
  ],
  "done_when": [
    "reserve accepts and rejects exactly as R1 through R3 require",
    "release frees a slot so it can be rebooked"
  ],
  "assumed": ["times are minute offsets from midnight, single timezone, single day"],
  "open_questions": [],
  "requirement_map": [
    { "quoted": "rooms cannot be double-booked", "represented_as": "rule", "ref": "R1" },
    { "quoted": "each team is capped at three hours of bookings per day", "represented_as": "rule", "ref": "R2" },
    { "quoted": "bookings must sit on half-hour boundaries", "represented_as": "rule", "ref": "R3" }
  ],
  "checks": [
    { "id": "K1", "covers": ["R1"], "how": "reserve Aurora 9:00 to 10:00, then attempt Aurora 9:30 to 10:30; the second call must fail" },
    { "id": "K2", "covers": ["R2"], "how": "give Team Cedar 150 minutes, then attempt 60 more; must fail" },
    { "id": "K3", "covers": ["R3"], "how": "attempt a reservation starting at 9:15; must fail" }
  ]
}

Audit before freezing

Before the model earns its fixed status, put it through four questions plus a structural pass.

| Check | The question | What failure looks like | |---|---|---| | Coverage | Does every sentence of the request have exactly one home — a rule, a done_when item, or a precondition or effect? | A requirement missing from requirement_map, or two entries that disagree | | Operability | Can the entire job be assembled from the listed operations alone? | Your plan needs a lookup or validation step that no operation provides | | Consistency | Can any operation's effects break an always-rule, or do two rules conflict? | An effect that violates an invariant, or two rules that cannot both hold | | Testability | Does every rule have at least one check that would catch its violation? | A rule with no covering check |

Structural pass, done by hand: every section above is present; every operation lists its preconditions and effects; every rule has an id and a statement; every requirement_map entry points at a real rule, operation, or done_when item; every check names at least one rule; every quoted requirement matches the user's words exactly.

Outcomes:

  • All checks pass and open_questions is empty — declare the model frozen and move to Stage B.
  • Any check fails — revise the model and repeat the audit. You are still in Stage M, so write no code.
  • open_questions is not empty — stop and ask.

Freeze and amend

Once past the audit, the model is fixed for the rest of the task. If the build later exposes a genuine gap — say, nothing defines what happens when a room is retired mid-day — do not work around it silently in code. Instead:

  1. Append a minimal, labeled amendment to the model stating what changed and why, in one or two lines.
  2. Restart the build plan from the amended model.

The amendment log doubles as a record of where the original request was underspecified.

Stage B — plan, build, prove

Plan

Write numbered steps, each one an instance of a modeled operation. For each step, record which operation runs, which preconditions hold at that point, which state changes, and which rules the step must respect. Step-by-step reasoning is welcome here, but only in model vocabulary: the moment you catch yourself reasoning about a noun or verb the model never defined, treat it as a gap and take the amend path above.

Build

Translate model pieces into code:

| Model piece | Code counterpart | |---|---| | data_shapes and state | Types, interfaces, schemas | | operations | Functions that validate their preconditions and fail with an explicit error rather than silently proceeding | | rules | Runtime guards, argument validation, invariant assertions at system boundaries |

The stub rule from the ground rules bites hardest here: if you need an interface that was never provided — a persistence layer, an external clock — either add an open question and stop, or write a placeholder marked with a clearly visible stub comment describing the real dependency that belongs there.

Prove

Implement every item from checks so that each rule is covered by at least one test. Then close with a verification map: for each rule, the file and line where it is enforced, and the test that would catch its violation. If any rule has no enforcement point or no test, the build is not done.

Limits of this method

  • It does not write any implementation before the model passes its audit.
  • It does not let the build phase add concepts the model never defined — amend first, then rebuild.
  • It does not invent libraries, APIs, or method signatures that were never supplied.
  • It does not treat a passing audit as proof of correctness; it lowers the odds of constraint drift and hidden assumptions, it does not eliminate them.