# eduardolat/clancy architecture

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

- Interactive diagram: https://gitdiagram.com/eduardolat/clancy
- Repository: https://github.com/eduardolat/clancy

## Overview

Clancy is a command-line orchestrator for repeatedly running an AI coding agent until its output meets a stop condition or safety limit. The principal flow loads YAML settings, resolves a literal or file-based prompt, prepares the agent command, and runs it through a platform-specific process runner; the loop checks output and handles retries, delays, and timeouts. The CLI also generates a starter configuration and reports version metadata. The README documents example prompt templates; their use is not wired into the runtime flow shown here.

Main entry points: [`cmd/clancy/main.go`](https://github.com/eduardolat/clancy/blob/main/cmd/clancy/main.go) (CLI commands), [`internal/runner/runner.go`](https://github.com/eduardolat/clancy/blob/main/internal/runner/runner.go) (Runner interface), [`internal/config/config.go`](https://github.com/eduardolat/clancy/blob/main/internal/config/config.go) (Config loading), [`internal/loop/loop.go`](https://github.com/eduardolat/clancy/blob/main/internal/loop/loop.go) (Loop controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI entry"]
  node_cli["CLI commands<br/>[main.go]"]
  node_version["Version metadata<br/>[version.go]"]
end

subgraph group_inputs["Configuration and input"]
  node_config["Config loading<br/>[config.go]"]
  node_prompt["Prompt resolution<br/>[config.go]"]
  node_templates["Example prompts"]
end

subgraph group_runtime["Agent runtime"]
  node_loop["Loop controller<br/>[loop.go]"]
  node_runnerapi["Runner interface<br/>[runner.go]"]
  node_command["Command execution<br/>[runner_unix.go]"]
  node_windows["Windows execution<br/>[runner_windows.go]"]
end

node_user(("CLI user"))
node_yaml["YAML config"]
node_promptfile["Prompt file"]
node_agent(("Agent process"))

node_user -->|"invokes"| node_cli
node_cli -->|"loads settings"| node_config
node_cli -->|"resolves prompt"| node_prompt
node_config -->|"reads"| node_yaml
node_prompt -->|"reads when configured"| node_promptfile
node_cli -->|"starts"| node_loop
node_cli -->|"creates runner"| node_runnerapi
node_cli -->|"reports"| node_version
node_loop -->|"uses"| node_runnerapi
node_runnerapi -->|"implements on Unix"| node_command
node_runnerapi -->|"implements on Windows"| node_windows
node_command -->|"runs command"| node_agent
node_windows -->|"runs command"| node_agent

click node_cli "https://github.com/eduardolat/clancy/blob/main/cmd/clancy/main.go"
click node_version "https://github.com/eduardolat/clancy/blob/main/internal/version/version.go"
click node_config "https://github.com/eduardolat/clancy/blob/main/internal/config/config.go"
click node_prompt "https://github.com/eduardolat/clancy/blob/main/internal/config/config.go"
click node_loop "https://github.com/eduardolat/clancy/blob/main/internal/loop/loop.go"
click node_runnerapi "https://github.com/eduardolat/clancy/blob/main/internal/runner/runner.go"
click node_command "https://github.com/eduardolat/clancy/blob/main/internal/runner/runner_unix.go"
click node_windows "https://github.com/eduardolat/clancy/blob/main/internal/runner/runner_windows.go"
click node_templates "https://github.com/eduardolat/clancy/tree/main/prompts"

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,node_version,node_user toneBlue
class node_config,node_prompt,node_templates toneAmber
class node_loop,node_runnerapi,node_command,node_windows toneMint
class node_yaml,node_promptfile,node_agent toneIndigo
```

## Components

### CLI entry

- [CLI commands](https://github.com/eduardolat/clancy/blob/main/cmd/clancy/main.go): `cmd/clancy/main.go`
- [Version metadata](https://github.com/eduardolat/clancy/blob/main/internal/version/version.go): `internal/version/version.go`

### Configuration and input

- [Config loading](https://github.com/eduardolat/clancy/blob/main/internal/config/config.go): `internal/config/config.go`
- [Prompt resolution](https://github.com/eduardolat/clancy/blob/main/internal/config/config.go): `internal/config/config.go`
- [Example prompts](https://github.com/eduardolat/clancy/tree/main/prompts): `prompts`

### Agent runtime

- [Loop controller](https://github.com/eduardolat/clancy/blob/main/internal/loop/loop.go): `internal/loop/loop.go`
- [Runner interface](https://github.com/eduardolat/clancy/blob/main/internal/runner/runner.go): `internal/runner/runner.go`
- [Command execution](https://github.com/eduardolat/clancy/blob/main/internal/runner/runner_unix.go): `internal/runner/runner_unix.go`
- [Windows execution](https://github.com/eduardolat/clancy/blob/main/internal/runner/runner_windows.go): `internal/runner/runner_windows.go`

### Other components

- **CLI user**
- **YAML config**
- **Prompt file**
- **Agent process**

## Connections

- CLI user → CLI commands: invokes (evidence: `README.md`)
- CLI commands → Config loading: loads settings (evidence: `cmd/clancy/main.go`)
- CLI commands → Prompt resolution: resolves prompt (evidence: `cmd/clancy/main.go`)
- Config loading → YAML config: reads (evidence: `internal/config/config.go`)
- Prompt resolution → Prompt file: reads when configured (evidence: `internal/config/config.go`)
- CLI commands → Loop controller: starts (evidence: `cmd/clancy/main.go`)
- CLI commands → Runner interface: creates runner (evidence: `cmd/clancy/main.go`)
- CLI commands → Version metadata: reports (evidence: `cmd/clancy/main.go`)
- Loop controller → Runner interface: uses (evidence: `internal/loop/loop.go`)
- Runner interface → Command execution: implements on Unix (evidence: `internal/runner/runner_unix.go`)
- Runner interface → Windows execution: implements on Windows (evidence: `internal/runner/runner_windows.go`)
- Command execution → Agent process: runs command (evidence: `internal/runner/runner_unix.go`)
- Windows execution → Agent process: runs command (evidence: `internal/runner/runner_windows.go`)
