Session Isolation Pattern: Session-based artifact isolation for multi-artifact workflows. Use when orchestrating workflows that generate multiple files (designs, reviews, reports) to prevent file collisions across concurrent or sequential sessions.
Installation
Details
Usage
After installing, this skill will be available to your AI coding assistant.
Verify installation:
skills listSkill Instructions
Session Isolation Pattern
Session-based artifact isolation for multi-artifact workflows. Use when orchestrating workflows that generate multiple files (designs, reviews, reports) to prevent file collisions across concurrent or sequential sessions.
Problem
When multiple workflows run (even sequentially), artifacts with the same name collide:
Session 1 (SEO): writes ai-docs/plan-review-grok.md
Session 2 (API): writes ai-docs/plan-review-grok.md <-- OVERWRITES!
Solution
Use unique session folders to isolate artifacts:
ai-docs/sessions/agentdev-seo-20260105-143022-a3f2/
├── session-meta.json # Session tracking
├── design.md # Primary artifact
├── reviews/
│ ├── plan-review/ # Plan review phase
│ │ ├── internal.md
│ │ ├── grok.md
│ │ └── consolidated.md
│ └── impl-review/ # Implementation review phase
│ ├── internal.md
│ └── consolidated.md
└── report.md # Final report
Implementation Pattern
1. Session Initialization (Orchestrator)
Add to Phase 0 of your orchestrator command:
# Generate unique session path
TARGET_SLUG=$(echo "${TARGET_NAME:-workflow}" | tr '[:upper:] ' '[:lower:]-' | sed 's/[^a-z0-9-]//g' | head -c20)
SESSION_BASE="${WORKFLOW_TYPE}-${TARGET_SLUG}-$(date +%Y%m%d-%H%M%S)-$(head -c4 /dev/urandom | xxd -p | head -c4)"
SESSION_PATH="ai-docs/sessions/${SESSION_BASE}"
# Create directory structure
mkdir -p "${SESSION_PATH}/reviews/plan-review" \
"${SESSION_PATH}/reviews/impl-review" || {
echo "Warning: Cannot create session directory, using legacy mode"
SESSION_PATH="ai-docs"
}
# Create session metadata (if not legacy mode)
if [[ "$SESSION_PATH" != "ai-docs" ]]; then
cat > "${SESSION_PATH}/session-meta.json" << EOF
{
"session_id": "${SESSION_BASE}",
"type": "${WORKFLOW_TYPE}",
"target": "${USER_REQUEST}",
"started_at": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
"status": "in_progress"
}
EOF
fi
2. Pass SESSION_PATH to Sub-Agents
Include in all agent prompts:
SESSION_PATH: ${SESSION_PATH}
{actual task description}
Save output to: ${SESSION_PATH}/{artifact_path}
3. Sub-Agent SESSION_PATH Detection
Add to agent <critical_constraints>:
<session_path_support>
**Check for Session Path Directive**
If prompt contains `SESSION_PATH: {path}`:
1. Extract the session path
2. Use it for all output file paths
3. Primary artifact: `${SESSION_PATH}/{type}.md`
4. Reviews: `${SESSION_PATH}/reviews/{phase}/{model}.md`
**If NO SESSION_PATH**: Use legacy paths (ai-docs/)
</session_path_support>
4. Session Completion
Update metadata when workflow completes:
if [[ -f "${SESSION_PATH}/session-meta.json" ]]; then
jq '.status = "completed" | .completed_at = (now | strftime("%Y-%m-%dT%H:%M:%SZ"))' \
"${SESSION_PATH}/session-meta.json" > "${SESSION_PATH}/session-meta.json.tmp" && \
mv "${SESSION_PATH}/session-meta.json.tmp" "${SESSION_PATH}/session-meta.json"
fi
Artifact Path Mapping
| Artifact Type | SESSION_PATH Format | Legacy Format |
|---|---|---|
| Design/Context | ${SESSION_PATH}/design.md | ai-docs/agent-design-{name}.md |
| Plan Review | ${SESSION_PATH}/reviews/plan-review/{model}.md | ai-docs/plan-review-{model}.md |
| Impl Review | ${SESSION_PATH}/reviews/impl-review/{model}.md | ai-docs/impl-review-{model}.md |
| Consolidated | ${SESSION_PATH}/reviews/{phase}/consolidated.md | ai-docs/{phase}-consolidated.md |
| Final Report | ${SESSION_PATH}/report.md | ai-docs/{workflow}-report-{name}.md |
Backward Compatibility
Legacy Mode Triggers:
SESSION_PATHnot provided in prompt- Directory creation fails (permissions)
- Explicit
LEGACY_MODE: truein prompt
Behavior:
- Fall back to flat
ai-docs/paths - Log warning about legacy mode
- All features still work, just without isolation
Session Metadata Schema
{
"session_id": "agentdev-seo-20260105-143022-a3f2",
"type": "agentdev",
"target": "SEO agent improvements",
"started_at": "2026-01-05T14:30:22Z",
"completed_at": "2026-01-05T15:45:30Z",
"status": "completed",
"phases_completed": ["init", "design", "plan-review", "implementation", "quality-review"],
"models_used": ["claude-embedded", "x-ai/grok-code-fast-1", "google/gemini-3-pro"],
"artifacts": {
"design": "design.md",
"plan_reviews": ["reviews/plan-review/internal.md", "reviews/plan-review/grok.md"],
"impl_reviews": ["reviews/impl-review/internal.md", "reviews/impl-review/gemini.md"],
"report": "report.md"
}
}
Plugins Using Session Isolation
| Plugin | Command | Session Pattern |
|---|---|---|
| agentdev | /develop | agentdev-{target}-{timestamp}-{random} |
| frontend | /review, /implement | review-{timestamp}-{random} |
| seo | /review, /alternatives | seo-review-{timestamp}-{random} |
Best Practices
- Always initialize early: Session creation should happen in Phase 0
- Include SESSION_PATH in all prompts: Sub-agents need it for output paths
- Use descriptive slugs: Include workflow type and target in folder name
- Update metadata on completion: Track status changes
- Fallback gracefully: Never fail the workflow due to session creation issues
More by MadAppGang
View allChoose optimal external AI models for code analysis, bug investigation, and architectural decisions. Use when consulting multiple LLMs via claudish, comparing model perspectives, or investigating complex Go/LSP/transpiler issues. Provides empirically validated model rankings (91/100 for MiniMax M2, 83/100 for Grok Code Fast) and proven consultation strategies based on real-world testing.
CRITICAL - Guide for using Claudish CLI ONLY through sub-agents to run Claude Code with OpenRouter models (Grok, GPT-5, Gemini, MiniMax). NEVER run Claudish directly in main context unless user explicitly requests it. Use when user mentions external AI models, Claudish, OpenRouter, or alternative models. Includes mandatory sub-agent delegation patterns, agent selection guide, file-based instructions, and strict rules to prevent context window pollution.
MANDATORY tracking protocol for multi-model validation. Creates structured tracking tables BEFORE launching models, tracks progress during execution, and ensures complete results presentation. Use when running 2+ external AI models in parallel. Trigger keywords - "multi-model", "parallel review", "external models", "consensus", "model tracking".
XML tag structure patterns for Claude Code agents and commands. Use when designing or implementing agents to ensure proper XML structure following Anthropic best practices.