How kbwen/agentic-os works
1. This repository is not an application runtime; it is a governance/control plane for AI coding agents. Its core job is to turn agent instructions into enforceable workflow checks, with Git hooks and CI acting as the real boundary that accepts or rejects claimed progress.
2. The main “product surface” is the prompt-and-workflow layer under .claude/commands, .agents/workflows, .agent/workflows, and the corresponding platform entrypoints in AGENTS.md, CLAUDE.md, GEMINI.md, and .codex/. These files define the lifecycle commands like bootstrap, plan, implement, review, test, ship, and audit.
3. A second major subsystem is the policy/guardrail layer in .agent, .agentcortex, .antigravity, .claude, .codex, and the docs/specs tree. This layer encodes the operating rules, skill attachments, state-machine constraints, and governance doctrine that the agents are expected to follow.
4. The enforcement boundary lives in .agentcortex/tools, .agentcortex/bin, .githooks, and .github/workflows. These scripts and workflows validate evidence, scan credentials, check spec drift, verify audit chains, enforce lock semantics, and ensure the repo’s governance state is internally consistent before changes can land.
5. The system’s durable state is stored in .agentcortex/context. current_state.md acts as a single source of truth for shared project state, while work/<branch>.md holds per-task logs, evidence, and gate receipts. That separation is central: shared state is global, work logs are branch/task-scoped, and both are machine-checked.
6. There is an explicit audit/evidence model. Files in .agentcortex/context/archive, docs/architecture, docs/audit, docs/reviews, and various *_log.md / spec files preserve decisions, reviews, and lifecycle history. Tools such as check_audit_chain.py, check_lesson_chain.py, and verify_agent_evidence.py read those artifacts to detect missing phases or broken provenance.
7. The repo also contains a metadata and lifecycle subsystem under .agentcortex/metadata and .agentcortex/eval. These files define trigger registries, skill provenance, lifecycle baselines, and governance evaluation inputs. They support automated classification and allow the validator to determine what phases and checks are required for a given task type.
8. The skill system is distributed across .agent/skills, .agents/skills, and .agentcortex/docs. Skills are not the gate themselves; they are phase-aware guidance that auto-attaches to tasks. The architecture separates guidance from enforcement: skills tell the agent what to do, while hooks and CI verify that it actually did it.
9. The repository has a cross-platform adapter layer in installers/, demo/, and the shell/PowerShell scripts under .agentcortex/bin and .agentcortex/tools. These are used to deploy the governance bundle into another repo, validate a local setup, or demonstrate gates such as credential scanning without depending on a specific agent vendor or OS.
10. GitHub Actions is the remote enforcement plane. .github/workflows/validate.yml and security.yml run the same kinds of checks used locally, making the CI floor non-optional for merge. The repository’s own tests in tests/, tests/ci/, tests/guard/, and .agentcortex/tests/ verify those contracts, including state-machine rules, credential floors, lock recovery, and lifecycle compliance.
11. The main data flow is: an agent reads a workflow prompt, writes state and work-log evidence, tools validate that evidence against lifecycle rules, and hooks/CI block commits or PRs if required phases, tests, or security checks are missing. In other words, the repo’s architecture is a closed loop of instructions → evidence → validation → allowed merge.
12. The important architectural boundary to diagram is between “agent-facing guidance” and “machine-enforced truth.” Anything in Markdown workflows, skills, or docs is advisory; anything in hooks, validator scripts, audit checks, and CI is authoritative. That separation is the essence of the project.
Main entry points: tools Validator tools · tests Governance tests · rules Core rules · workflows Agent workflows
Components 18
Agent guidance
Workflow prompts, commands, and skills that tell agents what to do.
- Platform entrypoints · Top-level command and agent entry files for Claude, Codex, Gemini, and shared agent instructions.
AGENTS.md - Claude commands · Claude command layer covering bootstrap, plan, implement, review, ship, audit, and related lifecycle steps.
.claude/commands - Agent workflows · Shared workflow definitions used to route lifecycle actions and task-specific execution paths.
.agent/workflows - Skill library · Distributed skill attachments that provide task-aware advice without enforcing outcomes.
.agents/skills
Governance policy
Rules, guardrails, and doctrine that define expected behavior.
- Core rules · Behavioral and state-machine rules for agent execution and conflict resolution.
.agent/rules - Antigravity rules · Additional platform-specific rules governing the agent runtime posture.
.antigravity/rules.md - Codex rules · Codex-specific rules and defaults for the governance bundle.
codex/rules/default.rules - Safety docs · Platform guides and philosophy docs that explain operating constraints and safe usage.
.agentcortex/docs
Enforcement boundary
Hooks, validators, and CI that accept or reject progress.
- Validator tools · Core Python and shell utilities that verify audit chains, spec drift, evidence, and governed writes.
.agentcortex/tools - Git hooks · Pre-commit and related hook entrypoints that block invalid changes before commit.
.githooks - CI workflows · GitHub Actions validation and security workflows that enforce the same checks remotely.
.github/workflows - Deploy/validate · Cross-platform scripts for installing the governance bundle and validating a local setup.
.agentcortex/bin - Governance tests · Repository tests that assert state-machine rules, credential floors, hook behavior, and workflow contracts.
tests
State and evidence
Durable shared state, work logs, and audit history.
- Current state · Global machine-checked project state that acts as the single source of truth.
.agentcortex/context/current_state.md - Work logs · Branch-scoped work records containing evidence, receipts, and gate outcomes.
.agentcortex/context/work - Audit archive · Immutable-ish archive of decisions, reviews, and lifecycle history.
.agentcortex/context/archive
Metadata and eval
Registries and baselines used to classify tasks and validate lifecycle requirements.
- Trigger metadata · Registries and baselines that classify task types and required phases.
.agentcortex/metadata - Eval harness · Evaluation inputs and baselines used to measure governance behavior and lifecycle compliance.
.agentcortex/eval/governance.yaml
Connections 22
- Platform entrypoints → Claude commands: routes to · Top-level agent entrypoints expose the command surface.
- Platform entrypoints → Agent workflows: shares workflows · Shared lifecycle concepts are defined in reusable workflow files.
- Claude commands → Skill library: attaches · Commands pull in phase-aware skill guidance when appropriate.
- Agent workflows → Skill library: guides with · Workflow steps reference skills for task-specific advice.
- Core rules → Agent workflows: constrains · Workflow behavior is bounded by core operating rules.
- Antigravity rules → Core rules: specializes · Platform policy extends the common rule set.
- Codex rules → Core rules: specializes · Codex-specific defaults narrow the shared governance rules.
- Safety docs → Core rules: explains · Docs provide doctrine and operating intent behind the rules.
- Validator tools → Current state: checks · Validators read the shared state to confirm consistency.
- Validator tools → Work logs: checks · Tools verify task evidence and receipts in work logs.
- Validator tools → Audit archive: verifies · Audit-chain and lesson-chain tools inspect preserved history.
- Validator tools → Trigger metadata: uses · Lifecycle and trigger tools classify tasks from metadata.
- Git hooks → Validator tools: invokes · Local hooks call the validator layer before allowing commits.
- CI workflows → Validator tools: invokes · Remote workflows run the same validation logic in CI.
- Deploy/validate → Validator tools: bootstraps · Adapter scripts install and exercise the governance tooling.
- Trigger metadata → Eval harness: feeds · Registry and baseline data inform governance evaluation inputs.
- Governance tests → Validator tools: covers · Tests assert the behavior of the validation and enforcement tools.
- Governance tests → Git hooks: covers · Tests verify pre-commit and hook boundary behavior.
- Governance tests → CI workflows: covers · Tests exercise CI/security workflow contracts.
- Current state → Work logs: scopes · Global state and branch-scoped evidence are intentionally separated.
- Work logs → Audit archive: rolls into · Completed work is preserved in the archive for provenance.
- Validator tools → Governance tests: enforced by · Contract tests encode the expected validator outcomes.