# kbwen/agentic-os architecture

> Architecture diagram of the GitHub repository kbwen/agentic-os, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kbwen/agentic-os
- Repository: https://github.com/kbwen/agentic-os

## Overview

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: [`.agentcortex/tools`](https://github.com/kbwen/agentic-os/blob/main/.agentcortex/tools) (Validator tools), [`tests`](https://github.com/kbwen/agentic-os/tree/main/tests) (Governance tests), [`.agent/rules`](https://github.com/kbwen/agentic-os/blob/main/.agent/rules) (Core rules), [`.agent/workflows`](https://github.com/kbwen/agentic-os/blob/main/.agent/workflows) (Agent workflows)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_guidance["Agent guidance"]
  node_entrypoints["Platform entrypoints<br/>agent surface<br/>[AGENTS.md]"]
  node_claude_cmds["Claude commands<br/>workflow prompts<br/>[commands]"]
  node_agent_workflows["Agent workflows<br/>workflow prompts<br/>[workflows]"]
  node_skills["Skill library<br/>phase guidance<br/>[skills]"]
end

subgraph group_policy["Governance policy"]
  node_rules["Core rules<br/>guardrails<br/>[rules]"]
  node_antigravity["Antigravity rules<br/>platform policy<br/>[rules.md]"]
  node_codex_rules["Codex rules<br/>platform policy<br/>[default.rules]"]
  node_safety_docs["Safety docs<br/>doctrine<br/>[docs]"]
end

subgraph group_enforcement["Enforcement boundary"]
  node_validator_tools["Validator tools<br/>checks<br/>[tools]"]
  node_hooks["Git hooks<br/>local gate<br/>[.githooks]"]
  node_ci_workflows["CI workflows<br/>remote gate<br/>[workflows]"]
  node_deploy_validate["Deploy/validate<br/>adapter scripts<br/>[bin]"]
  node_tests["Governance tests<br/>contract tests"]
end

subgraph group_state["State and evidence"]
  node_current_state["Current state<br/>shared SSOT<br/>[current_state.md]"]
  node_work_logs["Work logs<br/>task ledger<br/>[work]"]
  node_archive["Audit archive<br/>history ledger<br/>[archive]"]
end

subgraph group_metadata["Metadata and eval"]
  node_trigger_meta["Trigger metadata<br/>lifecycle registry<br/>[metadata]"]
  node_eval_harness["Eval harness<br/>governance eval<br/>[governance.yaml]"]
end

node_entrypoints -->|"routes to"| node_claude_cmds
node_entrypoints -->|"shares workflows"| node_agent_workflows
node_claude_cmds -->|"attaches"| node_skills
node_agent_workflows -->|"guides with"| node_skills
node_rules -->|"constrains"| node_agent_workflows
node_antigravity -->|"specializes"| node_rules
node_codex_rules -->|"specializes"| node_rules
node_safety_docs -.->|"explains"| node_rules
node_validator_tools -->|"checks"| node_current_state
node_validator_tools -->|"checks"| node_work_logs
node_validator_tools -->|"verifies"| node_archive
node_validator_tools -->|"uses"| node_trigger_meta
node_hooks -->|"invokes"| node_validator_tools
node_ci_workflows -->|"invokes"| node_validator_tools
node_deploy_validate -->|"bootstraps"| node_validator_tools
node_trigger_meta -->|"feeds"| node_eval_harness
node_tests -->|"covers"| node_validator_tools
node_tests -->|"covers"| node_hooks
node_tests -->|"covers"| node_ci_workflows
node_current_state -.->|"scopes"| node_work_logs
node_work_logs -.->|"rolls into"| node_archive
node_validator_tools -->|"enforced by"| node_tests

click node_entrypoints "https://github.com/kbwen/agentic-os/blob/main/AGENTS.md"
click node_claude_cmds "https://github.com/kbwen/agentic-os/blob/main/.claude/commands"
click node_agent_workflows "https://github.com/kbwen/agentic-os/blob/main/.agent/workflows"
click node_skills "https://github.com/kbwen/agentic-os/blob/main/.agents/skills"
click node_rules "https://github.com/kbwen/agentic-os/blob/main/.agent/rules"
click node_antigravity "https://github.com/kbwen/agentic-os/blob/main/.antigravity/rules.md"
click node_codex_rules "https://github.com/kbwen/agentic-os/blob/main/codex/rules/default.rules"
click node_safety_docs "https://github.com/kbwen/agentic-os/blob/main/.agentcortex/docs"
click node_validator_tools "https://github.com/kbwen/agentic-os/blob/main/.agentcortex/tools"
click node_hooks "https://github.com/kbwen/agentic-os/blob/main/.githooks"
click node_ci_workflows "https://github.com/kbwen/agentic-os/blob/main/.github/workflows"
click node_deploy_validate "https://github.com/kbwen/agentic-os/blob/main/.agentcortex/bin"
click node_current_state "https://github.com/kbwen/agentic-os/blob/main/.agentcortex/context/current_state.md"
click node_work_logs "https://github.com/kbwen/agentic-os/blob/main/.agentcortex/context/work"
click node_archive "https://github.com/kbwen/agentic-os/blob/main/.agentcortex/context/archive"
click node_trigger_meta "https://github.com/kbwen/agentic-os/blob/main/.agentcortex/metadata"
click node_eval_harness "https://github.com/kbwen/agentic-os/blob/main/.agentcortex/eval/governance.yaml"
click node_tests "https://github.com/kbwen/agentic-os/tree/main/tests"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_entrypoints,node_claude_cmds,node_agent_workflows,node_skills toneBlue
class node_rules,node_antigravity,node_codex_rules,node_safety_docs toneAmber
class node_validator_tools,node_hooks,node_ci_workflows,node_deploy_validate,node_tests toneMint
class node_current_state,node_work_logs,node_archive toneRose
class node_trigger_meta,node_eval_harness toneIndigo
```

## Components

### Agent guidance

Workflow prompts, commands, and skills that tell agents what to do.

- [Platform entrypoints](https://github.com/kbwen/agentic-os/blob/main/AGENTS.md): agent surface · Top-level command and agent entry files for Claude, Codex, Gemini, and shared agent instructions. · `AGENTS.md`
- [Claude commands](https://github.com/kbwen/agentic-os/blob/main/.claude/commands): workflow prompts · Claude command layer covering bootstrap, plan, implement, review, ship, audit, and related lifecycle steps. · `.claude/commands`
- [Agent workflows](https://github.com/kbwen/agentic-os/blob/main/.agent/workflows): workflow prompts · Shared workflow definitions used to route lifecycle actions and task-specific execution paths. · `.agent/workflows`
- [Skill library](https://github.com/kbwen/agentic-os/blob/main/.agents/skills): phase guidance · 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](https://github.com/kbwen/agentic-os/blob/main/.agent/rules): guardrails · Behavioral and state-machine rules for agent execution and conflict resolution. · `.agent/rules`
- [Antigravity rules](https://github.com/kbwen/agentic-os/blob/main/.antigravity/rules.md): platform policy · Additional platform-specific rules governing the agent runtime posture. · `.antigravity/rules.md`
- [Codex rules](https://github.com/kbwen/agentic-os/blob/main/codex/rules/default.rules): platform policy · Codex-specific rules and defaults for the governance bundle. · `codex/rules/default.rules`
- [Safety docs](https://github.com/kbwen/agentic-os/blob/main/.agentcortex/docs): doctrine · 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](https://github.com/kbwen/agentic-os/blob/main/.agentcortex/tools): checks · Core Python and shell utilities that verify audit chains, spec drift, evidence, and governed writes. · `.agentcortex/tools`
- [Git hooks](https://github.com/kbwen/agentic-os/blob/main/.githooks): local gate · Pre-commit and related hook entrypoints that block invalid changes before commit. · `.githooks`
- [CI workflows](https://github.com/kbwen/agentic-os/blob/main/.github/workflows): remote gate · GitHub Actions validation and security workflows that enforce the same checks remotely. · `.github/workflows`
- [Deploy/validate](https://github.com/kbwen/agentic-os/blob/main/.agentcortex/bin): adapter scripts · Cross-platform scripts for installing the governance bundle and validating a local setup. · `.agentcortex/bin`
- [Governance tests](https://github.com/kbwen/agentic-os/tree/main/tests): contract 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](https://github.com/kbwen/agentic-os/blob/main/.agentcortex/context/current_state.md): shared SSOT · Global machine-checked project state that acts as the single source of truth. · `.agentcortex/context/current_state.md`
- [Work logs](https://github.com/kbwen/agentic-os/blob/main/.agentcortex/context/work): task ledger · Branch-scoped work records containing evidence, receipts, and gate outcomes. · `.agentcortex/context/work`
- [Audit archive](https://github.com/kbwen/agentic-os/blob/main/.agentcortex/context/archive): history ledger · 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](https://github.com/kbwen/agentic-os/blob/main/.agentcortex/metadata): lifecycle registry · Registries and baselines that classify task types and required phases. · `.agentcortex/metadata`
- [Eval harness](https://github.com/kbwen/agentic-os/blob/main/.agentcortex/eval/governance.yaml): governance eval · Evaluation inputs and baselines used to measure governance behavior and lifecycle compliance. · `.agentcortex/eval/governance.yaml`

## Connections

- 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.
