# itsthecsguy/ratchet architecture

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

- Interactive diagram: https://gitdiagram.com/itsthecsguy/ratchet
- Repository: https://github.com/itsthecsguy/ratchet

## Overview

Ratchet turns repository guidance into deterministic checks, then evaluates those checks during linting, setup, tool-call hooks, and finish-time checks. The main CLI dispatches ordinary commands, while hook events take a fast path into the hook runtime. Supporting layers parse skills, assemble plans, inspect repository state, and render findings; model testing evaluates prose-oriented rules with agent CLIs. The README documents the product workflow and harness coverage. Some IO and hook internals were not excerpted, so undocumented runtime links are omitted.

Main entry points: [`crates/ratchet-cli/src/commands.rs`](https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-cli/src/commands.rs) (Commands), [`crates/ratchet-hook/src/lib.rs`](https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-hook/src/lib.rs) (Hook runtime), [`crates/ratchet-io/src/plan.rs`](https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-io/src/plan.rs) (Plan loader), [`crates/ratchet-cli/src/main.rs`](https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-cli/src/main.rs) (CLI entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI workflows"]
  node_cli_entry["CLI entry<br/>[main.rs]"]
  node_cli_commands["Commands<br/>[commands.rs]"]
  node_guidance_detect["Guidance detection<br/>[detect.rs]"]
  node_rule_catalogue["Rule catalogue<br/>[catalogue.rs]"]
  node_lint["Skill lint<br/>[lint.rs]"]
  node_updater["Updater<br/>[update.rs]"]
end

subgraph group_rules["Rules and evaluation"]
  node_syntax_skill["Skill parser<br/>[skill.rs]"]
  node_syntax_checks["Rule checks<br/>[checks.rs]"]
  node_guidance_checks["Guidance checks<br/>[guidance.rs]"]
  node_plan["Plan loader<br/>[plan.rs]"]
  node_action["Action evaluator<br/>[action.rs]"]
  node_freshness["Freshness checks<br/>[freshness.rs]"]
  node_stop["Stop checks<br/>[stop.rs]"]
  node_render["Finding renderer<br/>[render.rs]"]
end

subgraph group_integration["Agent integrations"]
  node_hook_runtime["Hook runtime<br/>[lib.rs]"]
  node_harness_adapters["Harness adapters"]
end

subgraph group_repo["Repository state"]
  node_io_git["Git inspection<br/>[git.rs]"]
  node_io_paths["Path discovery<br/>[paths.rs]"]
  node_io_state["Local state<br/>[state.rs]"]
  node_io_skills["Skill files<br/>[skills.rs]"]
  node_io_transcript["Session transcripts<br/>[transcript.rs]"]
  node_io_harness["Harness setup IO<br/>[harness.rs]"]
  node_io_githook["Git hook setup<br/>[githook.rs]"]
end

subgraph group_models["Model evaluation"]
  node_model_spec["Model specifications<br/>[spec.rs]"]
  node_model_driver["Agent driver<br/>[driver.rs]"]
  node_model_sandbox["Test sandbox<br/>[sandbox.rs]"]
  node_model_verdict["Verdict evaluator<br/>[verdict.rs]"]
  node_model_report["Test reports<br/>[report.rs]"]
end

node_user(("Engineer"))
node_agent(("Coding agent"))
node_harness(("Agent harness"))

node_user -->|"runs commands"| node_cli_entry
node_cli_entry -->|"dispatches"| node_cli_commands
node_cli_entry -->|"routes hook events"| node_hook_runtime
node_cli_commands -->|"discovers guidance"| node_guidance_detect
node_cli_commands -->|"proposes rules"| node_rule_catalogue
node_cli_commands -->|"runs lint"| node_lint
node_cli_commands -->|"runs update"| node_updater
node_lint -->|"parses skills"| node_syntax_skill
node_syntax_skill -->|"uses checks"| node_syntax_checks
node_syntax_skill -->|"uses guidance"| node_guidance_checks
node_cli_commands -->|"loads rules"| node_plan
node_plan -->|"reads skills"| node_io_skills
node_plan -->|"uses git data"| node_io_git
node_plan -->|"resolves paths"| node_io_paths
node_plan -->|"refreshes cache"| node_io_state
node_hook_runtime -->|"dispatches adapters"| node_harness_adapters
node_harness -->|"sends tool events"| node_hook_runtime
node_hook_runtime -.->|"evaluates loaded rules"| node_plan
node_hook_runtime -.->|"checks actions"| node_action
node_hook_runtime -.->|"checks freshness"| node_freshness
node_hook_runtime -.->|"checks completion"| node_stop
node_action -->|"renders findings"| node_render
node_freshness -->|"renders findings"| node_render
node_freshness -.->|"checks changes"| node_io_git
node_stop -.->|"renders findings"| node_render
node_cli_commands -.->|"configures hooks"| node_io_harness
node_cli_commands -.->|"installs git hook"| node_io_githook
node_cli_commands -.->|"audits sessions"| node_io_transcript
node_cli_commands -.->|"configures model tests"| node_model_spec
node_model_spec -->|"selects driver"| node_model_driver
node_model_driver -->|"runs in sandbox"| node_model_sandbox
node_model_sandbox -->|"evaluates run"| node_model_verdict
node_model_verdict -.->|"reports verdict"| node_model_report
node_model_driver -->|"launches CLI"| node_agent

click node_cli_entry "https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-cli/src/main.rs"
click node_cli_commands "https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-cli/src/commands.rs"
click node_guidance_detect "https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-cli/src/detect.rs"
click node_rule_catalogue "https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-cli/src/catalogue.rs"
click node_lint "https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-cli/src/lint.rs"
click node_updater "https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-cli/src/update.rs"
click node_syntax_skill "https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-syntax/src/skill.rs"
click node_syntax_checks "https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-syntax/src/checks.rs"
click node_guidance_checks "https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-syntax/src/guidance.rs"
click node_plan "https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-io/src/plan.rs"
click node_action "https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-core/src/action.rs"
click node_freshness "https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-core/src/freshness.rs"
click node_stop "https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-core/src/stop.rs"
click node_render "https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-core/src/render.rs"
click node_hook_runtime "https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-hook/src/lib.rs"
click node_harness_adapters "https://github.com/itsthecsguy/ratchet/tree/main/crates/ratchet-hook/src"
click node_io_git "https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-io/src/git.rs"
click node_io_paths "https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-io/src/paths.rs"
click node_io_state "https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-io/src/state.rs"
click node_io_skills "https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-io/src/skills.rs"
click node_io_transcript "https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-io/src/transcript.rs"
click node_io_harness "https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-io/src/harness.rs"
click node_io_githook "https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-io/src/githook.rs"
click node_model_spec "https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-modeltest/src/spec.rs"
click node_model_driver "https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-modeltest/src/driver.rs"
click node_model_sandbox "https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-modeltest/src/sandbox.rs"
click node_model_verdict "https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-modeltest/src/verdict.rs"
click node_model_report "https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-modeltest/src/report.rs"

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_cli_entry,node_cli_commands,node_guidance_detect,node_rule_catalogue,node_lint,node_updater toneBlue
class node_syntax_skill,node_syntax_checks,node_guidance_checks,node_plan,node_action,node_freshness,node_stop,node_render toneAmber
class node_hook_runtime,node_harness_adapters toneMint
class node_io_git,node_io_paths,node_io_state,node_io_skills,node_io_transcript,node_io_harness,node_io_githook toneRose
class node_model_spec,node_model_driver,node_model_sandbox,node_model_verdict,node_model_report,node_user,node_agent,node_harness toneIndigo
```

## Components

### CLI workflows

- [CLI entry](https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-cli/src/main.rs): `crates/ratchet-cli/src/main.rs`
- [Commands](https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-cli/src/commands.rs): `crates/ratchet-cli/src/commands.rs`
- [Guidance detection](https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-cli/src/detect.rs): `crates/ratchet-cli/src/detect.rs`
- [Rule catalogue](https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-cli/src/catalogue.rs): `crates/ratchet-cli/src/catalogue.rs`
- [Skill lint](https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-cli/src/lint.rs): `crates/ratchet-cli/src/lint.rs`
- [Updater](https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-cli/src/update.rs): `crates/ratchet-cli/src/update.rs`

### Rules and evaluation

- [Skill parser](https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-syntax/src/skill.rs): `crates/ratchet-syntax/src/skill.rs`
- [Rule checks](https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-syntax/src/checks.rs): `crates/ratchet-syntax/src/checks.rs`
- [Guidance checks](https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-syntax/src/guidance.rs): `crates/ratchet-syntax/src/guidance.rs`
- [Plan loader](https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-io/src/plan.rs): `crates/ratchet-io/src/plan.rs`
- [Action evaluator](https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-core/src/action.rs): `crates/ratchet-core/src/action.rs`
- [Freshness checks](https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-core/src/freshness.rs): `crates/ratchet-core/src/freshness.rs`
- [Stop checks](https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-core/src/stop.rs): `crates/ratchet-core/src/stop.rs`
- [Finding renderer](https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-core/src/render.rs): `crates/ratchet-core/src/render.rs`

### Agent integrations

- [Hook runtime](https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-hook/src/lib.rs): `crates/ratchet-hook/src/lib.rs`
- [Harness adapters](https://github.com/itsthecsguy/ratchet/tree/main/crates/ratchet-hook/src): `crates/ratchet-hook/src`

### Repository state

- [Git inspection](https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-io/src/git.rs): `crates/ratchet-io/src/git.rs`
- [Path discovery](https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-io/src/paths.rs): `crates/ratchet-io/src/paths.rs`
- [Local state](https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-io/src/state.rs): `crates/ratchet-io/src/state.rs`
- [Skill files](https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-io/src/skills.rs): `crates/ratchet-io/src/skills.rs`
- [Session transcripts](https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-io/src/transcript.rs): `crates/ratchet-io/src/transcript.rs`
- [Harness setup IO](https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-io/src/harness.rs): `crates/ratchet-io/src/harness.rs`
- [Git hook setup](https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-io/src/githook.rs): `crates/ratchet-io/src/githook.rs`

### Model evaluation

- [Model specifications](https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-modeltest/src/spec.rs): `crates/ratchet-modeltest/src/spec.rs`
- [Agent driver](https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-modeltest/src/driver.rs): `crates/ratchet-modeltest/src/driver.rs`
- [Test sandbox](https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-modeltest/src/sandbox.rs): `crates/ratchet-modeltest/src/sandbox.rs`
- [Verdict evaluator](https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-modeltest/src/verdict.rs): `crates/ratchet-modeltest/src/verdict.rs`
- [Test reports](https://github.com/itsthecsguy/ratchet/blob/main/crates/ratchet-modeltest/src/report.rs): `crates/ratchet-modeltest/src/report.rs`

### Other components

- **Engineer**
- **Coding agent**
- **Agent harness**

## Connections

- Engineer → CLI entry: runs commands (evidence: `README.md`)
- CLI entry → Commands: dispatches (evidence: `crates/ratchet-cli/src/main.rs`)
- CLI entry → Hook runtime: routes hook events (evidence: `crates/ratchet-cli/src/main.rs`)
- Commands → Guidance detection: discovers guidance (evidence: `crates/ratchet-cli/src/commands.rs`)
- Commands → Rule catalogue: proposes rules (evidence: `crates/ratchet-cli/src/commands.rs`)
- Commands → Skill lint: runs lint (evidence: `crates/ratchet-cli/src/commands.rs`)
- Commands → Updater: runs update (evidence: `crates/ratchet-cli/src/commands.rs`)
- Skill lint → Skill parser: parses skills (evidence: `crates/ratchet-cli/src/lint.rs`)
- Skill parser → Rule checks: uses checks (evidence: `crates/ratchet-syntax/src/skill.rs`)
- Skill parser → Guidance checks: uses guidance (evidence: `crates/ratchet-syntax/src/skill.rs`)
- Commands → Plan loader: loads rules (evidence: `crates/ratchet-cli/src/commands.rs`)
- Plan loader → Skill files: reads skills (evidence: `crates/ratchet-io/src/plan.rs`)
- Plan loader → Git inspection: uses git data (evidence: `crates/ratchet-io/src/plan.rs`)
- Plan loader → Path discovery: resolves paths (evidence: `crates/ratchet-io/src/plan.rs`)
- Plan loader → Local state: refreshes cache (evidence: `crates/ratchet-io/src/plan.rs`)
- Hook runtime → Harness adapters: dispatches adapters (evidence: `crates/ratchet-hook/src/lib.rs`)
- Agent harness → Hook runtime: sends tool events (evidence: `README.md`)
- Hook runtime → Plan loader: evaluates loaded rules
- Hook runtime → Action evaluator: checks actions
- Hook runtime → Freshness checks: checks freshness
- Hook runtime → Stop checks: checks completion
- Action evaluator → Finding renderer: renders findings (evidence: `crates/ratchet-core/src/action.rs`)
- Freshness checks → Finding renderer: renders findings (evidence: `crates/ratchet-core/src/freshness.rs`)
- Freshness checks → Git inspection: checks changes
- Stop checks → Finding renderer: renders findings
- Commands → Harness setup IO: configures hooks
- Commands → Git hook setup: installs git hook
- Commands → Session transcripts: audits sessions
- Commands → Model specifications: configures model tests
- Model specifications → Agent driver: selects driver (evidence: `crates/ratchet-modeltest/src/driver.rs`)
- Agent driver → Test sandbox: runs in sandbox (evidence: `crates/ratchet-modeltest/src/sandbox.rs`)
- Test sandbox → Verdict evaluator: evaluates run (evidence: `crates/ratchet-modeltest/src/verdict.rs`)
- Verdict evaluator → Test reports: reports verdict
- Agent driver → Coding agent: launches CLI (evidence: `crates/ratchet-modeltest/src/driver.rs`)
