🌏 日本語版も利用可能: Japanese documentation is available here (日本語ドキュメントはこちら)
A guide to building agent systems using Claude Code as a natural language interpreter.
This guide presents Natural Language Macro Programming that executes structured tasks using natural language as macro code, with LLM as interpreter.
While conventional programming requires computers to interpret programming languages with specific syntax, natural language macro programming enables:
- Natural language and Markdown notation as program descriptions
- Claude Code functioning as an interpreter that parses and executes these descriptions
- Advanced control structures (Task tool, TODO tool, variable management, conditional branching, parallel execution) realized through natural language
- Agent systems for automating and optimizing complex tasks
You can design agent behaviors using intuitive natural language and have Claude Code execute them.
Natural language macro programming provides high explainability, which is crucial for responsible AI development. The natural language descriptions make processing steps human-readable, ensuring execution transparency, auditability, and debuggability, thereby facilitating system verification and traceability.
Try variable storage and reference:
Store in variable:
"Create 3 haiku poems about spring and save to {{haiku}}"
Reference variable:
"Select the most beautiful one from {{haiku}} and refine it"
Execute these directly in Claude Code to experience natural language macro programming. (Note: CLAUDE.md macro definition is required)
The core of natural language macro programming consists of 10 design patterns, systematically organized into 4 Basic Patterns and 6 Advanced Patterns.
📋 Basic 4 Patterns - macro.md
- Pattern 1: Sequential Pipeline - Basic execution pattern that processes tasks sequentially, passing results from one stage to the next
- Pattern 2: Parallel Processing - Parallel execution pattern that runs multiple tasks simultaneously for efficient processing
- Pattern 3: Conditional Execution - Conditional branching pattern that selects different processing paths based on situations
- Pattern 4: Loop & Modular Programming - Efficient repetitive control through TODO-list based iteration and Few-shot Pattern Loop
🚀 Advanced 6 Patterns - macro.md
- Pattern 5: Problem Solving & Recursion - Recursive approach that breaks down complex problems step by step and solves them through TODO management
- Pattern 6: Learning from Experience - Experience learning pattern that learns from past execution results and generates improvement suggestions
- Pattern 7: Environment Sensing, Knowledge-base & Environment Model - Acquires external environment information, builds knowledge systems, and executes adaptive processing according to situations
- Pattern 8: Human-in-the-Loop - Collaborative execution pattern that incorporates human judgment at appropriate timings
- Pattern 9: Error Handling - Robustness improvement pattern that predicts errors and executes appropriate recovery processing
- Pattern 10: Debug & Tracing - Development support pattern that visualizes execution status and assists in problem identification and resolution
Structure: Combine Pattern 1-4 (Basic Patterns) and Pattern 5-10 (Advanced Patterns), along with Appendix (Specialized Technologies) to build practical systems.
Integration Effects: By combining multiple patterns, collaborative systems like the A.4 Haiku Generation Multi-Agent can be constructed.
📖 Appendix (Advanced Technologies) - Appendix.md
- A.1: Event-Driven Execution - Asynchronous processing and real-time response systems
- A.2: Four-Layer Defense Strategy - Four-layer defense strategies for reliable operations
- A.3: Python Tool Integration - Python ecosystem utilization via SQLite variable management integration
- A.4: Multi-Agent System Design - Collaborative agent systems with shared blackboard model (includes haiku generation multi-agent implementation example)
- A.5: Audit Log System - Transparency and accountability tracking via SQLite variable management extension
- A.6: LLM-based Pre-execution Inspection - LLM-powered pre-execution static analysis for security and quality assurance
- A.7: Metaprogramming - Self-adaptive systems through dynamic macro generation, verification, evaluation, and improvement
- A.8: Ensemble Execution and Consensus Formation - Statistical countermeasures for probabilistic behavior
- A.9: Type Safety and Schema Management - Gradual type safety enhancement and schema-based systematic data management
- A.10: LLM-based Post-execution Evaluation - Quality, creativity, and logic evaluation for probabilistic systems
- A.11: Variable Management Persistence and Scaling - Robust state management via databases
- A.12: Vector Database and RAG Utilization - Dynamic knowledge systems through knowledge bases and experience learning
- A.13: Goal-Oriented Architecture and Autonomous Planning - Complete autonomous systems via 4-stage flow and PDCA cycle
- A.14: Python Orchestration-Based Hybrid Approach - High-speed, cost-efficient systems via Python + natural language macros
- A.15: SQLite-Based Variable Management - Robust variable management system with SQLite database, enhanced performance
- A.16: Macro Auto-Generation by Coding Agents - Automatic conversion methods from declarative specifications to procedural macros with design pattern utilization
- macro.md - Main guide (10 design patterns + appendix references)
- Appendix.md - Appendix (advanced technical elements and methodologies)
- examples/ - Pattern-specific example collection
- multi-haiku/ - Multi-agent haiku generation system (SQLite-based implementation example)
- SQLite/ - SQLite-based variable management system implementation code and tools
- haiku_direct.md - Practical example (haiku generation system)
- CLAUDE.md - Macro definition file
- debugger.md - Debug mode specification
- Technical questions, bug reports: GitHub Issues
- Academic inquiries: wadayama@nitech.ac.jp
MIT License - see LICENSE for details.
- Tadashi Wadayama - Project design and documentation
Last Updated: 2025-07-27
Author: Tadashi Wadayama (with assistance from Claude Code)
License: MIT License (2025)