baba agents¶
Adaptive context-fencing compiler, token budget auditor, and modular skills generator for AI coding agents.
🚀 Synopsis¶
Command Aliases¶
baba agents guarantees strict behavioral parity across all aliases:
baba agents— Short CLI entry pointbbyg agents— Baba-Yaga aliasmatryoshka agents— Canonical package name
📖 Description¶
The agents command suite eliminates the "AI-Slop" and context bloat crisis. Monolithic 500-line prompt files waste expensive API tokens and dilute model attention, leading to hallucinations and poor adherence to guidelines.
Matryoshka solves this by enforcing adaptive context-fencing:
- An ultra-lean root
AGENTS.mdstrictly bounded under 200 tokens (hard limit: 250 tokens). - Modular, specialized skills housed in
.agents/skills/loaded only on demand using mandatory YAML frontmatter. - Non-negotiable software engineering invariants rooted in YAGNI and DRY.
🛠️ Subcommands¶
1. baba agents generate¶
Compile the root AGENTS.md directive boundary and modular skills tailored to the detected repository archetype.
Options:¶
--interactive, -i— Launch interactive terminal UI to review stack and select skills. In headless environments, automatically falls back to deterministic batch mode.--yes, -y— Bypass interactive prompts and apply recommended defaults non-interactively.--force, -f— Overwrite existingAGENTS.md. Automatically creates anAGENTS.md.bakbackup to prevent loss of custom instructions.--dry-run— Preview planned generation and token savings without writing files to disk.--json— Output result as structured JSON.
2. baba agents profile¶
Inspect repository structure and output archetype governance classification.
Discovers architectural seams (routes, controllers, models, services) and classifies projects into:
api_backendopinionated_monolithreactive_frontendsystems_microservicefullstack_hybrid
3. baba agents check¶
Audit the token budget of the active AGENTS.md to prevent prompt bloat.
Options:¶
--max-tokens <num>— Maximum token threshold for compliance (defaults to250).--json— Emit token metrics and pass/fail status as JSON.
4. baba agents skill <name>¶
Render and inspect the compiled content of a specific on-demand skill.
Available Skill Names:¶
backend— ORM query optimization, anti-N+1 strategies, and routing conventions.frontend— Core Web Vitals, CLS prevention, image sizing, and semantic accessibility.database— Migration safety, non-blocking indexing (CONCURRENTLY), and transaction boundaries.security— OWASP Top 10 mitigation, parameter sanitization, and secret prevention.testing— The Seam Contract, Red-to-Green TDD discipline, and assertion verification.
🛡️ Modular Skills & Mandatory YAML Frontmatter¶
Skills generated in .agents/skills/ are guarded by strict YAML frontmatter metadata so agents only load them when working on corresponding file globs:
---
name: backend
description: Framework-specific database queries, ORM patterns, and routing guidelines
globs:
- "src/api/**"
- "src/services/**"
alwaysApply: false
---
# Backend Engineering Directives
...
📋 Examples¶
Simulating Generation (Dry Run)¶
Preview generated files and token consumption without modifying disk:
Overwriting with Safe Backup Guardrail¶
Regenerate instructions while preserving previous configuration in AGENTS.md.bak:
Checking Token Compliance in CI¶
Validate that root instructions stay under the 250-token threshold:
Profiling Archetype Governance¶
Inspect detected archetype and architectural boundaries:
Output:
{
"status": "success",
"command": "agents:profile",
"archetype": "api_backend",
"seams": [
"routes",
"controllers",
"models"
],
"governance": {
"principles": [
"YAGNI",
"DRY"
]
}
}
🔄 Non-Destructive Legacy Migration (baba agents migrate)¶
The baba agents migrate command safely migrates pre-existing monolithic instruction files into modular skills.
Zero-Loss Guarantee:¶
- Byte-for-byte Backup: Snapshots original file to
AGENTS.md.bak. - Domain Extraction: Extracts customized business rules into
.agents/skills/<project-name>/SKILL.md. - Lean Root Index: Compiles an ultra-lean root
AGENTS.md(< 200 tokens) referencing the project custom skill.