| name | workflows:work |
| description | Execute research implementation plans efficiently while maintaining estimation quality and finishing features |
| argument-hint | <plan file, estimation specification, or task description> |
| allowed-tools | Read, Glob, Edit, Write, Bash |
Work Plan Execution Command
Pipeline mode: This command operates fully autonomously. All decisions are made automatically.
Execute a research implementation plan systematically. The focus is on shipping complete, reproducible research code by understanding requirements quickly, following existing patterns, and maintaining estimation quality throughout.
Input Document
<input_document> #$ARGUMENTS </input_document>
If no input document is provided: Look for the most recent plan in docs/plans/ and use it. If no plans exist, state "No plan found. Run /workflows:plan first." and stop.
Execution Workflow
Phase 1: Quick Start
-
Read Plan
- Read the work document completely
- Review any references, brainstorm origins, or linked code paths
- Identify the estimation method, identification strategy, and key deliverables
- Note any open questions from planning โ resolve by picking the conservative default and documenting the choice
- Proceed immediately โ do not wait for approval
-
Setup Environment
First, detect the project environment:
if [ -f "requirements.txt" ] || [ -f "setup.py" ] || [ -f "pyproject.toml" ]; then
echo "LANG=python"
elif [ -f "DESCRIPTION" ] || [ -f "renv.lock" ] || [ -f ".Rprofile" ]; then
echo "LANG=R"
elif [ -f "Project.toml" ]; then
echo "LANG=julia"
elif ls *.do >/dev/null 2>&1; then
echo "LANG=stata"
fi
ls Makefile Snakefile dvc.yaml 2>/dev/null
Then check the current branch:
current_branch=$(git branch --show-current)
default_branch=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@')
if [ -z "$default_branch" ]; then
default_branch=$(git rev-parse --verify origin/main >/dev/null 2>&1 && echo "main" || echo "master")
fi
If already on a feature branch (not the default branch):
- Continue working on it. Proceed to step 3.
If on the default branch:
Option A: Create a new branch (default)
-
Activate Research Environment
Read compound-science.local.md for environment configuration. Then activate:
Python:
if [ -d ".venv" ]; then source .venv/bin/activate
elif [ -d "venv" ]; then source venv/bin/activate
elif command -v conda &>/dev/null; then conda activate $(basename $PWD)
fi
python -c "import numpy, scipy, pandas; print('Core packages OK')"
R:
Rscript -e "if (file.exists('renv.lock')) renv::status()"
Verify data paths:
ls data/ 2>/dev/null | head -5
-
Create Task List
- Use TodoWrite to break plan into actionable tasks
- Include dependencies between tasks
- Prioritize based on the plan's phase structure
- Include estimation-specific quality check tasks:
- Convergence verification after each estimation step
- Standard error computation and diagnostic tests
- Robustness checks specified in the plan
- Keep tasks specific and completable
Phase 2: Execute
-
Task Execution Loop
For each task in priority order:
while (tasks remain):
- Mark task as in_progress in TodoWrite
- Read any referenced files from the plan
- Look for similar patterns in codebase
- Implement following existing conventions
- Write tests for new functionality
- Run Estimation Quality Check (see below)
- Run tests after changes
- Mark task as completed in TodoWrite
- Mark off the corresponding checkbox in the plan file ([ ] โ [x])
- Evaluate for incremental commit (see below)
Estimation Quality Check โ Before marking an estimation task done:
| Check | What to verify |
|---|
| Convergence | Did the optimizer converge? Check exit flag, gradient norm, iteration count. Multiple starting values yield consistent results? |
| Sensible estimates | Are parameter signs correct? Magnitudes economically reasonable? No values at boundary constraints? |
| Standard errors | Computed with appropriate method (robust, clustered, bootstrap)? Positive definite Hessian? No suspiciously small or large SEs? |
| Diagnostics | First-stage F > 10 (if IV)? Overidentification test (if overidentified)? Hausman or specification tests where relevant? |
| Numerical stability | Log-likelihood (not likelihood) used? Condition number of key matrices acceptable? No NaN/Inf in outputs? |
| Reproducibility | Random seeds set? Results identical across runs? Dependencies pinned? |
When to skip: Pure data cleaning, documentation updates, or pipeline configuration changes that don't involve estimation. If the task is purely additive (new utility function, data loading), the check takes 10 seconds and the answer is "no estimation, skip."
When this matters most: Any change that touches estimation routines, moment conditions, likelihood functions, or simulation code.
IMPORTANT: Always update the original plan document by checking off completed items. Use the Edit tool to change - [ ] to - [x] for each task you finish.
-
Incremental Commits
After completing each task, evaluate whether to create an incremental commit:
Phase 3: Quality Check
-
Run Core Quality Checks
Always run before submitting:
-
Estimation-Specific Validation
For any work involving estimation:
-
Consider Reviewer Agents (Optional)
Use for complex or risky changes. Read agents from compound-science.local.md frontmatter (review_agents). If no settings file, create one following the template in workflows-review/references/project-config.md.
Run configured agents in parallel with Task tool. Address critical issues before proceeding.
Default agents for estimation work:
econometric-reviewer โ identification and inference review
numerical-auditor โ numerical stability and convergence
identification-critic โ identification argument completeness
-
Final Validation
- All TodoWrite tasks marked completed
- All tests pass
- Linting passes
- Estimation converges with sensible results
- Standard errors and diagnostics computed
- Code follows existing patterns
- Random seeds set and documented
- No console errors or warnings
Phase 4: Ship It
-
Create Commit
git add <relevant files>
git status
git diff --staged
git commit -m "$(cat <<'EOF'
feat(estimation): description of what and why
Brief explanation if needed.
Co-Authored-By: Claude <noreply@anthropic.com>
EOF
)"
-
Create Pull Request
git push -u origin <branch-name>
gh pr create --title "feat(estimation): [Description]" --body "$(cat <<'EOF'
## Summary
- What was implemented
- Methodological approach and key decisions
- Estimation results summary (if applicable)
## Estimation Quality
- Convergence: [status]
- Diagnostics: [first-stage F, overid test, specification tests]
- Robustness: [alternative specifications checked]
## Testing
- Tests added/modified
- Estimation verified with [approach]
## Reproducibility
- Random seeds: [set/documented]
- Pipeline: [runs end-to-end / specific steps]
- Dependencies: [pinned in requirements.txt/renv.lock]
## Research Impact
- Identification: [any changes to assumptions]
- Estimation: [computational cost, convergence]
- Robustness: [new checks added/updated]
- Replication: [package changes]
EOF
)"
-
Update Plan Status
If the input document has YAML frontmatter with a status field, update it:
status: active โ status: completed
-
Summary
- Display what was completed
- Link to PR
- Summarize estimation results if applicable
- Note any follow-up work needed (additional robustness checks, referee suggestions)
Phase 5: Handoff
Pipeline mode (when invoked from /lfg or /slfg):
- Skip the interactive menu
- Auto-invoke
/workflows:review on the files that were changed
Standalone mode (when invoked directly by the user):
- After the Phase 4 summary, present options:
- Proceed to review (Recommended) โ Immediately run
/workflows:review in this session
- Continue working โ Return to Phase 2 task loop for additional implementation
- End session โ Stop here; changes are committed
Swarm Mode (Optional)
For complex plans with multiple independent workstreams, enable swarm mode for parallel execution.
When to Use Swarm Mode
| Use Swarm Mode when... | Use Standard Mode when... |
|---|
| Plan has independent estimation specifications | Single estimation pipeline |
| Multiple robustness checks can run in parallel | Sequential estimation steps |
| Monte Carlo with independent DGP variants | Simple parameter change |
| Large replication package with separable components | Small feature or bug fix |
Enabling Swarm Mode
To trigger swarm execution, say:
"Make a Task list and launch an army of agent swarm subagents to build the plan"
See references/orchestration-patterns.md in the slfg skill for detailed swarm patterns and best practices.
Key Principles
Start Fast, Execute Methodically
- Read the plan, set up environment, then execute
- Don't wait for perfect understanding โ resolve ambiguity by picking conservative defaults
- The goal is to finish the implementation with verified estimation quality
The Plan is Your Guide
- Plans reference existing code, methods papers, and brainstorm decisions โ load those references
- Follow the plan's phase structure and acceptance criteria
- Don't reinvent โ match existing patterns in the codebase
Test Estimation Quality Continuously
- Verify convergence after each estimation step, not at the end
- Check diagnostics as you go โ fix issues immediately
- Continuous quality checking prevents late-stage surprises
Quality is Built In
- Follow existing patterns
- Write tests for new code
- Verify estimation convergence and diagnostics
- Run linting before pushing
- Use reviewer agents for complex or risky estimation changes only
Ship Complete, Reproducible Research
- Mark all tasks completed before moving on
- Don't leave estimation code 80% done โ partial results are worse than no results
- A finished, reproducible implementation ships; a perfect but incomplete one doesn't
- Seeds set, dependencies pinned, pipeline runs end-to-end
Quality Checklist
Before creating PR, verify:
Common Pitfalls to Avoid
- Skipping convergence checks โ verify estimation converged, don't assume it did
- Wrong standard errors โ check clustering level, robustness to heteroskedasticity, bootstrap if needed
- Missing seeds โ set random seeds BEFORE any stochastic computation
- Ignoring plan references โ the plan has code paths and method citations for a reason
- Testing at the end โ test continuously or discover convergence failures too late
- 80% done syndrome โ finish the estimation, run diagnostics, compute standard errors
- Hardcoded paths โ use relative paths, check data directory structure
Routes To
/workflows:review โ review the implementation
/workflows:compound โ document solutions discovered during implementation