Task Closeout
Goal
Create a temporary handoff packet for later learning extraction.
Follow Skill initialization and Procedure below. Required filenames, summary.json expectations (including openspec_change), and write scope are in CONTRACT.md.
Skill initialization (before first closeout)
Run this once per target repo after the skill files are present under .agents/skills/task-closeout/ (for example after copying only that skill folder or after an npx/package install drops it there). Idempotent: safe to repeat.
Resolve the repo root (the directory that contains .git/ in normal layouts).
Ensure .agents/sessions/ exists.
If .agents/sessions/README.md is missing, create it from bootstrap/sessions/README.md in this skill folder.
Ensure .agents/.gitignore exists. If it is missing, create it with exactly:
sessions/*
!sessions/README.md
If .agents/.gitignore already exists, merge these two lines if they are absent; do not remove unrelated ignore rules.
If the repo does not track .agents/.gitignore and the user relies on the repo root .gitignore, ensure equivalent patterns exist there: .agents/sessions/* and !.agents/sessions/README.md.
Do not create durable knowledge files (AGENTS.md, docs/, playbooks/) as part of this skill; those are owned by learning-distill initialization or a full kit merge.
Output location
Write inside the repo to .agents/sessions/<session-folder>/.
The session folder name is a sortable storage label. The canonical task/session identifier is the task_id field inside the bundle's summary.json.
Required outputs
- summary.json
- active-task.md
- learning-candidate.md
- changed-files.txt
- validation.txt
Example bundle
Filled-in reference files live under .agents/skills/task-closeout/example/task-bundle/ when this skill is installed under .agents/skills/task-closeout/.
Rules
- Record only observable facts in active-task.md.
- Record only candidate lessons in learning-candidate.md.
- Distinguish clearly between what failed, what worked, and what is only a hypothesis.
- Do not update
.agents/AGENTS.md or any other durable repo knowledge file.
- Record the associated OpenSpec change, if any, in
summary.json under openspec_change (the change name from openspec/changes/<name>/). Omit the field when the session touched no OpenSpec change.
- Never modify anything under
openspec/ during closeout of an in-flight change; spec updates happen at /opsx:archive time, not closeout time.
- Do not edit files under
.agents/skills/ during closeout. Capture proposed skill or MAINTENANCE.md edits as text in the bundle; learning-distill applies kit-wide skill changes.
- Treat the whole maintainer conversation as in-scope for
active-task.md and learning-candidate.md unless the user explicitly limits closeout to one subtask (mistakes, reversals, and corrections—not only the last git diff).
- Do not write narrative summaries longer than necessary.
- Prefer concise bullet lists.
Procedure
- Determine or create
repo_id.
- Determine or create
task_id.
- Create a session folder using the pattern
YYYYMMDD-HHMMSS-short-topic.
- Keep one task-closeout bundle per session folder.
- Collect changed files.
- Collect commands run and validation results.
- Re-read the full session (or transcript) before drafting bundle prose so notes and lessons are not scoped to the final edit only.
- Write active-task.md.
- Write learning-candidate.md.
- Write summary.json with status, metadata,
repo_id, task_id, openspec_change (when applicable), and optional agent identifiers when available.
- Mark the session bundle ready for distillation.
Optional agent metadata
Record agent provenance whenever the active tool can supply it. Record session provenance whenever the active tool can supply a stable session identifier.
- In
summary.json, add agent when the active agent/tool identity is known.
- In
summary.json, add agent_session_id when the active agent/tool exposes a stable session ID.
- In
active-task.md, add an Agent section when the agent/tool identity is known.
- In
active-task.md, add an Agent Session ID section when the active agent/tool exposes a stable session ID.
- Treat
agent and agent_session_id independently: record either one when available; omit only the specific field/section that is unavailable.
- Do not invent session IDs or require manual lookup outside the agent/tool's supported session history.
Session folder naming
- Use a deterministic, sortable folder name such as
YYYYMMDD-HHMMSS-short-topic.
- Keep the slug short, lowercase, and tied to the task goal.
- Reuse the same session folder only for the single task-closeout bundle it was created for.
- Do not treat the folder name as the canonical task identity; use the
task_id field in summary.json.
active-task.md sections
- Task ID
- Agent (optional)
- Agent Session ID (optional)
- Goal
- Outcome
- Files Changed
- Commands Run
- Validation
- Remaining Work
- Notes
learning-candidate.md sections
- Task
- What failed
- What worked
- Reusable pattern
- Candidate AGENTS update
- Candidate troubleshooting note
- Candidate repo decision
- Candidate playbook
- Spec updates deferred to archive time (change name + what to fold in)
- Confidence
1---2name: task-closeout3description: Capture the current task into a structured temporary session bundle under `.agents/sessions/` so a learning agent can later distill durable repo knowledge. Use for completed, blocked, or abandoned tasks with meaningful changes, debugging, validation, or reusable lessons.4---56# Task Closeout78## Goal910Create a temporary handoff packet for later learning extraction.1112Follow **Skill initialization** and **Procedure** below. Required filenames, `summary.json` expectations (including `openspec_change`), and write scope are in [`CONTRACT.md`](CONTRACT.md).1314## Skill initialization (before first closeout)1516Run this once per target repo after the skill files are present under `.agents/skills/task-closeout/` (for example after copying only that skill folder or after an `npx`/package install drops it there). Idempotent: safe to repeat.17181. Resolve the repo root (the directory that contains `.git/` in normal layouts).19202. Ensure `.agents/sessions/` exists.21223. If `.agents/sessions/README.md` is missing, create it from `bootstrap/sessions/README.md` in this skill folder.23244. Ensure `.agents/.gitignore` exists. If it is missing, create it with exactly:2526 ```gitignore27 sessions/*28 !sessions/README.md29 ```3031 If `.agents/.gitignore` already exists, merge these two lines if they are absent; do not remove unrelated ignore rules.32335. If the repo does not track `.agents/.gitignore` and the user relies on the repo root `.gitignore`, ensure equivalent patterns exist there: `.agents/sessions/*` and `!.agents/sessions/README.md`.3435Do not create durable knowledge files (`AGENTS.md`, `docs/`, `playbooks/`) as part of this skill; those are owned by `learning-distill` initialization or a full kit merge.3637## Output location3839Write inside the repo to `.agents/sessions/<session-folder>/`.4041The session folder name is a sortable storage label. The canonical task/session identifier is the `task_id` field inside the bundle's `summary.json`.4243## Required outputs4445- summary.json46- active-task.md47- learning-candidate.md48- changed-files.txt49- validation.txt5051## Example bundle5253Filled-in reference files live under `.agents/skills/task-closeout/example/task-bundle/` when this skill is installed under `.agents/skills/task-closeout/`.5455## Rules5657- Record only observable facts in active-task.md.58- Record only candidate lessons in learning-candidate.md.59- Distinguish clearly between what failed, what worked, and what is only a hypothesis.60- Do not update `.agents/AGENTS.md` or any other durable repo knowledge file.61- Record the associated OpenSpec change, if any, in `summary.json` under `openspec_change` (the change name from `openspec/changes/<name>/`). Omit the field when the session touched no OpenSpec change.62- Never modify anything under `openspec/` during closeout of an in-flight change; spec updates happen at `/opsx:archive` time, not closeout time.63- Do not edit files under `.agents/skills/` during closeout. Capture proposed skill or `MAINTENANCE.md` edits as text in the bundle; **learning-distill** applies kit-wide skill changes.64- Treat the **whole maintainer conversation** as in-scope for `active-task.md` and `learning-candidate.md` unless the user explicitly limits closeout to one subtask (mistakes, reversals, and corrections—not only the last `git diff`).65- Do not write narrative summaries longer than necessary.66- Prefer concise bullet lists.6768## Procedure69701. Determine or create `repo_id`.712. Determine or create `task_id`.723. Create a session folder using the pattern `YYYYMMDD-HHMMSS-short-topic`.734. Keep one task-closeout bundle per session folder.745. Collect changed files.756. Collect commands run and validation results.767. Re-read the full session (or transcript) before drafting bundle prose so notes and lessons are not scoped to the final edit only.778. Write active-task.md.789. Write learning-candidate.md.7910. Write summary.json with status, metadata, `repo_id`, `task_id`, `openspec_change` (when applicable), and optional agent identifiers when available.8011. Mark the session bundle ready for distillation.8182## Optional agent metadata8384Record agent provenance whenever the active tool can supply it. Record session provenance whenever the active tool can supply a stable session identifier.8586- In `summary.json`, add `agent` when the active agent/tool identity is known.87- In `summary.json`, add `agent_session_id` when the active agent/tool exposes a stable session ID.88- In `active-task.md`, add an Agent section when the agent/tool identity is known.89- In `active-task.md`, add an Agent Session ID section when the active agent/tool exposes a stable session ID.90- Treat `agent` and `agent_session_id` independently: record either one when available; omit only the specific field/section that is unavailable.91- Do not invent session IDs or require manual lookup outside the agent/tool's supported session history.9293## Session folder naming9495- Use a deterministic, sortable folder name such as `YYYYMMDD-HHMMSS-short-topic`.96- Keep the slug short, lowercase, and tied to the task goal.97- Reuse the same session folder only for the single task-closeout bundle it was created for.98- Do not treat the folder name as the canonical task identity; use the `task_id` field in `summary.json`.99100## active-task.md sections101102- Task ID103- Agent (optional)104- Agent Session ID (optional)105- Goal106- Outcome107- Files Changed108- Commands Run109- Validation110- Remaining Work111- Notes112113## learning-candidate.md sections114115- Task116- What failed117- What worked118- Reusable pattern119- Candidate AGENTS update120- Candidate troubleshooting note121- Candidate repo decision122- Candidate playbook123- Spec updates deferred to archive time (change name + what to fold in)124- Confidence