Structured file-based planning for Alexandria's complex multi-step tasks. Creates task_plan.md, findings.md, progress.md. REQUIRED for: >5 tool calls, database schema changes, queue architecture, external API integrations, performance optimization, data migration. DO NOT use mcp__pal__planner for file-based implementation tasks.
Priority: PRIMARY tool for all complex implementation tasks
This skill is MANDATORY for:
Use PAL MCP tools instead for:
mcp__pal__debug - Deep debugging of mysterious bugsmcp__pal__codereview - Post-implementation code reviewmcp__pal__secaudit - Security vulnerability scanningmcp__pal__consensus - Multi-model architectural decision validationClear distinction:
Create these in your project root (not in skill directory):
task_plan.md - Implementation Roadmap# Task: [Descriptive Name]
## Goal
[What we're building/fixing and why]
## Context
- Current state: [What exists now]
- Problem: [What needs to change]
- Success criteria: [How we know it's done]
## Implementation Steps
- [ ] Phase 1: Research & Design
- [ ] Explore current codebase
- [ ] Document findings
- [ ] Design approach
- [ ] Phase 2: Core Implementation
- [ ] File 1: [Changes]
- [ ] File 2: [Changes]
- [ ] Phase 3: Testing & Validation
- [ ] Unit tests
- [ ] Integration tests
- [ ] Manual validation
- [ ] Phase 4: Deployment
- [ ] Deploy to production
- [ ] Monitor metrics
- [ ] Validate no regressions
## Risks & Mitigations
| Risk | Impact | Mitigation |
|------|--------|------------|
| Database lock | Production outage | Test migration on staging first |
| ISBNdb quota exhaustion | Failed enrichment | Add quota check before operations |
## Files Modified
- `worker/src/services/enrichment.ts`
- `worker/src/routes/api.ts`
- `worker/wrangler.jsonc`
## Testing Strategy
- Unit: [Specific test cases]
- Integration: [Workflow tests]
- E2E: [Full pipeline validation]
findings.md - Research Journal# Findings: [Task Name]
## Current Implementation Analysis
**Date:** [YYYY-MM-DD HH:MM]
### Architecture
- Current approach: [How it works now]
- Key files: [List with line numbers]
- Dependencies: [What this depends on]
- Performance: [Current metrics]
### Database Schema
```sql
-- Current schema
CREATE TABLE enriched_editions (...);
[YYYY-MM-DD HH:MM] - Discovered ISBNdb batch endpoint
[YYYY-MM-DD HH:MM] - Found Hyperdrive connection pooling issue
[YYYY-MM-DD HH:MM] - Decision: Use lazy backfill strategy
### 3. `progress.md` - Execution Log
```markdown
# Progress: [Task Name]
## Summary
- **Status**: In Progress
- **Started**: 2026-01-11 10:30
- **Last Updated**: 2026-01-11 14:15
- **Completion**: 60%
- **Current Phase**: Phase 2 - Core Implementation
## Completed Work
✅ **Phase 1: Research & Design** (10:30-12:00)
- Explored `worker/src/services/enrichment.ts`
- Documented current provider chain
- Designed new circuit breaker approach
- Created architecture diagrams in findings.md
✅ **Step 2.1: Implement circuit breaker** (12:15-13:30)
- Created `worker/src/middleware/circuit-breaker.ts`
- Added unit tests (8/8 passing)
- Integrated with enrichment service
## Current Work
🔄 **Step 2.2: Update enrichment pipeline** (13:45-present)
- Modifying `enrichment.ts` to use circuit breaker
- Need to test with real ISBNdb API
- Next: Add analytics tracking
## Pending Work
- [ ] Step 2.3: Add provider fallback logic
- [ ] Step 2.4: Update tests
- [ ] Phase 3: Testing & Validation
- [ ] Phase 4: Deployment
## Issues Encountered
| Time | Error | Attempted Fix | Resolution |
|------|-------|---------------|------------|
| 13:50 | ISBNdb 429 (rate limit) | Added circuit breaker | ✅ Circuit opens after 5 failures |
| 14:10 | TypeScript error in tests | Fixed mock types | ✅ All tests passing |
## Next Actions
1. Complete circuit breaker integration
2. Run full test suite (`npm run test`)
3. Deploy to staging for validation
4. Monitor ISBNdb quota usage
## Metrics
- Files modified: 3
- Lines changed: +245 / -87
- Tests added: 12
- Tests passing: 20/20
Trigger: "Add subject_tags column to enriched_works"
Required steps:
Key files:
worker/src/schemas/ - Zod validationworker/src/services/enrichment.ts - Pipeline logicTrigger: "Enrichment queue is backing up"
Required steps:
queue-handlers.tswrangler.jsoncKey files:
worker/src/services/queue-handlers.tsworker/wrangler.jsonc - Queue configworker/src/services/cover-processor.tsTrigger: "Add LibraryThing API support"
Required steps:
docs/operations/RATE-LIMITS.mdKey files:
worker/src/services/external-apis/worker/src/services/normalizers/worker/src/middleware/circuit-breaker.tsComplex Alexandria tasks touch database + queues + external APIs. You will lose track without planning files.
Alexandria's golden rule: Always validate SQL in psql first. Never write Worker code blind.
ssh [email protected] "docker exec postgres psql -U openlibrary -d openlibrary"
Every research session adds to findings.md. Includes:
Alexandria runs on production data (54M+ books). Errors are learning opportunities:
## Errors Encountered
| Error | Root Cause | Fix |
|-------|------------|-----|
| PG timeout (30s) | Missing index on edition_isbns.isbn | CREATE INDEX CONCURRENTLY |
| ISBNdb 402 (quota) | Daily limit exceeded | Added quota tracking via KV |
Before modifying database schema or queue config, re-read task_plan.md. Keeps goals fresh in context.
# Schema migration uses planning-with-files automatically
/schema-migration
↳ Loads postgres-optimizer agent
↳ Creates planning files
↳ Runs db-check.sh validation
# Queue optimization uses planning-with-files automatically
/queue-optimization
↳ Loads cloudflare-workers-optimizer agent
↳ Creates planning files
↳ Profiles current performance
# 1. Use planning-with-files for implementation
# 2. After completion, validate with PAL:
# Code review
mcp__pal__codereview - Check for bugs, patterns, optimization opportunities
# Security audit
mcp__pal__secaudit - Scan for SQL injection, API key exposure, etc.
# Document findings from PAL in findings.md
After 2+ months of production use in BooksTrack:
| ❌ Don't Do This | ✅ Do This Instead |
|---|---|
| Start coding immediately | Create task_plan.md first |
| Use TodoWrite for persistence | Use markdown planning files |
| Skip findings.md | Document every discovery |
| Test Worker code first | Test SQL in psql first |
| Commit planning files | Git-ignore them (session-specific) |
| Use PAL planner for implementation | Use planning-with-files |
| Repeat failed actions | Log errors, mutate approach |
Starter templates are in templates/ subdirectory:
templates/task_plan.md - Full implementation templatetemplates/findings.md - Research journal templatetemplates/progress.md - Execution log templateCopy these to your project root when starting a new task.
# 1. Create planning files (project root)
touch task_plan.md findings.md progress.md
# 2. Start with task_plan.md
# - Define goal and success criteria
# - Break into phases
# - List files to modify
# - Identify risks
# 3. Research phase (update findings.md)
# - Explore codebase
# - Test queries in psql
# - Document current architecture
# 4. Implementation phase (update progress.md)
# - Mark steps complete
# - Log errors
# - Track metrics
# 5. Validation phase
# - Run tests
# - Deploy to staging
# - Monitor production
# 6. (Optional) Post-implementation review
# - mcp__pal__codereview for code quality
# - mcp__pal__secaudit for security
# - Document findings in findings.md
Version: 2.0.2 (Alexandria Optimized) Last Updated: 2026-01-11 Maintained By: Alexandria AI Team Pattern Source: BooksTrack (2+ months production validated)