bastion/output-validator
Skill8 starsChanged 4 months agoMITView on GitHub
Automatic output validation for Bastion skills. Generates JSON Schema Draft 7 from ## Output Example sections in SKILL.md files and validates LLM outputs against those schemas at runtime. Tracks validation metrics and detects drift.
In this repository17 other files it gives its agents.
- bastion/agentskills-installSkill
- bastion/agentskills-publishSkill
- bastion/calendarSkill
- bastion-pet-packSkill
- bastion/channel-scaffoldSkill
- bastion/crisis-modeSkill
- bastion/life-logSkill
- mcporterSkill
- bastion/mesh-connectSkill
- bastion/mobile-connectSkill
- bastion/onboardingSkill
- bastion/persona-engineSkill
- bastion/proactive-engineSkill
- bastion/self-improvingSkill
- bastion/skill-writerSkill
- bastion/weekly-reviewSkill
- bastion/weight-systemSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 0 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 129
Check that your SKILL.md has a ## Output Example section with a valid JSON block.
- Very specific: line 133
Run python -m output_validator.cli regenerate skill-name to regenerate the schema.
- Very specific: line 134
Check skills/skill-name/schema.json — you can manually adjust constraints.
- Very specific: line 138
Check recent errors: python -m output_validator.cli stats skill-name
- Very specific: line 142
Default limit is 1 MB. For larger outputs, instantiate AutoValidator directly:
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Skill: bastion/output-validator
Overview
The output-validator automatically validates structured LLM outputs against JSON Schema Draft 7. It generates schemas from examples defined in SKILL.md files — zero manual schema writing required.
Key features:
- Auto-generates schemas from
## Output Examplesections in SKILL.md - Validates outputs at runtime with detailed error messages
- Tracks success rates per skill and detects drift below 90%
- CLI for manual validation, schema regeneration, and stats
Installation
The skill is bundled with Bastion. No extra installation needed.
Dependencies (already in the Bastion environment):
jsonschema>=4.0.0click>=8.0.0hypothesis>=6.0.0(for tests only)
Usage
Python API
from output_validator import validate_skill_output
# Validate a skill output (schema auto-generated on first call)
result = validate_skill_output("life-log", output)
if not result.is_valid:
logger.error("Validation failed: %s", result.errors)
# Disable metrics tracking
result = validate_skill_output("life-log", output, track_metrics=False)CLI
# Validate an output file
python -m output_validator.cli validate life-log output.json
# Regenerate schema from SKILL.md
python -m output_validator.cli regenerate life-log
# Show validation stats
python -m output_validator.cli stats
python -m output_validator.cli stats life-log
# Show dashboard (all skills, colour-coded)
python -m output_validator.cli dashboardHow to Add Validation to an Existing Skill
Step 1 — Add ## Output Example to SKILL.md
## Output Example
```json
{
"entry": "Had a productive morning working on the API.",
"mood": "good",
"tags": ["work", "api"],
"timestamp": "2024-01-15T10:30:00Z"
}
### Step 2 — Add validation call in your skill code
```python
from output_validator import validate_skill_output
# After getting LLM output:
result = validate_skill_output("your-skill-name", llm_output)
if not result.is_valid:
logger.warning("Output validation failed: %s", result.errors)
# Handle gracefully — don't crash the skillStep 3 — First run generates the schema automatically
On the first call, schema.json is created in skills/your-skill-name/.
You can inspect and manually adjust it if needed.
ValidationResult
@dataclass
class ValidationResult:
is_valid: bool # True if output conforms to schema
errors: List[str] # Validation error messages
warnings: List[str] # Non-fatal warnings
schema_generated: bool # True if schema was just generated
schema_path: Optional[Path] # Path to schema.json usedTroubleshooting
Schema not generated / "no ## Output Example"
- Check that your SKILL.md has a
## Output Examplesection with a valid JSON block. - The JSON block must use triple backticks with
jsonlanguage tag.
Validation fails unexpectedly
- Run
python -m output_validator.cli regenerate skill-nameto regenerate the schema. - Check
skills/skill-name/schema.json— you can manually adjust constraints.
Drift warning in logs
- Success rate dropped below 90% in the last 100 validations.
- Check recent errors:
python -m output_validator.cli stats skill-name - The LLM may be generating outputs that don't match the expected schema.
Output too large error
- Default limit is 1 MB. For larger outputs, instantiate
AutoValidatordirectly:from output_validator.auto_validator import AutoValidator validator = AutoValidator(Path("skills"), max_output_bytes=5 * 1024 * 1024)
Output Example
{
"skill": "output-validator",
"version": "1.0.0",
"status": "healthy",
"total_skills_tracked": 3,
"skills_with_drift": []
}Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

