Guide to using the modular-builder AI agent for generating module scaffolding.
modular-builder is an AI agent that generates module scaffold code based on specifications. It helps you:
- Generate initial module structure
- Create pyproject.toml with correct entry points
- Scaffold test files
- Generate basic README documentation
Important: modular-builder generates starting points, not production code. Always review and test.
Use modular-builder when:
- Starting a new module from scratch
- Unsure about entry point configuration
- Want to quickly prototype an idea
- Need boilerplate for a standard pattern
Write manually when:
- Complex custom logic required
- Integrating with existing code
- Performance-critical implementation
- Specialized error handling needed
Create a YAML specification:
# module-spec.yaml
name: myfeature
type: tool
description: Convert text to various formats
author: Your Name
functions:
- name: to_uppercase
description: Convert text to uppercase
parameters:
text:
type: string
description: The text to convert
returns:
type: string
description: The uppercased text
- name: to_lowercase
description: Convert text to lowercase
parameters:
text:
type: string
description: The text to convert
returns:
type: string
description: The lowercased text
config:
strict_mode:
type: boolean
default: false
description: Raise errors on invalid input
dependencies:
- amplifier-foundation>=0.1.0
test_coverage: 85# Generate module
modular-builder generate --spec module-spec.yaml --output ./amplifier-module-tool-myfeature
# With custom template
modular-builder generate --spec module-spec.yaml --template advanced --output ./my-module
# Dry run (show what would be generated)
modular-builder generate --spec module-spec.yaml --dry-runmodular-builder creates:
amplifier-module-tool-myfeature/
├── amplifier_module_tool_myfeature/
│ ├── __init__.py # mount() and get_schema()
│ ├── _internal.py # Implementation stubs
│ └── py.typed
├── tests/
│ ├── conftest.py # Test fixtures
│ └── test_unit.py # Test stubs
├── pyproject.toml # Complete with entry points
├── README.md # Generated documentation
└── .gitignore
After generation:
cd amplifier-module-tool-myfeature
# Check structure
tree .
# Read generated code
cat amplifier_module_tool_myfeature/__init__.pyuv venv
uv pip install -e ".[dev]"uv run pytestexport AMPLIFIER_MODULE_TOOL_MYFEATURE=$(pwd)
python -c "
from amplifier_foundation import load_bundle
import asyncio
asyncio.run(load_bundle('./test_profile.md'))
"# Ensure README matches implementation
cat README.mdIf generated code isn't right:
# Add new function
functions:
- name: to_titlecase
description: Convert to title case
# ...# Regenerate (will prompt before overwriting)
modular-builder generate --spec module-spec.yaml --output ./amplifier-module-tool-myfeature
# Force overwrite
modular-builder generate --spec module-spec.yaml --output ./amplifier-module-tool-myfeature --force# Generate to temp directory
modular-builder generate --spec module-spec.yaml --output ./temp-module
# Review changes
diff -r ./amplifier-module-tool-myfeature ./temp-module
# Merge manually
# Copy desired files from temp-module# Start simple
name: myfeature
type: tool
description: Does one thing
functions:
- name: do_thing
# ...Don't try to get the spec perfect on first try. Generate, review, adjust.
Generated code may have:
- Missing error handling
- Inefficient algorithms
- Missing edge cases
- Incomplete documentation
Generated test stubs are minimal. Add comprehensive tests.
Generated README is basic. Enhance with:
- Real usage examples
- Complete API documentation
- Configuration details
- Generate scaffold with modular-builder
- Implement core logic manually
- Regenerate docs/tests with updated spec
- Merge manually
# Generate minimal boilerplate
modular-builder generate --spec minimal-spec.yaml --template minimal
# Then write all logic manuallyProblem: Module not found by amplifier
Solution: Check pyproject.toml:
[project.entry-points."amplifier.tools"]
myfeature = "amplifier_module_tool_myfeature:mount"Problem: Cannot import module
Solution: Install in editable mode:
uv pip install -e .Problem: Generated tests don't match implementation
Solution: Review and update tests manually.
For complete examples, see EXAMPLES.md. For manual development, see DEVELOPMENT_WORKFLOW.md.