| name | validate-structure |
| description | Run AST guard validation on a generated agent project and auto-fix violations |
Validate Agent Structure
You are running the final structure validation on a generated agent project.
Prerequisites
- A generated agent project exists (from the generate step)
- The build-my-agent guard is available
Process
Step 1: Run Guard
Execute the guard checker:
python -m guard check <agent-project-path>
Step 2: Handle Results
If all checks pass:
"All structure checks passed. Your agent is ready to use.
Quick start:
cd <component_name>-ops-agent
pip install -e '.[dev]'
python agent.py
python agent.py --once "check error rate"
python agent.py --diagnose --once "why is latency high?"
To add new tools later:
- Create a new file in
tools/ with one public function and a docstring
- Use lazy config loading:
_get_*_config() pattern (see existing tools for reference)
- Add its config section to
config/agent.yaml
- Import and export from
tools/__init__.py
- Register in
agent.py tools list
- Run
python -m guard check . to verify"
If violations found:
For each violation, fix it:
| Violation | Fix |
|---|
| Missing required file | Create the file using the appropriate template |
| File name not snake_case | Rename the file to snake_case |
| Function name not snake_case | Rename the function |
| Multiple public functions | Split into separate tool files, or prefix helpers with _ |
| Missing docstring | Add a descriptive docstring to the function |
| Hardcoded URL | Replace with config loading pattern |
After fixing, re-run the guard:
python -m guard check <agent-project-path>
Repeat until all checks pass.
Step 3: Run Tests
After guard passes, run the project's tests:
cd <agent-project-path>
pip install -e '.[dev]'
python -m pytest tests/ -v
Fix any test failures.
Step 4: Final Report
"Validation complete:
- Guard: all checks passed
- Tests: [pass/fail status]
Your <component_name>-ops-agent is ready for use."