Add DOG structure to existing codebase
Adds DOG planning structure to existing codebases by analyzing current state and creating tracking documents
/plugin marketplace add cowwoc/claude-code-dog/plugin install dog@claude-code-dogAdd DOG planning structure to an existing codebase. Detects existing code patterns, analyzes project state, and creates DOG planning documents that reflect current progress.
This is a brownfield initialization - we must understand what exists before planning what comes next.
</objective><execution_context>
@${CLAUDE_PLUGIN_ROOT}/.claude/dog/templates/project.md @${CLAUDE_PLUGIN_ROOT}/.claude/dog/templates/roadmap.md @${CLAUDE_PLUGIN_ROOT}/.claude/dog/templates/dog-config.json @${CLAUDE_PLUGIN_ROOT}/.claude/dog/workflows/questioning.md
</execution_context>
<process> <step name="verify">MANDATORY FIRST STEP - Verify preconditions:
Abort if DOG already exists:
[ -f .claude/dog/PROJECT.md ] && echo "ERROR: DOG already initialized. Use /dog:status" && exit 1
Verify this is an existing codebase:
# Check for existing code files
CODE_COUNT=$(find . -name "*.ts" -o -name "*.js" -o -name "*.py" -o -name "*.go" \
-o -name "*.rs" -o -name "*.java" -o -name "*.swift" 2>/dev/null \
| grep -v node_modules | grep -v .git | wc -l)
if [ "$CODE_COUNT" -eq 0 ]; then
echo "No existing code found. Use /dog:new-project instead."
exit 1
fi
echo "Found $CODE_COUNT source files"
Initialize git if needed:
if [ -d .git ] || [ -f .git ]; then
echo "Git repo exists"
else
git init
echo "Initialized new git repo"
fi
You MUST run all bash commands above using the Bash tool before proceeding.
Detect project characteristics:
Identify language/stack:
# Check for package managers and build files
[ -f package.json ] && echo "Node.js project detected"
[ -f requirements.txt ] && echo "Python project detected"
[ -f Cargo.toml ] && echo "Rust project detected"
[ -f go.mod ] && echo "Go project detected"
[ -f pom.xml ] && echo "Maven/Java project detected"
[ -f build.gradle ] && echo "Gradle/Java project detected"
[ -f Package.swift ] && echo "Swift project detected"
Check for existing documentation:
[ -f README.md ] && echo "README.md exists"
[ -d docs ] && echo "docs/ directory exists"
Analyze git history:
git log --oneline -20 2>/dev/null || echo "No git history"
Check for tests:
find . -name "*test*" -o -name "*spec*" 2>/dev/null | grep -v node_modules | head -10
Analyze existing code and present findings:
Use AskUserQuestion:
If "Let me clarify" -> receive input, update understanding.
</step> <step name="question">Gather context about project goals:
1. Current state (FREEFORM):
Ask inline: "What is this project, and what stage is it at?"
Wait for response.
2. Existing work:
Use AskUserQuestion:
3. Next steps:
Use AskUserQuestion:
4. Boundaries (future work only):
NOTE: This question is about FUTURE work scope only. Completed versions are ALWAYS included in DOG tracking to maintain historical record. Do NOT offer options to exclude completed versions.
Use AskUserQuestion:
5. Decision gate:
Use AskUserQuestion:
Infer current state from codebase:
Based on analysis:
</step> <step name="create_structure">MANDATORY: Include ALL discovered versions in ROADMAP.md - completed, in-progress, AND planned. The "Boundaries" question only affects OUT OF SCOPE items, NOT which versions to track. Completed versions provide historical context and enable accurate
/dog:statusreporting.
Create DOG planning structure:
mkdir -p .claude/dog
Create PROJECT.md with inferred state:
# [Project Name]
## Overview
[Description from README or inferred from code]
## Goals
- [Inferred from codebase]
## Requirements
### Validated
- [x] [Existing capability 1] - existing
- [x] [Existing capability 2] - existing
- [x] [Existing capability 3] - existing
### Active
- [ ] [Next requirement 1]
- [ ] [Next requirement 2]
### Out of Scope
- [Exclusion 1] - [why]
## Constraints
- [Inferred constraints]
## Key Decisions
| Decision | Rationale | Outcome |
|----------|-----------|---------|
| [Existing architectural choice] | [Inferred] | Implemented |
---
*Last updated: [date] after DOG initialization on existing codebase*
Create ROADMAP.md reflecting current state:
IMPORTANT: Minor versions group related tasks. Each minor version contains MULTIPLE tasks. Do NOT create one minor per task. Instead, group logically related work into minor versions.
# Roadmap
## Version 1: [Current Version Name]
- **1.0:** [Description of this minor version's goal] (COMPLETED)
- task-a
- task-b
- task-c
- **1.1:** [Description of next minor version's goal]
- task-d
- task-e
---
*Initialized from existing codebase*
*Use /dog:add-major-version to add more major versions*
Grouping guidance:
Create task directory structure for ALL discovered tasks:
IMPORTANT: Create task directories for EVERY task in ROADMAP.md, including completed versions. Do NOT skip completed tasks. The directory structure provides a complete historical record and enables
/dog:statusto report accurate counts across all versions.
For each major version in ROADMAP.md (including completed versions):
mkdir -p ".claude/dog/major/{major}"
For each minor version under each major:
mkdir -p ".claude/dog/major/{major}/minor/{minor}"
Create minor STATE.md:
# State
- **Status:** {completed|in-progress|pending}
- **Progress:** {percentage based on task completion}%
- **Tasks:** {completed}/{total}
- **Last Updated:** {timestamp}
For each task discovered in the minor version:
mkdir -p ".claude/dog/major/{major}/minor/{minor}/task/{task-name}"
Create task STATE.md:
# State
- **Status:** {completed|in-progress|pending}
- **Progress:** {100 if completed, 0 if pending, 50 if in-progress}%
- **Dependencies:** []
- **Last Updated:** {timestamp}
Create task PLAN.md (minimal for discovered tasks):
# Plan: {task-name}
## Goal
{Inferred from task name and context}
## Status
{Discovered during DOG initialization from existing codebase}
## Notes
- Task discovered from existing project state
- Plan details to be refined when task is executed
Create task CHANGELOG.md (status-aware):
For completed tasks:
# Changelog
## {task-name}
*Completed prior to DOG initialization. See git history for details.*
For pending/in-progress tasks:
# Changelog
## {task-name}
*Changelog will be populated during task execution.*
Task status mapping:
(COMPLETED) or (COMPLETE) in ROADMAP.md → status: completed, progress: 100%(IN PROGRESS) in ROADMAP.md → status: in-progress, progress: 50%status: pending, progress: 0%Ask workflow mode preference:
Use AskUserQuestion:
Create .claude/dog/dog-config.json with selected mode.
git add .claude/dog/
git commit -m "$(cat <<'EOF'
docs: add DOG structure to existing codebase
Initializes DOG planning on existing project.
Infers current state from codebase analysis.
Creates task directories for all discovered tasks.
EOF
)"
</step>
<step name="done">
Determine next action based on pending/in-progress tasks:
Scan created task directories for tasks with status: pending or status: in-progress in STATE.md:
/dog:execute-task {major}.{minor}/{task-name} with first pending task/dog:add-taskPresent completion:
DOG structure added to existing codebase:
- Project: .claude/dog/PROJECT.md
- Roadmap: .claude/dog/ROADMAP.md
- Config: .claude/dog/dog-config.json (mode: [mode])
Task directories created:
- [N] major versions
- [N] minor versions
- [N] tasks ([N] completed, [N] in-progress, [N] pending)
---
## Next Up
[IF pending/in-progress tasks exist:]
**Execute next task** - {task-name}
`/dog:execute-task {major}.{minor}/{task-name}`
[ELSE:]
**Add tasks** - define work to be done
`/dog:add-task`
<sub>`/clear` first -> fresh context window</sub>
---
</step>
</process>
<success_criteria>
</success_criteria>