agentleFS
EmeaAppGbbEmeaAppGbb/spec2cloud/.github/skills/state-management/SKILL.md

state-management

Skill100 starsChanged 7 months agoMITView on GitHub

Read, write, and maintain .spec2cloud/state.json across phases and increments. Defines the state schema, read/write protocol, and resume re-validation logic. Use when reading project state, updating state after task completion, or resuming from a previous session.

We split this skill into the rules it gives an agent

9 rules. 0 are common, 4 are distinctive, and 5 are very specific to this project.

  • 0

    Common

    Most of the 20 edited versions we read keep these.

  • 4

    Distinctive

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    If in increment-delivery, parse currentIncrement and its steps to determine what's been done and what's next

    line 15
  2. Distinctive:

    Update the relevant section with the result of the task you just executed

    line 21
  3. Very specific:

    Update lastUpdated to the current ISO timestamp

    line 22
  4. Very specific:

    Write the updated state back to .spec2cloud/state.json

    line 23
  5. Distinctive:

    When operating in brownfield mode, the state includes additional fields for testability tracking and per-feature track assignment.

    line 56
  6. Very specific:

    When track is "hybrid", each increment in Phase 2 inherits its track from featureTracks.

    line 79
  7. Distinctive:

    If results match state → continue from where you left off

    line 89
  8. Distinctive:

    If results differ → update state to reflect reality, then continue

    line 90
  9. Very specific:

    BLOCKING: If state.json is invalid or inconsistent with actual artifacts, the resume skill will reconstruct the wrong position.

    line 103

“Common” is measured: kept by at least 6 in 10 of the 20 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

State Management

State lives in .spec2cloud/state.json. You read it at the start of every loop iteration and write it at the end.

Reading State

At the start of every loop iteration:

  1. Read .spec2cloud/state.json
  2. Parse currentPhase to determine where you are (setup, discovery, or increment-delivery)
  3. If in increment-delivery, parse currentIncrement and its steps to determine what's been done and what's next
  4. Parse humanGates to check which approvals have been granted

Writing State

At the end of every loop iteration:

  1. Update the relevant section with the result of the task you just executed
  2. Update lastUpdated to the current ISO timestamp
  3. Write the updated state back to .spec2cloud/state.json

State File Schema

See references/schema.md for the full JSON schema example and field descriptions.

Increment Object Fields

FieldTypeDescription
status"pending" | "in-progress" | "done"Overall increment delivery status. "done" only when Step 4 (Verify & Ship) completes.
stepsobjectPer-step status tracking: tests, contracts, implementation, verification.

Step Object Fields

StepKey FieldsDescription
testse2eSpecs, gherkinFiles, cucumberSteps, vitestFilesFiles generated for this increment's test scaffolding.
contractsapiContracts, sharedTypes, infraUpdatedContract artifacts for this increment.
implementationslices (api, web, integration)Per-slice tracking with modifiedFiles, failingTests, lastTestRun, iteration.
verificationregression, deployment, smokeTests, docsFull regression results, deployment URL, smoke test results, docs status.

Slice Dependencies (within implementation)

Contracts → api  (api slice reads contract types)
Contracts → web  (web slice reads contract types)
api + web → integration  (integration requires both slices done)
integration → verification  (verify requires all slices green)

Brownfield State Fields

When operating in brownfield mode, the state includes additional fields for testability tracking and per-feature track assignment.

FieldTypeDescription
brownfield.testability"full" | "partial" | "none"Overall testability verdict after the testability gate.
brownfield.track"A" | "B" | "hybrid"Delivery track: A (testable, green baseline), B (doc-only), or hybrid (mix per feature).
brownfield.testabilityChecklistobjectSix binary checks: canBuild, externalDepsReachable, apiExercisable, uiRenderable, devEnvExists, existingTestsRunnable.
brownfield.featureTracksobjectMap of featureId → "A" | "B". Only present when track is "hybrid".
brownfield.greenBaselineobjectTrack A metrics: per-feature scenarios count, testsPass boolean, lastVerified ISO timestamp.
brownfield.behavioralDocsobjectTrack B metrics: per-feature scenarios count and manualChecklist item count.

Brownfield State Transitions

TriggerPhaseState Updates
Extraction complete"B1"currentPhase: "B1", extraction output paths recorded in brownfield.extraction
Spec-Enable complete"B2"currentPhase: "B2", brownfield.prdGenerated: true, brownfield.frdCount: N
Testability gate complete"B3"currentPhase: "B3", brownfield.testability, brownfield.track, brownfield.testabilityChecklist recorded
Track A baseline green(still B3)brownfield.greenBaseline.features populated with per-feature test results
Track B docs complete(still B3)brownfield.behavioralDocs.features populated with per-feature scenario/checklist counts
Path selection (human gate)"assessment"brownfield.selectedPaths array recorded (e.g., ["modernize", "security"])
Assessment + planning done"increment-delivery"Increments generated, incrementPlan populated, delivery proceeds track-aware

When track is "hybrid", each increment in Phase 2 inherits its track from featureTracks. Track A increments follow the full test → contract → implement → verify cycle. Track B increments follow a doc-only path (behavioral docs + manual checklists instead of automated green baselines).

On Resume

  1. Read .spec2cloud/state.json
  2. Determine current increment and current step within it
  3. Re-validate by running the appropriate test suite:
    • Tests step: verify test files exist and compile
    • Implementation step: run tests for the current slice, compare to state
    • Verification step: check deployment status
  4. If results match state → continue from where you left off
  5. If results differ → update state to reflect reality, then continue

Mandatory Completion Checklist

The orchestrator MUST verify ALL of the following after every state write:

  • .spec2cloud/state.json is valid JSON (parseable without errors)
  • currentPhase reflects the actual phase the orchestrator is in
  • currentIncrement and increment step match the work just completed
  • lastUpdated timestamp is current
  • No fields are null/undefined that downstream skills depend on (e.g., adrs.nextNumber, incrementPlan)
  • State file is committed alongside the artifacts it describes (not orphaned)

BLOCKING: If state.json is invalid or inconsistent with actual artifacts, the resume skill will reconstruct the wrong position. Fix state before proceeding.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.