Implement
Create an isolated git worktree and execute a work package implementation.
What It Does
The implement phase:
- Creates a git worktree with dedicated branch for isolation
- Loads the WP prompt file with instructions and requirements
- Tracks subtask completion as you check them off
- Validates governance at completion (tests pass, files match scope)
- Marks ready for review when implementation is complete
Quick Usage
agileplus implement WP01Output:
Setting up WP01: Email Models...
✓ Created worktree at .worktrees/001-email-notifications-WP01
✓ Checked out branch: feat/001-email-notifications-WP01
✓ Loaded prompt: WP01-email-models.md
Your task:
Create Email, EmailPreference, and EmailTemplate data models
Subtasks (from WP01-email-models.md):
[ ] Create Email struct with all fields
[ ] Implement EmailStatus enum
[ ] Add sqlx FromRow implementations
[ ] Write unit tests
[ ] Verify database integration
Start implementing:
cd .worktrees/001-email-notifications-WP01
# ... write code ...
agileplus move WP01 --to for_reviewWorktree Isolation
Each work package gets its own isolated git worktree:
.worktrees/
├── 001-email-notifications-WP01/
│ ├── src/ # Full project copy
│ ├── tests/
│ ├── Cargo.toml
│ └── .git # Dedicated git repo
├── 001-email-notifications-WP02/
│ └── ...
└── 001-email-notifications-WP03/
└── ...Benefits of isolation:
- ✓ No conflicts between parallel implementations
- ✓ Each WP has clean diff against main
- ✓ Independent branch per WP
- ✓ Easy cleanup after merge
- ✓ Allows safe parallel work on same codebase
Structure:
.worktrees/001-feature-WP01/
├── .git/ # Worktree-specific repo
├── src/ # Full source copy
│ └── models/
│ └── email.rs # You implement here
├── tests/
├── Cargo.toml
├── Cargo.lock
└── [all project files]Implementation Workflow
Step-by-Step Implementation
1. Start the Work Package
agileplus implement WP01This:
- Creates worktree at
.worktrees/001-feature-WP01 - Checks out dedicated branch
feat/001-feature-WP01 - Loads the WP prompt file
- Marks WP status as
doing
2. Navigate to Worktree
cd .worktrees/001-email-notifications-WP013. Read the Prompt
# View the WP instructions
cat ../../kitty-specs/001-email-notifications/tasks/WP01-database.mdExample prompt:
# WP01: Database Schema
## Your Task
Create database migrations for email tables.
## Subtasks
- [ ] Create 001_email_schema.sql (up migration)
- [ ] Create 001_email_schema.down.sql (down migration)
- [ ] Define email table with proper indexes
- [ ] Define email_preference table with constraints
- [ ] Test migration up/down cycle
## Deliverables
- src/db/migrations/001_email_schema.sql
- src/db/migrations/001_email_schema.down.sql
## Acceptance Criteria
- [ ] Both migrations run without errors
- [ ] Migrations are reversible
- [ ] Tables have proper indexes and constraints4. Implement
Write code according to the prompt:
# Example: create database migration
mkdir -p src/db/migrations
cat > src/db/migrations/001_email_schema.sql << 'EOF'
CREATE TABLE emails (
id BIGINT PRIMARY KEY AUTO_INCREMENT,
user_id BIGINT NOT NULL,
event_type VARCHAR(50) NOT NULL,
recipient VARCHAR(255) NOT NULL,
subject TEXT NOT NULL,
body LONGTEXT NOT NULL,
status VARCHAR(20) NOT NULL DEFAULT 'pending',
attempts INT DEFAULT 0,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
sent_at TIMESTAMP NULL,
bounced_at TIMESTAMP NULL,
FOREIGN KEY (user_id) REFERENCES users(id),
INDEX idx_user_status (user_id, status),
INDEX idx_created (created_at)
);
CREATE TABLE email_preferences (
id BIGINT PRIMARY KEY AUTO_INCREMENT,
user_id BIGINT NOT NULL,
category VARCHAR(50) NOT NULL,
enabled BOOLEAN DEFAULT true,
unsubscribe_token VARCHAR(255) UNIQUE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(id),
UNIQUE KEY idx_user_category (user_id, category)
);
EOF5. Run Tests
Ensure your implementation works:
# Run project tests
cargo test
# Run tests in isolation
cargo test --test email_integration
# Run with logging
RUST_LOG=debug cargo test -- --nocaptureExample test:
#[tokio::test]
async fn test_email_model() {
let email = Email {
user_id: 1,
recipient: "test@example.com".to_string(),
status: EmailStatus::Pending,
..Default::default()
};
assert_eq!(email.status, EmailStatus::Pending);
assert!(email.recipient.contains("@"));
}6. Commit Your Work
# Stage all changes
git add -A
# Commit with clear message (reference WP)
git commit -m "feat(WP01): create email database schema
- Add emails table with indexes
- Add email_preferences table with constraints
- Create up and down migrations
Implements: WP01-database
Spec: 001-email-notifications"Commit message format:
feat(WP01): short description
- Detailed point 1
- Detailed point 2
- Detailed point 3
Implements: WP01-{name}
Spec: 001-{feature}7. Verify Completion
Before moving to review, verify:
# Ensure all tests pass
cargo test --all
# Check git status (should be clean)
git status
# View your commits
git log --oneline main..HEAD
# Verify deliverables exist
ls -la src/db/migrations/001_email*8. Mark Complete
When all subtasks are done:
agileplus move WP01 --to for_reviewOutput:
✓ WP01: Database Schema
Status: for_review
Commits: 1
Files changed: 2
Ready for code review:
agileplus review WP01
Dependent WPs waiting on this:
- WP02: Email Models (blocked)This:
- Moves WP from
doing→for_review - Marks ready for code review
- Unblocks dependent WPs (they can start planning)
Worktree Commands
Create a Worktree
agileplus implement WP01
# Creates .worktrees/001-feature-WP01Switch Between Worktrees
# Go to WP02's worktree
cd .worktrees/001-feature-WP02
git status
# Go to main project
cd ../..
git statusRemove a Worktree
Usually automatic after merge, but manual cleanup:
# Remove WP01's worktree
rm -rf .worktrees/001-feature-WP01
# Or let merge command handle it
agileplus merge 001 # Cleans up all WP worktreesCommon Patterns
Pattern 1: Implement with Agent
Auto-dispatch to Claude:
agileplus implement WP01 --agent claude-codeClaude receives:
- WP prompt
- Spec and plan context
- File paths to modify
- Expected deliverables
Pattern 2: Implement Locally
agileplus implement WP01
cd .worktrees/001-feature-WP01
# ... your implementation ...
git commit -m "feat(WP01): ..."
agileplus move WP01 --to for_reviewPattern 3: Parallel Implementation
Multiple developers work in parallel:
# Developer A
agileplus implement WP01
cd .worktrees/001-feature-WP01
# ... implement ...
# Developer B (different terminal/machine)
agileplus implement WP02
cd .worktrees/001-feature-WP02
# ... implement ...
# Both commit independently
# Reviews happen in parallelTroubleshooting
Worktree Creation Failed
# Check git status
git status
# Ensure clean state
git stash
# Retry
agileplus implement WP01 --forceTests Failing
# Run tests with more detail
cargo test -- --nocapture --test-threads=1
# Check recent changes
git diff main
# Revert specific file if needed
git checkout <file>Merge Conflicts (During Implementation)
If main branch changed while you were working:
# Update worktree from main
git fetch origin
git rebase origin/main
# Resolve conflicts
git status # Shows conflicts
# Edit conflicted files
git add .
git rebase --continue
# Continue implementationForgot to Commit
# Check what's staged
git status
# Stage all changes
git add -A
# Commit
git commit -m "feat(WP01): ..."Want to Reset
If things went wrong:
# Discard all changes (dangerous!)
git reset --hard main
# Or discard just one file
git checkout main -- <file>
# Start over if needed
cd ../..
agileplus implement WP01 --forceBest Practices
1. Small Commits
# Good: Multiple commits for logical chunks
git commit -m "feat(WP01): create email model"
git commit -m "feat(WP01): add database fields"
git commit -m "feat(WP01): implement validation"
# Avoid: One giant commit
git commit -m "feat(WP01): do everything"2. Meaningful Messages
# Good
feat(WP01): create Email model with validation
- Add Email struct with id, recipient, subject, body
- Implement EmailStatus enum (pending, sent, failed)
- Add validation for email addresses
- Write unit tests for Email model
# Avoid
feat: stuff3. Regular Testing
# Test after each logical chunk
cargo test
cargo clippy # Check for warnings4. Sync with Dependencies
If your WP depends on another WP:
# Check if dependent WP is done
agileplus show 001 --dependencies
# If yes, your blocker is resolved
# Start implementation5. Follow Subtasks
The WP prompt has subtasks. Check them off:
# View prompt
cat ../../kitty-specs/001-feature/tasks/WP01-*.md
# As you implement, follow the subtasks
# When all are done, move to reviewNext Steps
After implementation:
# Move to review
agileplus move WP01 --to for_review
# Reviewer checks the work
agileplus review WP01
# If approved:
agileplus move WP01 --to doneThis unblocks dependent WPs.
Related Documentation
- Tasks — Work package generation
- Review — Code quality review
- Merge — Integration to main
- Core Workflow — Full pipeline overview