| name | manage-state |
| description | Creates, reads, and updates the per-workflow agent state file at .github/state/<TICKET-KEY>.md — a fast-access local mirror of workflow context that reduces GitHub API round-trips and enables richer resumption. Use when creating a new workflow, at phase transitions, or when resuming. |
| argument-hint | operation and ticket key (e.g., create KAN-12, update KAN-12) |
Manage State
Creates, reads, and updates the per-workflow agent state file at .github/state/<TICKET-KEY>.md. The state file is the single source of truth for workflow context — the PR body is a rendered view produced from it at phase boundaries.
Schema reference: Block definitions and mutability rules are in .github/state/SCHEMA.md. The template is .github/state/workflow-state.tpl.md.
Content Depth Principle
The state file is the agent's working memory and the authoritative record of workflow context. The PR body is human-facing and deliberately summarized — it is rendered from state, not maintained in parallel. Write each block with enough detail that an agent resuming work in a new session can fully reconstruct context and continue from the current step without re-reading the JIRA ticket, re-running research, re-exploring the codebase, or re-deriving decisions.
Per-Block Depth Guide
| Block | Depth | What to include | What to omit |
|---|
| UNDERSTANDING | Full reproduction of ticket requirements in the agent's own words | Every requirement and acceptance criterion from the ticket; edge cases and ambiguities identified during codebase exploration; key file paths and patterns discovered; existing conventions relevant to the task; build/test/lint commands confirmed | Verbatim copy-paste of the entire JIRA description (summarize in your own words instead) |
| RESEARCH | Full findings with rationale | Each option evaluated and why it was accepted or rejected; library versions, API patterns, algorithm trade-offs; links to docs or references consulted; final recommendation with explicit reasoning | Raw web-page dumps or full API reference pages |
| PLAN | Mirror the PR body task list, plus implementation notes per task | Task table with status; for each task: which files to create/modify, what pattern to follow, what tests to add, any gotchas discovered during planning; test strategy with exact commands; risk details with concrete mitigation steps | Vague tasks like "implement feature" — be specific enough that the task could be done without re-reading the ticket |
| IMPLEMENTATION | Running log of what was done and why | Every file created or modified (with brief note on what changed); every test added (with what it covers); any decisions made during implementation that deviated from the plan; command outputs if relevant (e.g., test results) | Full file contents or large diffs (reference the file path instead) |
| REVIEW | Structured findings and their resolution status | Risk level; each finding with severity, description, and resolution; what was fixed vs. deferred vs. accepted | Full code snippets from the review (summarize the issue and point to the file/line) |
Rule of Thumb
After writing a block, ask: "If I lost my entire conversation history and only had this state file, could I continue from the current phase without re-doing any prior phase's work?" If the answer is no, add more detail.
When to Use
- Create: After creating the branch and before creating the draft PR — state file is created first, then
create-pull-request renders the initial PR body from it
- Read: At workflow resume to restore context via the
resume-workflow skill
- Update (phase transition): At each phase transition; then invoke
update-pull-request to re-render the PR body from the updated state
- Update (task progress): After completing each task in Implement phase to keep PLAN block current
Procedure
Create a New State File
-
Copy the template:
cp .github/state/workflow-state.tpl.md .github/state/<TICKET-KEY>.md
-
Populate each block per the Per-Block Depth Guide above. The data source for each block at creation:
- META: workflow type, ticket key/URL, branch, timestamps (PR number/URL populated after
create-pull-request returns)
- PHASE:
Implementing
- UNDERSTANDING: jira-reader output + codebase exploration
- RESEARCH: researcher output (leave empty if not invoked)
- PLAN: planner-lite output + per-task implementation notes
- PHASE_LOG: first row — "Branch created, state file initialized, entering implementation"
-
Write the populated content using single-quoted Python (never heredocs):
python3 -c 'content = open(".github/state/workflow-state.tpl.md").read(); # ... populate content ...; open(".github/state/<TICKET-KEY>.md","w").write(content)'
-
Commit the state file alongside any other Phase 2 work:
python3 ./.github/skills/git-operations/scripts/git_helper.py commit "chore(state): initialize workflow state [<TICKET-KEY>]"
Read / Parse State File
cat .github/state/<TICKET-KEY>.md
Parse STATE_BLOCK:*:BEGIN/END boundary markers to extract specific sections:
- UNDERSTANDING block → requirements, discovered file paths, conventions, build commands (primary context for resuming Phase 1 work)
- RESEARCH block → options evaluated, recommendation, references (prevents re-running research)
- META block → ticket, branch, PR number for API calls
- PHASE block → current phase for routing
- PLAN block → task table with statuses for progress assessment
- PHASE_LOG block → audit trail for context
If the state file does not exist (older workflow or first resume), fall back to fetching the PR body:
python3 ./.github/skills/create-pull-request/scripts/pr_helper.py fetch-body --pr-number <PR_NUMBER>
Update — Phase Transition
At each phase transition:
-
Update the PHASE block: replace the phase value
-
Update the META block: advance Updated At to current UTC timestamp
-
Update phase-specific MUTABLE blocks per the Per-Block Depth Guide:
- Entering
Reviewing: populate IMPLEMENTATION block
- Entering
Submitting: populate REVIEW block
- Entering
Ready: ensure all MUTABLE blocks are complete and consistent
-
Append a row to the PHASE_LOG block — do not append if the last row already has the same Phase value
-
Commit the updated state file:
git add .github/state/<TICKET-KEY>.md
-
Then invoke update-pull-request to re-render the PR body from the updated state. The PR body reflects state; state is never derived from the PR body.
Update — Task Progress
During Phase 3/4, after completing each task:
- In the PLAN block, update the task's
Status column: pending → in-progress → done
- Update the IMPLEMENTATION block per the depth guide (files modified, tests added, any plan deviations)
- Stage the state file:
git add .github/state/<TICKET-KEY>.md
Archive at Completion
When the pr-author finalizes the PR (moves to Ready), move the state file to the archive folder per the rules in .github/state/SCHEMA.md:
mkdir -p .github/state/archive
git mv .github/state/<TICKET-KEY>.md .github/state/archive/<TICKET-KEY>.md
Include this git mv in the finalization commit alongside the artifact registry update. If the PR is abandoned instead, delete the file with git rm rather than archiving it.
Important
- The state file lives in the working tree and must be committed to git — it is not a temp file
- Never store secrets or credentials in the state file
- If
STATE_BLOCK boundary markers are missing or malformed, stop and report — do not proceed
- The state file is the source of truth. The PR body is always derived from it — never the reverse