Appendix K: Complete Worked Examples
This appendix contains four complete, end-to-end worked examples, each showing every file, script, and configuration needed to run a specific automation from scratch. Unlike the cookbook which provides flexible recipes, these worked examples are fully specified — ready to copy, adapt, and run. They're the most practical reference in the handbook for practitioners who learn by studying complete implementations rather than assembling fragments.
The four examples cover the most common automation scenarios: a Weekly Intelligence Briefing that researches multiple topics and compiles a digest, an Expense Auto-Logger triggered by receipt photos or text input, a Code Review Assistant that checks changed files against configurable standards, and a Research Pipeline with defined phases from query generation through synthesis to report generation. Each example includes the JSON config files, Python scripts, cron task configurations, and testing procedures.
The Weekly Intelligence Briefing demonstrates multi-topic research aggregation with per-topic JSON config, a Python compilation script, and a cron task that orchestrates web search → web fetch → JSON save → compile → WhatsApp in sequence. The Expense Auto-Logger demonstrates the image-analysis-to-structured-data pattern, JSON file persistence with append, keyword routing in SOUL.md, and monthly summary aggregation. The Code Review Assistant demonstrates pattern-based static analysis across Python and JavaScript, git diff for changed-file detection, severity classification, and conditional alerting based on issue count. The Research Pipeline demonstrates a complete multi-phase workflow with explicit stopping criteria, structured report output format, and metadata tracking.
Each example follows the same structure: problem definition, files to create (with complete content), cron configuration (with complete JSON), and testing procedures. The testing sections show how to create synthetic test data and verify the pipeline works before deploying to production.
Key Items
- **Weekly Intelligence Briefing** — Multi-topic research aggregator with cron at 6am Monday; demonstrates complete pipeline from topic config JSON → web search → web fetch → JSON save → Python compile → WhatsApp digest; includes test data creation and compilation verification
- **Expense Auto-Logger** — Image-based receipt extraction via `image` tool + Python logging; keyword routing in SOUL.md ("log: $X at MERCHANT"); JSON file persistence; monthly summary cron with category breakdown; demonstrates full input → process → store → report flow
- **Code Review Assistant** — Pattern-matching static analysis for Python and JavaScript; regex patterns for critical issues (hardcoded credentials, eval) and high issues (print statements); git diff for changed files since N hours; severity-classified output with conditional WhatsApp alerting
- **Research Pipeline (complete)** — 4-phase workflow: query generation (5-7 diverse searches) → initial research (web search + fetch, top 2 per query) → synthesis (consensus, disputes, gaps) → report generation (executive summary, findings, sources, metadata); explicit stopping criteria; structured markdown output format
Related Concepts
- [[kelly-handbook-appendix-d-cookbook]] for flexible recipes and variations
- [[kelly-handbook-ch3-file-automation]] for file operations in automation scripts
- [[kelly-handbook-ch4-web-automation]] for web research and scraping patterns
- [[karpathy-llm-wiki]] for the LLM wiki pattern this KB follows