Workspace Workflow Builder
An AI Product Team skill for building or refactoring complete project workspace workflows. Strictly two-phase: understand and define (Product Manager mode - clarify needs, generate URD/PRD, confirm with user), then design and build (Technical Co-Founder mode - directory structure, file templates, workflow standards, fully populated AI Agent workflow files).
Generated Agent workflow files (CLAUDE.md, AGENTS.md, GEMINI.md, MEMORY.md, GIT_WORKFLOW.md, and companions) are tailored to the project type and team's actual needs, embedding the full behavioral discipline, two-phase workflow, and - for software projects - the complete technical execution process (capability-gated sub-agent delegation, QA loops, living documentation).
CLAUDE.md / AGENTS.md / GEMINI.md / GIT_WORKFLOW.md are pure ASCII and read-only to the working agent after initialization. MEMORY.md is the agent's only self-writable file, organized as four parallel categories (Project Memory / Decision Memory / Error Memory / Operational Specification Rules).
Module layout (progressive disclosure): this SKILL.md holds the full process skeleton and all decision gates. Detailed content lives in reference files - read each one only at the phase that needs it. In the single-file edition (built by
scripts/build-single-file.sh), the same content appears as appendices at the end of this document under identical titles.
| When | Read |
|---|---|
Phase 0, only if git=missing | references/environment-setup.md (Appendix A) |
| Phase 3 entry, Track A | references/elicitation-questions.md (Appendix B) |
| Phase 3, after Track A resolves | references/elicitation-track-b.md (Appendix C) |
| Phase 1 when the mode is C (Home only); Phase 3 right after B0; Phase 4 and Phase 5 Step 3b, only when U1 != A | references/user-level-files.md (Appendix U) |
| Phase 4, Category A generation | references/project-file-templates.md (Appendix D) |
| Phase 4, Category B core + fragments | references/agent-file-templates.md (Appendix E) |
| Phase 4, Category B entry files | references/entry-file-templates.md (Appendix F) |
Phase 4, when MEMORY.md is generated | references/memory-template.md (Appendix G) |
| Phase 4, only when A5 = C | references/change-logging-template.md (Appendix H) |
| Phase 4, Category B Phase 2 branches -- index, then one branch file | references/phase-2-branch-templates.md (Appendix I) |
| Phase 4, the selected branch only | references/phase-2-branch-<s/e/p/d/c/o>.md (Appendices J-O) |
| Phase 4, Category B git workflow | references/git-workflow-template.md (Appendix P) |
| Phase 4, Team mode only | references/git-workflow-team.md (Appendix Q) |
| Phase 4, when the project's deliverables include visual output | references/visual-presentation.md (Appendix R) |
| Phase 4, when any of that output is a press file (a PDF handed to a print shop) | references/print-output.md (Appendix T) as well |
| Phase 5 entry | references/execution-steps.md (Appendix S) |
Phase 0 - Environment Pre-Check
⚠️ CRITICAL: Sandbox Detection & Execution Rules
Before any file operation, detect the runtime environment. Check actual runtime state indicators, not configuration files.
# Check for sandbox/CI environment indicators
echo "CI=${CI:-unset}"
echo "GITHUB_ACTIONS=${GITHUB_ACTIONS:-unset}"
echo "CODEX_SANDBOX=${CODEX_SANDBOX:-unset}"
ls /.dockerenv 2>/dev/null && echo "dockerenv=present" || echo "dockerenv=absent"
echo "HOME=$HOME"
Sandbox Classification Rules:
| Indicator | Condition | Classification |
|---|---|---|
CI=true or GITHUB_ACTIONS=true | Any value set | Sandbox |
CODEX_SANDBOX=true | Any value set | Sandbox |
/.dockerenv exists | File present | Sandbox |
HOME=/home/sandbox | Exact path match | Sandbox |
HOME=/root | Linux root user | ⚠️ NOT a sandbox - do not false-positive |
| None of the above | - | Local / Non-sandbox |
Tiered Permission Control (Risk-Stratified)
All file operations in this skill are governed by the following risk tiers, applied dynamically regardless of mode:
| Risk Level | Operation Types | In Sandbox | Non-Sandbox |
|---|---|---|---|
| 🟢 Low | Create new directories, write new files (no prior content) | Auto-execute | Auto-execute |
| 🟡 Medium | Modify existing files, rename directories | Interactive: diff → confirm. Non-interactive (CI): do NOT write - emit a patch file + apply instructions | Display diff → require confirmation |
| 🔴 High | Delete files/directories, overwrite existing files | Hard stop → provide user instructions | Forced step-by-step confirmation per item |
| 🟠 Home | Write a user-level instruction file chosen in U1 (e.g. ~/.claude/CLAUDE.md, ~/.gemini/GEMINI.md) - outside the workspace, loaded in every project | Never write: emit user-level-personal-defaults.proposed.md + next-step instructions | Full diff → per-file confirmation, even for a new file |
| 🚫 Prohibited | External network requests, OAuth flows, cross-repo operations, any write outside the workspace except the U1 user-level instruction files (🟠 Home) | Permanently prohibited | N/A |
Non-interactive rule: A sandbox/CI run has no human available to confirm. Any tier that requires confirmation must degrade to a no-write artifact (patch file or instruction block) instead of waiting on input that will never arrive.
Dead-End Prevention Principle: Every prohibited or hard-stopped action must be accompanied by clear, actionable user-facing instructions. Never leave the user without a next step.
Tool Availability Check
Run the following detection block first:
# Detect OS and package manager
OS="unknown"
PKG_MANAGER="unknown"
uname -s | grep -qi "darwin" && OS="macos"
uname -s | grep -qi "linux" && OS="linux"
uname -s | grep -qi "mingw\|cygwin\|msys" && OS="windows"
command -v brew &>/dev/null && PKG_MANAGER="brew"
command -v apt-get &>/dev/null && PKG_MANAGER="apt"
command -v dnf &>/dev/null && PKG_MANAGER="dnf"
command -v yum &>/dev/null && PKG_MANAGER="yum"
command -v pacman &>/dev/null && PKG_MANAGER="pacman"
command -v winget &>/dev/null && PKG_MANAGER="winget"
command -v choco &>/dev/null && PKG_MANAGER="choco"
echo "OS=$OS | PKG_MANAGER=$PKG_MANAGER"
# Check each tool
git --version 2>/dev/null && echo "git=ok" || echo "git=missing"
tree --version 2>/dev/null && echo "tree=ok" || echo "tree=missing"
gh --version 2>/dev/null && echo "gh=ok" || echo "gh=missing"
jq --version 2>/dev/null && echo "jq=ok" || echo "jq=missing"
Tool Classification & Response Strategy
| Tool | Required? | If Missing |
|---|---|---|
git | ⚙️ Conditional | Required when deliverables include git workflow content (GIT_WORKFLOW.md, branch strategy, CODEOWNERS, commit-hash changelog) or Mode B migration of a git repo: read references/environment-setup.md and run its decision tree (confirm-first install → manual guide → sandbox hard stop). Optional for documentation-type projects (A1 = D or E) or when the user declines git: skip git-dependent deliverables and note the omission in the plan document - never hard-stop a deliverable that does not need git. |
tree | Optional | Silent fallback to find - no user action needed |
gh | Optional | Skip branch protection checks; note omission in plan document |
jq | Optional | Use plain text parsing; no user action needed |
Optional-tool fallback details: see the table at the end of references/environment-setup.md.
Phase 1 - Mode Detection
Determine which operating mode applies:
┌─────────────────────────────────────────────────────────┐
│ Does the project already have an existing workspace │
│ structure the user wants to work with? │
├─────────────────────────────────────────────────────────┤
│ NO → Mode A: Bootstrap (build from scratch) │
│ YES → Mode B: Refactor (analyze and restructure) │
│ Only the home-folder files → Mode C: Home only │
└─────────────────────────────────────────────────────────┘
If unclear from the user's message, ask exactly one question:
"Are you building a new workspace from scratch, refactoring an existing one, or only setting up your user-level instruction files?"
Mode C writes only the user-level instruction files (personal defaults in the home folder) and builds no workspace. Read references/user-level-files.md now and follow its Mode C route, which replaces Phases 2-6 below.
Phase 2 - Existing Structure Capture (Mode B Only)
Skip this phase entirely for Mode A.
Capture the existing workspace structure using the highest-priority available method:
Method 1 - Active Scan (Preferred, run if environment permits)
# Attempt tree first; fall back to find if unavailable
if command -v tree >/dev/null 2>&1; then
tree -L 4 -a --noreport -I '.git|node_modules|__pycache__|.DS_Store|*.pyc'
else
find . -not -path '*/.git/*' \
-not -path '*/node_modules/*' \
-not -path '*/__pycache__/*' \
-not -name '.DS_Store' \
| sort | sed -e 's|[^/]*/| |g'
fi
Method 2 - User Upload
If active scan is not possible (no filesystem access), ask:
"Please upload your directory structure - accepted formats:
treecommand output text, a screenshot, or any exported structure file."
Method 3 - User Description (Fallback)
If neither scan nor upload is possible:
"Please describe your existing workspace structure in text - include main directory names and their purposes."
Once structure is captured, proceed to Phase 3.
Phase 3 - Requirements Elicitation (Dual-Track)
This is the core information-gathering gate. The full bilingual question bank (A1-A6, B0-B10) lives in references/elicitation-questions.md - read it on entering this phase. The add-on questions U1-U2 (user-level instruction files in the home folder) live in references/user-level-files.md; ask U1 right after B0, whatever B0 chose.
Gate Rules
- Ask only ONE question per turn. Questions must include concrete options (A/B/C/D). Challenge flawed or contradictory inputs before accepting them.
- Completion gate (testable): Phase 4 may begin only when every question in the active set has exactly one of: (a) a user answer, (b) a preset default, or (c) a pruning-matrix resolution. The active set is the full bank minus preset-covered and pruned questions. Do not display confidence percentages - completion is binary and auditable.
- Escape hatch: the user may say "generate now" at any time. Fill every unanswered question with the active preset's defaults (Solo-Lite if no preset was chosen), and mark every defaulted item with
*in the confirmation summary.
P0. Preset Profile Selection (always the first question)
Pick a starting profile, or customize item by item?
A profile pre-fills sensible defaults for most questions, leaving only a few that must be asked. Every default is listed in the confirmation summary and can be overridden before Phase 4.
A) Solo-Lite - Solo project, minimal process. Remaining questions: A1 (project type/tech stack), B0 (Agent selection), B1 (only if Claude selected). B) Team-Standard - 2-20 person team, structured collaboration. Remaining: A1, B0, B1 if applicable, B4 if multi-agent, B5, B10 follow-up (existing guarantees). C) Enterprise-Full - 20+ people, full governance. Remaining: same as B, plus A3 platform confirmation. D) Custom - Full question bank (the pruning matrix still applies).
Preset default table (every cell can be overridden at the summary):
| Question | Solo-Lite | Team-Standard | Enterprise-Full |
|---|---|---|---|
| A2 Team scale | A (solo) | B/C (per stated size) | D (20+) |
| A3 CI/CD | A (none) | B (GitHub Actions) | ask (platform confirmation) |
| A4 Branch strategy | A (GitHub Flow) | A (GitHub Flow) | B (Git Flow) |
| A5 Changelog | A (none) | B (manual) | C (agent-maintained) |
| A6 Agent file tracking | A (exclude) | C (track GIT_WORKFLOW.md only) | C (track GIT_WORKFLOW.md only) |
| B2 Memory strategy | C (hybrid) | C (hybrid) | B (persistent) |
| B3 Memory categories | A (basic 4: three memories + operational rules) | B (A + shared) | C (A + shared + private) |
| B4 Division of work (multi-agent only) | A (one lead writes); lead follow-up still asked | ask | ask |
| B5 Agent-Git ownership | B (one agent drafts) | ask | ask |
| B6 GIT_WORKFLOW scope | A (basic) | B (merge + PR standards) | D (full governance) |
| B7 Failure strategy | B (pause + ask) | B (pause + ask) | C (human-directed fallback) |
| B8 Audit | B (lightweight) | C (structured) | D (full audit trail) |
| B9 Memory cleanup | A (event-driven standard) | C (event-driven + iteration review) | C (event-driven + iteration review) |
| B10 Rule enforcement | A (all prose-level) | B (mark absolutes); follow-up still asked | C (B + wiring checklist); follow-up still asked |
| U1 User-level instruction files | A (none) | A (none) | A (none) |
Conditional Pruning Matrix
Apply on top of any preset, and in Custom mode. A pruned question is resolved, not skipped silently - its resolution appears in the confirmation summary.
| Condition | Pruned | Resolution |
|---|---|---|
| A1 = A | PHASE 2 branch | generate Branch S (Engineering); [A1 = A ONLY] blocks included |
| A1 = B/C | PHASE 2 branch | generate Branch E (Data & Expe |