Implementation
Executes implementation tasks using different approaches: direct execution, dual-agent comparison, or plan-based execution.
Requirements
- Active session must exist (session path in working memory)
- If no active session: STOP and ask user for session path
Common Steps (Mandatory)
These steps apply to ALL actions after implementation is complete.
Working Dir Resolution
- Read Working Dir from session
_overview.md - If not set: check project
.samocodefile forMAIN_REPO, or use git root, or ask user
After Code Changes
- Lint/typecheck: Run pyright/ruff (Python). For TypeScript, rely on LSP (vtsls) — do NOT run
npx tsc --noEmit(it OOMs on large codebases) - Commit code: In Working Dir, commit with descriptive message
- Check branch first: warn if on main, should be feature branch
After Session Changes
- Update
_overview.md: Add Flow Log entry and Files entry - Commit session:
cd [SESSION_DIR] && git add . && git commit -m "[action]: [description]"
Plan Progress (when working from a plan)
- Read plan file, mark completed items
- [x] - Add completion note:
**Phase completed** ([TIMESTAMP_ITERATION])
Default Action: dop2
IMPORTANT: For implementation phases, use dop2 (dual-agent comparison).
- dop2 (Dual-Agent): Spawn 2 Task sub-agents to propose solutions, then compare
- dop (Direct): Only for trivially simple 1-2 line changes
DO NOT implement directly with Edit/Write - spawn sub-agents to propose solutions first.
Rule of thumb: If you're considering dop, ask "Could there be a cleaner way?" If yes -> use dop2.
Actions
do - Direct Implementation
Execute a task directly with full implementation and documentation.
Session path: [SESSION_PATH from working memory] Task: $ARGUMENTS
Steps
Investigate and implement:
- Review session documents for context
- Explore codebase as needed
- Make all necessary code changes
Document work - Create
[SESSION_PATH]/[TIMESTAMP_FILE]-do-[task-slug].md:# Task: [brief title] Date: [TIMESTAMP_LOG] ## What was done [Description of changes] ## Files Changed - [file] - [what changed] ## Testing [How verified] ## Notes [Any important observations]Complete common steps (see above)
Report back: Summary of what was done
do2 - Dual-Agent Comparison
Spawn two agents with different philosophies to solve the same task independently. Compare solutions and present options.
Session path: [SESSION_PATH from working memory] Task: $ARGUMENTS
Dual Agent Execution
Spawn 2 sub-agents in parallel (model: sonnet). Do NOT tell them about each other.
Both agents solve the entire task independently with different philosophies.
Agent 1: Minimal Footprint
Session path: [SESSION_PATH] Task: $ARGUMENTS
Approach: Smallest possible change surface.
- Touch few files, prefer localized fixes
- Avoid new abstractions
- Work within existing structures
Deliverables:
Create
[SESSION_PATH]/[TIMESTAMP_FILE]-solution-minimal.md:# Solution: Minimal Footprint Task: [description] ## Approach [High-level strategy] ## Proposed Changes ### File: [path] ```[language] [code]Why: [rationale]
Tradeoffs
[What we accept]
DO NOT edit actual code files - proposals only
Report summary
Agent 2: Clean Foundation
Session path: [SESSION_PATH] Task: $ARGUMENTS
Approach: The "right way" with time to do it properly.
- Refactor for cleaner solution
- Introduce helpful abstractions
- Consider future maintainability
Deliverables:
Create
[SESSION_PATH]/[TIMESTAMP_FILE]-solution-clean.md:# Solution: Clean Foundation Task: [description] ## Approach [High-level strategy] ## Proposed Changes ### File: [path] ```[language] [code]Why: [rationale]
Architecture Improvements
[New patterns, benefits]
DO NOT edit actual code files - proposals only
Report summary
Synthesis (Parent does this)
After both agents complete:
Review both solutions
Create
[SESSION_PATH]/[TIMESTAMP_FILE]-comparison.md:# Comparison: [task] ## Minimal Footprint **Pros:** [list] **Cons:** [list] ## Clean Foundation **Pros:** [list] **Cons:** [list] ## Recommendation [Which approach and why] ## Hybrid Possibility [Can we combine best of both?]Complete common steps for session files
Present to user:
Which approach? 1. Minimal footprint 2. Clean foundation 3. Hybrid 4. Neither (rethink)
After User Confirms
- Implement chosen solution
- If part of a plan: Update plan progress
- Complete common steps (lint, commit code, update session, commit session)
dop - Plan Phase Execution (Direct)
Execute a specific phase from the plan without comparing approaches.
Only for TRIVIALLY SIMPLE 1-2 line changes. For anything else, use dop2.
Session path: [SESSION_PATH from working memory] Phase: $ARGUMENTS
IMPORTANT: Only work on this specific part. Don't do other parts of the plan.
Steps
Find the plan:
- Check session
_overview.md-> Plans section for plan file - Read the plan file from session folder
- Locate the specific phase/section to implement
- Check session
Implement:
- Make all necessary code changes for this phase only
- Follow codebase best practices
Document work - Create
[SESSION_PATH]/[TIMESTAMP_FILE]-dop-[phase-slug].md:# Phase: [phase name] Date: [TIMESTAMP_LOG] Plan: [plan filename] ## Completed Items - [x] [Item from plan] - [x] [Item from plan] ## Changes Made - [file] - [what changed] ## Testing [How verified] ## Notes [Any issues or observations]Complete common steps (lint, commit code, update plan, update session, commit session)
Report back: Summary of completed items
dop2 - Dual-Agent Plan Phase with Auto-Selection
DEFAULT IMPLEMENTATION STRATEGY - Use Task tool to spawn 2 sub-agents.
Execute a plan phase using dual-agent comparison, with automatic solution selection weighted toward clean approach.
CRITICAL: You MUST use the Task tool to spawn sub-agents. DO NOT implement directly.
Session path: [SESSION_PATH from working memory] Task: $ARGUMENTS
IMPORTANT: Only work on this specific task. Don't do other parts of the plan.
Phase Scope Assessment
Before spawning agents, assess phase complexity:
- Review the phase items - Count distinct deliverables/changes
- If phase has 5+ items or touches 5+ files:
- Consider splitting into sub-phases (e.g., "Phase 3a", "Phase 3b")
- Each sub-phase should be a coherent unit (1-3 related items)
- Run dop2 for each sub-phase sequentially
- If phase has 2-4 independent sub-items:
- Can run 2 dop2 calls in parallel for independent items
- Only parallelize if items don't share files/dependencies
Dual Agent Execution
Spawn 2 sub-agents in parallel (model: sonnet) with the context below. Do NOT tell them about each other.
CRITICAL: Both agents solve the entire task independently. This is NOT task splitting - each agent produces a FULL solution with their own philosophy.
Agent 1: Minimal Footprint
Session path: [SESSION_PATH] Task: $ARGUMENTS
Your approach: Solve with the smallest possible change surface.
Guidelines:
- Touch as few files as possible
- Prefer simple, localized fixes
- Avoid new abstractions or patterns
- Work within existing structures
Deliverables:
Create
[SESSION_PATH]/[TIMESTAMP_FILE]-solution-minimal.md:# Solution: Minimal Footprint Date: [TIMESTAMP_LOG] Task: [description] ## Approach [High-level strategy] ## Proposed Changes ### File: [path] ```[language] [code]Why: [rationale]
Tradeoffs
[What we accept with this approach]
Risks
[Potential issues]
Update
_overview.md: Flow Log and Files entriesDO NOT edit actual code files - suggestions only
Report back with summary
Agent 2: Clean Foundation
Session path: [SESSION_PATH] Task: $ARGUMENTS
Your approach: Solve the "right way" assuming time to do it properly.
Guidelines:
- Refactor if it leads to cleaner solution
- Introduce abstractions where they reduce future complexity
- Consider how this code will evolve
- Prioritize maintainability over minimal diff
Deliverables:
Create
[SESSION_PATH]/[TIMESTAMP_FILE]-solution-clean.md:# Solution: Clean Foundation Date: [TIMESTAMP_LOG] Task: [description] ## Approach [High-level strategy] ## Proposed Changes ### File: [path] ```[language] [code]Why: [rationale]
Architecture Improvements
[New patterns, refactorings]
Benefits
[Long-term advantages]
Update
_overview.md: Flow Log and Files entriesDO NOT edit actual code files - suggestions only
Report back with summary
Synthesis & Auto-Selection
After both agents complete:
Create
[SESSION_PATH]/[TIMESTAMP_FILE]-comparison-[task-slug].md:# Comparison: [task] ## Key Differences [What's fundamentally different] ## Solution 1: Minimal **Pros:** [list] **Cons:** [list] **Risk:** [Low/Medium/High] ## Solution 2: Clean **Pros:** [list] **Cons:** [list] **Risk:** [Low/Medium/High] ## Recommendation [Which approach and why] ## Hybrid Possibility [Can we combine best of both?]Auto-Selection Logic:
- Default: Choose Clean Foundation unless minimal has compelling justification
- Choose Minimal only if:
- Clean introduces significant complexity with unclear benefit
- Minimal solves urgent issue with acceptable tradeoffs
- Clean approach has high risk/uncertainty
Complete common steps for session files
Present comparison and ask:
Which approach? 1. Minimal footprint 2. Clean foundation 3. Hybrid 4. Neither (rethink)
After User Confirms
- Implement chosen solution
- Update plan progress (mark items
- [x], add completion note) - Complete common steps (lint, commit code, update session, commit session)
IMPORTANT! If unsure about something, ask first.
Converted and distributed by TomeVault — claim your Tome and manage your conversions.