AI-COMPANY-CTO-AgentFactory
When to Use
- Create new AI Agents (any layer: tool/execution/management/decision)
- Generate standardized Agent position briefs (five elements)
- Design Agent architectures following Harness Engineering principles
- Batch-generate four-layer architecture Agent teams
Core Rules
- Must specify agent layer — choose from tool/execution/management/decision
- Must include five elements — role, objective, behavior rules, tool permissions, error handling
- File names in kebab-case — e.g.,
content-writer-agent - Configuration in YAML — structured, readable, verifiable
- Quality gates required after generation — 4 gates (schema/lint/security/integration)
Quick Reference
| File | Purpose |
|---|---|
templates/*-layer.md |
Four-layer templates (Tool/Execution/Management/Decision) |
scripts/generate_agent.py |
Main agent generation script |
scripts/validate_agent.py |
Quality gate validation script |
references/*.md |
Harness Engineering, quality gates, security compliance |
Usage
# Generate an agent
python scripts/generate_agent.py --config ./agent-config.yaml --output ./agents/
# Validate quality gates
python scripts/validate_agent.py --agent-dir ./agents/my-agent/
# Dry-run (validate only, no file generation)
python scripts/generate_agent.py --config ./agent-config.yaml --dry-run
# Output JSON report
python scripts/validate_agent.py --agent-dir ./agents/my-agent/ --json --output report.json
Example: agent-config.yaml
agent:
layer: execution
name: content-writer-agent
role: Content creation executor
description: Generates copy/articles/social posts.
objective_kpi:
metric: quality_score
target: ">=4.5/5"
measurement: Human sampling evaluation
behavior_rules:
must_do:
- Cite authoritative sources
- Check factual accuracy
must_not_do:
- Generate misinformation
- Disclose user privacy
tool_permissions:
- skill: online-search
access: read
- skill: docx
access: write
error_handling:
retry_policy: 3x
fallback_skill: general-knowledge
Four-Layer Architecture
| Layer | Responsibility | Key Attributes |
|---|---|---|
| Tool | Atomic capability | Stateless, idempotent, reusable |
| Execution | Task execution | Single responsibility, bound to Skills |
| Management | Task orchestration | State machine, error recovery |
| Decision | Strategic decisions | Data-driven, authoritative citations |
Quality Gates
| Gate | ID | Check | Threshold | Blocking |
|---|---|---|---|---|
| Schema Validation | G1 | Required fields & YAML | 100% coverage | Yes |
| Lint Check | G2 | Markdown & file structure | 0 errors | Yes |
| Security Scan | G3 | Forbidden patterns | 0 Critical/High | Yes |
| Integration Test | G4 | Test coverage | Pass rate >= 95% | Yes |
| Layer Validation | G5 | Layer requirements | All met | Yes |
CQO G2 Quality Gate — Lint Check Specification
The G2 Lint Check gate enforces:
- Markdown structure: All required sections present (Overview, Capabilities, Usage, API)
- File naming: kebab-case enforced for all generated files
- YAML validity: Valid YAML syntax with proper indentation
- Link integrity: No broken internal references
- Line count: SKILL.md must be under 500 lines
Blocking: Any lint error blocks agent deployment.
Security Scanner — Forbidden Patterns
The scanner flags these patterns (blocking on detection):
| Pattern | Description |
|---|---|
eval() |
Dynamic code execution |
exec() |
Dynamic code execution |
__import__(..system) |
System call via import |
subprocess.(call/run/Popen) |
Subprocess spawning |
pickle.loads |
Unsafe deserialization |
yaml.load (without SafeLoader) |
Unsafe YAML parsing |
| 40+ char base64-like strings | Potential hardcoded keys |
Note: The scanner legitimately uses
eval()andexec()only inside tests (tests/test_factory.py) to verify it correctly detects these patterns. The actual production scripts use only safe APIs (yaml.safe_load,jinja2.sandbox.SandboxedEnvironment).
CISO STRIDE Mitigations
This skill implements security controls against STRIDE threats:
| Threat | Mitigation |
|---|---|
| Spoofing | Agent config requires verified role definitions; YAML schema validates source identity |
| Tampering | Security scanner blocks dangerous patterns; Jinja2 sandbox prevents template injection |
| Repudiation | Audit logs generated for all agent creations; integration tests verify logging |
| Information Disclosure | Network permission set to false; no credentials in generated output |
| Denial of Service | Idempotent design prevents infinite loops; retry policies bounded |
| Elevation of Privilege | Tool permissions explicitly scoped; execute_scripts requires explicit config |
All generated agents inherit these security boundaries.
Harness Engineering — L1-L4 Layers
| Layer | Name | Description |
|---|---|---|
| L1 | Tool Layer | Atomic, stateless, idempotent capabilities (e.g., file read, web search) |
| L2 | Execution Layer | Single-responsibility task executors bound to specific Skills |
| L3 | Management Layer | Orchestration with state machine, error recovery, retry logic |
| L4 | Decision Layer | Strategic C-Suite agents with authority, compliance, audit logging |
The AgentFactory generates agents for any layer using standardized templates and validates layer-specific requirements through G5 gate.
Module Guide
Module 1: Agent Configuration & Schema
Define agent specifications in YAML. Required fields:
agent.layer,agent.name(kebab-case),agent.roleobjective_kpi(metric/target/measurement)behavior_rules(must_do / must_not_do lists)tool_permissions(skill + access level)error_handling(retry_policy / fallback_skill)
Module 2: Template Rendering
Uses Jinja2 SandboxedEnvironment for safe template rendering. Four layer templates are loaded from templates/:
tool-layer.md— stateless, idempotent atomic unitsexecution-layer.md— single-responsibility worker agentsmanagement-layer.md— orchestration with state machinedecision-layer.md— strategic C-Suite agents
Module 3: Quality Gates
Five sequential gates (all blocking by default):
- SchemaValidator — frontmatter + config.yaml structural integrity
- LintChecker — line count, required sections, broken links
- SecurityScanner — regex scan for forbidden patterns
- IntegrationTester — test file existence + real test methods (no bare
pass) - LayerSpecificValidator — layer-keyword presence check
Module 4: Test Generation
Per-layer test templates with actual assertions:
- Tool: schema compliance, stateless/idempotent verification
- Execution: role definition, tool permissions declared
- Management: state machine defined, error recovery paths
- Decision: authority/compliance section, audit logging present
File Structure
ai-company-cto-agentfactory/
├── SKILL.md # This file
├── scripts/
│ ├── generate_agent.py # Main generation script
│ └── validate_agent.py # Quality gate validator
├── templates/
│ ├── tool-layer.md # Tool layer template
│ ├── execution-layer.md # Execution layer template
│ ├── management-layer.md # Management layer template
│ └── decision-layer.md # Decision layer template
├── references/
│ ├── harness-engineering.md
│ ├── quality-gates.md
│ └── security-compliance.md
├── tests/
│ └── test_factory.py # Unit + integration tests
├── requirements.txt # Python dependencies
├── CHANGELOG.md
├── DESIGN-SPEC.md
└── TECHNICAL-REVIEW-REPORT.md
Version History
| Version | Date | Changes |
|---|---|---|
| 1.0.0 | 2026-04-16 | Initial release |
| 1.1.0 | 2026-04-22 | English rewrite; ClawHub Schema v1.0 compliance; execute_scripts:true; install block; saST/Vetter quality block; full four-layer template documentation; security scanner docs; CQO G2 lint gate documented; CISO STRIDE mitigations documented; Harness Engineering L1-L4 layers documented |
