npx claudepluginhub nickalus12/loom --plugin loomThis skill uses the workspace's default tool permissions.
---
Mandates invoking relevant skills via tools before any response in coding sessions. Covers access, priorities, and adaptations for Claude Code, Copilot CLI, Gemini CLI.
Share bugs, ideas, or general feedback.
Activate this skill for all session state operations during Loom orchestration. This skill defines the protocols for creating, updating, resuming, and archiving orchestration sessions.
When MCP state tools are available, prefer them for state operations:
initialize_workspace, create_session, update_session, transition_phase, get_session_status, archive_session) — structured I/O, atomic operations.Write/Edit directly on state files — when MCP tools are not in the available tool list.write-state.js, read-state.js) — remain available but are not the recommended path.Detection: check whether MCP state tools appear in your available tools. If they do, use them. If they do not, use Write/Edit.
Loom hooks maintain a separate, transient state directory at /tmp/loom-hooks/<session-id>/ that is distinct from orchestration state in <LOOM_STATE_DIR>:
| Concern | Orchestration State | Hook State |
|---|---|---|
| Location | <LOOM_STATE_DIR>/state/ | /tmp/loom-hooks/<session-id>/ (Unix) or <os.tmpdir()>/loom-hooks/<session-id>/ (Windows) |
| Lifecycle | Created in Phase 2, archived in Phase 4 | Directory created by hooks system (SessionStart) when an active session exists; active-agent file written by hooks system (PreToolUse) and cleared by orchestrator inline validation (no hook — see SKIP_EVENTS_CLAUDE); stale directories pruned by both hooks system (SessionStart) and hooks system (PreToolUse) |
| Contents | Session metadata, phase tracking, token usage, file manifests | Active agent tracking file (active-agent) |
| Persistence | Survives session restarts (supports /loom:resume) | Ephemeral — lost on session end or system reboot |
| Managed by | Orchestrator via session-management skill | The runtime's pre-delegation and post-delegation hooks |
The hooks system (PreToolUse) prunes stale hook state directories older than 2 hours to prevent accumulation from abnormal session terminations.
The orchestrator does not read or write hook-level state directly. It interacts only with <LOOM_STATE_DIR> paths. The two state systems are independent and serve different concerns.
For Standard workflow, create a new session when beginning Phase 2 (Team Assembly & Planning) of orchestration, after the design document has been approved. For Express workflow, create a session after the structured brief is approved (see Express Workflow section in the orchestrator template).
YYYY-MM-DD-<topic-slug>
Where:
YYYY-MM-DD is the orchestration start date<topic-slug> is a lowercase, hyphenated summary matching the design document topic<LOOM_STATE_DIR>/state/active-session.md
All state paths in this skill use <LOOM_STATE_DIR> as their base directory. In procedural steps, docs/loom represents the resolved value of this variable.
Both Read and Write work on state paths inside <LOOM_STATE_DIR>. The runtime's file-access configuration makes state paths accessible.
Use ${CLAUDE_PLUGIN_ROOT}/scripts/ for script locations so these commands work even when the extension is installed outside the workspace root.
Reading state files:
Use Read directly. The read-state.js script remains available as an alternative for TOML shell blocks that inject state before the model's first turn:
Bash: node ${CLAUDE_PLUGIN_ROOT}/scripts/read-state.js <relative-path>
Writing state files:
Use Write directly. When content must be piped from a shell command, use the atomic write script:
Bash: echo '...' | node ${CLAUDE_PLUGIN_ROOT}/scripts/write-state.js <relative-path>
Rules:
write-state.js script writes atomically (temp file + rename) to prevent partial writesLOOM_STATE_DIRdocs/loom/state/ directory if it does not exist (defense-in-depth fallback — workspace readiness startup check is the primary mechanism)active-session.md — if one exists, alert the user and offer to archive or resumetemplates/session-state.mdpendingin_progresscurrent_phase to 1---
session_id: "<YYYY-MM-DD-topic-slug>"
task: "<user's original task description>"
created: "<ISO 8601 timestamp>"
updated: "<ISO 8601 timestamp>"
status: "in_progress"
workflow_mode: "<standard|express>"
design_document: "docs/loom/plans/<design-doc-filename>"
implementation_plan: "docs/loom/plans/<impl-plan-filename>"
current_phase: 1
total_phases: <integer from impl plan>
execution_mode: null
execution_backend: null
task_complexity: null
token_usage:
total_input: 0
total_output: 0
total_cached: 0
by_agent: {}
phases:
- id: 1
name: "<phase name from impl plan>"
status: "pending"
agents: []
parallel: false
started: null
completed: null
blocked_by: []
files_created: []
files_modified: []
files_deleted: []
downstream_context:
key_interfaces_introduced: []
patterns_established: []
integration_points: []
assumptions: []
warnings: []
errors: []
retry_count: 0
---
# <Topic> Orchestration Log
Include task_complexity (from design document frontmatter) in the session state. Place after execution_backend, before token_usage. Default: null.
Update session state on every meaningful state change:
updated field on every state changepending -> in_progressin_progress -> completedin_progress -> failedfailed -> in_progress (retry)pending -> skipped (user decision only)current_phase to the ID of the currently executing phasefiles_created, files_modified, or files_deleted as subagents report changesdownstream_contexttotal_* and by_agent sectionserrors array with complete metadataerrors:
- agent: "<agent-name>"
timestamp: "<ISO 8601>"
type: "<validation|timeout|file_conflict|runtime|dependency>"
message: "<full error description>"
resolution: "<what was done to resolve, or 'pending'>"
resolved: false
retry_count on each retry attemptAfter updating YAML frontmatter, append to the Markdown body:
## Phase N: <Phase Name> <status indicator>
### <Agent Name> Output
[Summary of agent output or full content]
### Files Changed
- Created: [list]
- Modified: [list]
### Downstream Context
- Key Interfaces Introduced: [list]
- Patterns Established: [list]
- Integration Points: [list]
- Assumptions: [list]
- Warnings: [list]
### Validation Result
[Pass/Fail with details]
Status indicators:
Archive session state when:
LOOM_AUTO_ARCHIVE is true (default)LOOM_AUTO_ARCHIVE setting)When LOOM_AUTO_ARCHIVE is false, prompt the user after successful completion: "Session complete. Auto-archive is disabled. Would you like to archive this session?"
If archive_session appears in your available tools, use it — a single call handles all archival:
archive_session with the session ID. The MCP tool atomically:
completedactive-session.md to docs/loom/state/archive/<session-id>.mddocs/loom/plans/archive/ (if it exists and is non-null)docs/loom/plans/archive/ (if it exists and is non-null)archived_files array in the response)If archive_session is not available, fall back to manual file operations:
docs/loom/plans/archive/ directory if it does not existdocs/loom/state/archive/ directory if it does not existdocs/loom/plans/ to docs/loom/plans/archive/ — the original MUST be deleted. Use Bash with mv or read+write+delete. Do NOT leave the file in both locations. Skip this step if design_document is null (Express sessions).docs/loom/plans/ to docs/loom/plans/archive/ — same: delete the original. Skip this step if implementation_plan is null (Express sessions).status to completedupdated timestampactive-session.md from docs/loom/state/ to docs/loom/state/archive/<session-id>.md — delete the original.After archival, verify ALL of the following (archive is incomplete if any check fails):
active-session.md exists in docs/loom/state/docs/loom/plans/ (only the archive/ subdirectory should be present)archive/Resume is triggered by the /loom:resume command or when /loom:orchestrate detects an existing active session.
/loom:resume), use that injected content instead of calling get_session_status. Otherwise, if get_session_status appears in your available tools, call it to read the active session. Otherwise, read state via Bash: node ${CLAUDE_PLUGIN_ROOT}/scripts/read-active-session.js (resolves LOOM_STATE_DIR internally)status: completed)status: in_progress or pending)in_progress and update timestampsWhen resuming a session with workflow_mode: "express" (read from session state via get_session_status), follow the Express workflow's resume protocol instead of the standard resume steps above:
pending: re-generate and present the structured brief for approval. On approval, proceed to delegation.in_progress: the implementing agent was interrupted. Re-delegate with the same scope. Use the agents array to identify which agent was running.completed but session status is in_progress: code review or archival was interrupted. Run the code review step, then archive.Express sessions have a single phase. The phase status combined with the agents array contents determines the resume position.
When resuming, check for potential conflicts:
Report any detected conflicts to the user before proceeding.
After each subagent invocation, record:
Maintain two levels of aggregation:
token_usage:
total_input: 15000
total_output: 8000
total_cached: 3000
by_agent:
coder:
input: 8000
output: 4000
cached: 2000
tester:
input: 7000
output: 4000
cached: 1000