dept-save-state · git:20260516.83ea212 · 2026-05-16 · sha256 88e0a60ec985935d

dept-save-state git:20260516.83ea212A

Immutable. This exact content never changes and is served at /api/v1/blob/88e0a60ec985935d.

---
name: dept-save-state
description: >
  Freezes department state at session end — writes dept-state.md, updates
  member-roster.md, flushes active-coords.md, and archives dept scratch files.
  Invoke as /dept-save-state [dept-slug] or /dept-save-state all.
  Fully autonomous, no user interaction. Parallel-safe when saving all departments.
---

# /dept-save-state

Writes all department session-end state files. Caller spawns and waits — zero work
done in the calling session.

## Department Registry

The departments and their paths (relative to `{agency-root}/agents/`):

| Slug | Abbr |
|------|------|
| career | car |
| content-creation | cc |
| design | des |
| engineering | eng |
| game-development | gd |
| marketing | mkt |
| operations | ops |
| paid-media | pm |
| product | prd |
| project-management | prj |
| sales | sal |
| spatial-computing | spa |
| specialized | spc |
| testing | tst |

Replace `{agency-root}` with `~/.claude` after installation.

## Argument Resolution

| Argument | Action |
|---|---|
| `all` | Save all departments, in parallel via subagents |
| `[dept-slug]` | Save exactly one department |
| no arg | Fail with message: "Pass a dept slug or 'all'" |

## Step 1 — Read Current State

For the target department, read:
1. `{dept-path}/state/dept-state.md` — current snapshot
2. `{dept-path}/scratch/dept-scratch.md` — active session scratch (if exists)
3. `{dept-path}/scratch/coords/` — any active DC scratch files
4. `{dept-path}/state/active-coords.md` — running coord log

## Step 2 — Write dept-state.md

Overwrite `{dept-path}/state/dept-state.md` with current state. Max 20 lines:

```
dept: {dept-slug}
lead: {lead agent name}
abbr: {abbreviation}
updated: {YYYY-MM-DD HH:MM GMT+7}
active-pipelines: {comma-separated or "none"}
active-protocols: {comma-separated or "none"}
active-coords: {comma-separated DC names with state, or "none"}
open-issues: {any unresolved issues, or "none"}
member-alerts: {capacity/skill alerts, or "none"}
last-improvement: {most recent pipeline/protocol change, or "none"}
next-focus: {what the dept head should work on next session}
blockers: {any blockers, or "none"}
```

## Step 3 — Update member-roster.md

Read `{dept-path}/state/member-roster.md`. Update utilization and active task
columns based on what was observed during the session. If no changes were made
to member assignments, leave the file unchanged.

## Step 4 — Archive Scratch Files

1. If `{dept-path}/scratch/dept-scratch.md` exists → delete it (session is over)
2. If any `{dept-path}/scratch/coords/dc-*.md` files exist for completed coords → delete them
3. Leave scratch files for IN_PROGRESS coords (they'll resume next session)

## Step 5 — Promote Lessons

If any department-level lessons were learned during the session:
1. Append to `{dept-path}/memory/lessons.md` in the standard format
2. If the lesson is cross-department, also note it in `{agency-root}/memory/lessons/` with a reference

## Step 6 — Output Confirmation

```
DEPT-SAVE-STATE: {dept-slug}
Updated: dept-state.md, member-roster.md
Archived: {n} scratch files
Lessons: {n} promoted
Next focus: {value from dept-state.md next-focus field}
```