state-manager
Manage workflow state in .agents/tmp/state.json with atomic writes
What this skill does
# State Manager
Manage subagents workflow state with file-based persistence.
## State Location
`.agents/tmp/state.json` - All workflow state persisted here.
## State Schema (v2)
```json
{
"version": 2,
"task": "<task description>",
"status": "pending|in_progress|stopped|completed|failed|blocked|restarting|skipped",
"currentStage": "EXPLORE|PLAN|IMPLEMENT|TEST|FINAL",
"currentPhase": "0|1.1|1.2|1.3|2.1|2.2|2.3|3.1|3.2|3.3|3.4|3.5|4.1|4.2|4.3",
"pipelineProfile": "minimal|standard|thorough",
"codexAvailable": true,
"ownerPpid": "<session PID for scoping>",
"worktree": {
"path": "/absolute/path/to/repo--subagent",
"branch": "subagents/task-slug",
"createdAt": "<ISO timestamp>"
},
"reviewer": "subagents:codex-reviewer|subagents:claude-reviewer",
"failureAnalyzer": "subagents:codex-failure-analyzer|subagents:failure-analyzer",
"difficultyEstimator": "subagents:codex-difficulty-estimator|subagents:difficulty-estimator",
"testDeveloper": "subagents:codex-test-developer|subagents:test-developer",
"docUpdater": "subagents:codex-doc-updater|subagents:doc-updater",
"taskAnalysis": {
"complexity": "simple|medium|complex",
"needsTests": true,
"needsDocs": true,
"reasoning": "..."
},
"schedule": [
{ "phase": "0", "stage": "EXPLORE", "name": "Explore", "type": "dispatch" },
{
"phase": "1.1",
"stage": "PLAN",
"name": "Brainstorm",
"type": "subagent"
},
{ "phase": "1.2", "stage": "PLAN", "name": "Plan", "type": "dispatch" },
{
"phase": "1.3",
"stage": "PLAN",
"name": "Plan Review",
"type": "review"
},
{
"phase": "2.1",
"stage": "IMPLEMENT",
"name": "Task Execution",
"type": "dispatch"
},
{
"phase": "2.2",
"stage": "IMPLEMENT",
"name": "Simplify",
"type": "subagent"
},
{
"phase": "2.3",
"stage": "IMPLEMENT",
"name": "Implementation Review",
"type": "review"
},
{ "phase": "3.1", "stage": "TEST", "name": "Run Tests & Analyze", "type": "subagent" },
{
"phase": "3.2",
"stage": "TEST",
"name": "Analyze Failures",
"type": "subagent"
},
{
"phase": "3.3",
"stage": "TEST",
"name": "Develop Tests",
"type": "subagent"
},
{
"phase": "3.4",
"stage": "TEST",
"name": "Test Dev Review",
"type": "review"
},
{
"phase": "3.5",
"stage": "TEST",
"name": "Test Review",
"type": "review"
},
{
"phase": "4.1",
"stage": "FINAL",
"name": "Documentation",
"type": "subagent"
},
{
"phase": "4.2",
"stage": "FINAL",
"name": "Final Review",
"type": "review"
},
{
"phase": "4.3",
"stage": "FINAL",
"name": "Completion",
"type": "subagent"
}
],
"gates": {
"EXPLORE->PLAN": { "required": ["0-explore.md"], "phase": "0" },
"PLAN->IMPLEMENT": {
"required": ["1.1-brainstorm.md", "1.2-plan.md", "1.3-plan-review.json"],
"phase": "1.3"
},
"IMPLEMENT->TEST": {
"required": ["2.1-tasks.json", "2.3-impl-review.json"],
"phase": "2.3"
},
"TEST->FINAL": {
"required": ["3.1-test-results.json", "3.3-test-dev.json", "3.5-test-review.json"],
"phase": "3.5"
},
"FINAL->COMPLETE": { "required": ["4.2-final-review.json"], "phase": "4.2" }
},
"stages": {
"EXPLORE": { "status": "pending", "agentCount": 0 },
"PLAN": {
"status": "pending",
"phases": {},
"restartCount": 0,
"blockReason": null
},
"IMPLEMENT": {
"status": "pending",
"phases": {},
"restartCount": 0,
"blockReason": null
},
"TEST": {
"status": "pending",
"enabled": true,
"restartCount": 0,
"blockReason": null
},
"FINAL": { "status": "pending", "restartCount": 0, "blockReason": null }
},
"codexTimeout": {
"reviewPhases": 300000,
"finalReviewPhases": null,
"implementPhases": 1800000,
"testPhases": 600000,
"explorePhases": 600000,
"maxRetries": 2
},
"supplementaryPolicy": "on-issues",
"coverageThreshold": 90,
"webSearch": true,
"reviewPolicy": {
"minBlockSeverity": "LOW",
"maxFixAttempts": 10,
"maxStageRestarts": 3
},
"restartHistory": [],
"files": {},
"failure": null,
"compaction": { "lastCompactedAt": null, "history": [] },
"startedAt": null,
"updatedAt": null,
"stoppedAt": null
}
```
> **Note:** `taskAnalysis.complexity` uses `simple|medium|complex` for pipeline profile selection. Phase 2.1 complexity scoring uses `easy|medium|hard` for agent routing — these are separate concepts.
> **Note:** Phases 2.2 (Simplify) and 3.2 (Analyze Failures) are only included in the `thorough` pipeline profile. The `standard` profile (13 phases) omits them. The `minimal` profile further omits PLAN and TEST stages.
## Operations
### Initialize State
Create new state file with task and default values:
1. Create `.agents/tmp/` directory if not exists
2. Write initial state with `status: "in_progress"`, `startedAt: now()`
3. Return state object
### Read State
1. Check if `.agents/tmp/state.json` exists
2. Parse JSON and validate version
3. Return state object or null if not found
### Update State
1. Read current state
2. Deep merge updates
3. Set `updatedAt: now()`
4. Write to temp file first
5. Atomic rename to state.json
### Record Phase Output
1. Write output to `.agents/tmp/phases/{phase}-{name}.{ext}` using descriptive names:
- `0-explore.md`, `1.1-brainstorm.md`, `1.2-plan.md`, `1.3-plan-review.json`
- `2.1-tasks.json`, `2.3-impl-review.json`
- `3.1-test-results.json`, `3.2-analysis.md`, `3.3-test-dev.json`, `3.4-test-dev-review.json`, `3.5-test-review.json`
2. Update `state.files` with path
3. Save state
### Record Failure
1. Set `status: "failed"`
2. Set `failure` object with phase, error, context
3. Save state
### Validate Stage Gate
Before transitioning between stages, validate that the gate is satisfied:
1. Determine gate key: `{currentStage}->{nextStage}` (use `COMPLETE` for FINAL->done)
2. Look up gate in `state.gates`
3. For each file in `gate.required`:
- Check if `.agents/tmp/phases/{file}` exists
- Check if `state.files` has an entry for the corresponding phase
4. If ANY required file is missing:
- Set `status: "blocked"`
- Set `stages[currentStage].blockReason: "Gate check failed: missing {file}. Phase {gate.phase} must complete before transitioning to {nextStage}."`
- Return `{ passed: false, missing: ["{file}"] }`
5. If all required files exist:
- Return `{ passed: true }`
**Gate checks are mandatory.** The workflow MUST call this operation before every stage transition. Skipping a gate check is a protocol violation.
### Advance Phase
Move to the next phase in the schedule:
1. Read `state.schedule` to find current phase entry by `state.currentPhase`
2. Find the next entry in the array
3. If next entry's `stage` differs from current -> run "Validate Stage Gate" first
4. If gate passes (or same stage): update `currentPhase` and `currentStage`
5. If gate fails: halt and return gate failure
6. Save state
This replaces ad-hoc phase/stage advancement. The workflow calls `Advance Phase` after every phase completes instead of manually setting currentPhase.
## Failure Schema
```json
{
"failure": {
"phase": "2.1",
"error": "Task agent timeout on task-3",
"failedAt": "2026-01-29T10:15:00Z",
"context": {
"completedTasks": ["task-1", "task-2"],
"failedTask": "task-3",
"pendingTasks": ["task-4", "task-5"]
}
}
}
```
## Atomic Write Protocol
Always write to temp file first, then rename:
```
1. Write to .agents/tmp/state.json.tmp
2. Validate JSON is parseable
3. Rename to .agents/tmp/state.json
```
This prevents corrupted state if write is interrupted.
## Recovery
On load, if `.agents/tmp/statRelated in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.