# martinffx/atelier architecture

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

- Interactive diagram: https://gitdiagram.com/martinffx/atelier
- Repository: https://github.com/martinffx/atelier

## Overview

1. **What this repo is**
   Atelier is a TypeScript/Bun CLI that installs and maintains AI-agent workspace scaffolding in a target project. It is not an application server; its main job is to generate files, wire them into a harness, and optionally install bundled skills.

2. **Primary runtime boundary**
   The executable entrypoint lives in `src/atelier.ts`, with the public surface split into three user-facing commands: `init`, `update`, and `remove`. Those commands operate on the current project directory, not on Atelier’s own repo, so the architectural boundary is “tooling repository” vs “destination project.”

3. **Command orchestration layer**
   `src/commands/` is the control plane. `init` performs first-time setup and can be interactive or non-interactive; `update` refreshes generated harness assets; `remove` cleans up generated files without uninstalling skills. This layer is where idempotency and destructive/non-destructive behavior are enforced.

4. **Harness detection and branching**
   `src/utils/detect.ts` is the branching point that determines whether the target project is using Claude Code or OpenCode, unless the user forces a choice. That decision shapes every downstream output: agent file locations, plugin/hook format, and model identifiers.

5. **Configuration as the source of truth**
   The repo centers on a project-local config file under `.atelier/config.json`, represented by `src/models.ts` and `src/types.ts` and managed through `src/utils/config.ts`. This config captures harness choice, selected skills source, and agent definitions, and it lets later runs regenerate the same project state predictably.

6. **Template/rendering subsystem**
   `src/utils/templates.ts` provides the template content and file-shaping logic used by generators. The important architectural point is that generated artifacts are not hand-authored ad hoc; they are derived from templates so `init` and `update` can reproduce consistent output.

7. **Harness-specific generators**
   `src/generators/claude.ts` and `src/generators/opencode.ts` are the two concrete emitters. They translate the shared config/model layer into harness-specific outputs: Claude-focused agent directories and session hooks, or OpenCode plugins and agent definitions. The paired tests in `src/generators/*.test.ts` suggest this is a key compatibility boundary.

8. **Generated artifacts and project integration**
   The CLI writes into the destination repo’s tool-specific directories, such as `.claude/agents/`, `.opencode/agents/`, `.opencode/plugins/atelier.js`, and `.atelier/config.json`. For Claude Code, the hook boundary is session-start context injection; for OpenCode, it is plugin/config transformation. These outputs are the runtime integration points with the external harness.

9. **External dependency on the skills ecosystem**
   Atelier can optionally invoke the external `skills` CLI (`npx skills add martinffx/atelier`) to install the repo’s packaged skills into the project. That means skills are intentionally separated from the generator pipeline: the CLI can manage harness scaffolding without owning the skills distribution mechanism.

10. **Skills content as packaged knowledge**
   The `skills/` tree is a large content subsystem, not executable app logic. It contains workflow skills, oracle/thinking skills, and technology/domain skills that are meant to be auto-invoked by the harness. In architecture terms, these are deployable knowledge artifacts that complement the generated agents and hooks.

11. **Agent/persona definitions**
   The `agents/` directory and the README’s Scout/Oracle/Architect concept indicate a small persona layer with distinct responsibilities: reconnaissance, strategic analysis, and architecture. These are generated into harness-specific locations and configured with different model selections depending on Claude vs OpenCode.

12. **Error handling and validation**
   `src/utils/errors.ts` exists as a dedicated utility boundary for predictable failures. Combined with `src/utils/config.ts` and the command tests, this suggests the CLI is designed to fail cleanly when project state, harness detection, or generation inputs are invalid.

13. **Repo-level delivery and maintenance**
   GitHub Actions in `.github/workflows/ci.yml` and `release-please.yml`, plus `commitlint.config.js`, show a conventional release pipeline around a packaged CLI. The repository is designed to ship versioned tooling, with changelog/release automation rather than runtime deployment infrastructure.

14. **Docs/specs as design history**
   `docs/specs/` contains dated design and plan artifacts, which implies the repo uses spec-driven development for evolving features such as CLI behavior and provider selection. Those docs are not runtime dependencies, but they are important for understanding why the code is organized around generated artifacts, harness abstractions, and idempotent operations.

Main entry points: [`src/commands/init.ts`](https://github.com/martinffx/atelier/blob/main/src/commands/init.ts) (Init), [`src/commands/update.ts`](https://github.com/martinffx/atelier/blob/main/src/commands/update.ts) (Update), [`src/atelier.ts`](https://github.com/martinffx/atelier/blob/main/src/atelier.ts) (Atelier CLI), [`src/generators/claude.ts`](https://github.com/martinffx/atelier/blob/main/src/generators/claude.ts) (Claude Gen)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI Runtime"]
  node_atelier_entry["Atelier CLI<br/>entrypoint<br/>[atelier.ts]"]
  node_init_cmd["Init<br/>command<br/>[init.ts]"]
  node_update_cmd["Update<br/>command<br/>[update.ts]"]
  node_remove_cmd["Remove<br/>command<br/>[remove.ts]"]
end

subgraph group_core["Core Services"]
  node_detect{{"Detect Harness<br/>detection<br/>[detect.ts]"}}
  node_config[("Project Config<br/>state<br/>[config.ts]")]
  node_models["Models<br/>schema<br/>[models.ts]"]
  node_types["Types<br/>contracts<br/>[types.ts]"]
  node_templates["Templates<br/>rendering<br/>[templates.ts]"]
  node_errors["Errors<br/>failure-boundary<br/>[errors.ts]"]
end

subgraph group_backends["Harness Backends"]
  node_claude_gen["Claude Gen<br/>generator<br/>[claude.ts]"]
  node_opencode_gen["OpenCode Gen<br/>generator<br/>[opencode.ts]"]
  node_claude_out[("Claude Assets<br/>generated-artifacts<br/>[claude.ts]")]
  node_opencode_out[("OpenCode Assets<br/>generated-artifacts<br/>[opencode.ts]")]
end

subgraph group_content["Packaged Content"]
  node_skills_content["Skills Pack<br/>content<br/>[SKILL.md]"]
  node_agents["Agent Personas<br/>[architect.md]"]
  node_skills_cli(("Skills CLI<br/>external-tool"))
end

subgraph group_delivery["Delivery"]
  node_workflows["Release CI<br/>automation<br/>[ci.yml]"]
  node_specs["Specs<br/>design-history<br/>[design.md]"]
end

node_atelier_entry -->|"dispatch"| node_init_cmd
node_atelier_entry -->|"dispatch"| node_update_cmd
node_atelier_entry -->|"dispatch"| node_remove_cmd
node_init_cmd -->|"choose harness"| node_detect
node_init_cmd -->|"persist"| node_config
node_update_cmd -->|"read"| node_config
node_remove_cmd -->|"read"| node_config
node_config -->|"shape"| node_models
node_models -->|"define"| node_types
node_init_cmd -->|"render"| node_templates
node_update_cmd -->|"render"| node_templates
node_init_cmd -->|"branch"| node_claude_gen
node_init_cmd -->|"branch"| node_opencode_gen
node_update_cmd -->|"refresh"| node_claude_gen
node_update_cmd -->|"refresh"| node_opencode_gen
node_claude_gen -->|"emit"| node_claude_out
node_opencode_gen -->|"emit"| node_opencode_out
node_claude_gen -->|"persona input"| node_agents
node_opencode_gen -->|"persona input"| node_agents
node_claude_gen -->|"bundle"| node_skills_content
node_opencode_gen -->|"bundle"| node_skills_content
node_init_cmd -.->|"optional install"| node_skills_cli
node_skills_cli -.->|"install"| node_skills_content
node_atelier_entry -->|"fail fast"| node_errors
node_init_cmd -->|"validate"| node_errors
node_update_cmd -->|"validate"| node_errors
node_remove_cmd -->|"validate"| node_errors
node_workflows -->|"ship"| node_atelier_entry
node_specs -.->|"inform"| node_init_cmd
node_specs -.->|"inform"| node_detect

click node_atelier_entry "https://github.com/martinffx/atelier/blob/main/src/atelier.ts"
click node_init_cmd "https://github.com/martinffx/atelier/blob/main/src/commands/init.ts"
click node_update_cmd "https://github.com/martinffx/atelier/blob/main/src/commands/update.ts"
click node_remove_cmd "https://github.com/martinffx/atelier/blob/main/src/commands/remove.ts"
click node_detect "https://github.com/martinffx/atelier/blob/main/src/utils/detect.ts"
click node_config "https://github.com/martinffx/atelier/blob/main/src/utils/config.ts"
click node_models "https://github.com/martinffx/atelier/blob/main/src/models.ts"
click node_types "https://github.com/martinffx/atelier/blob/main/src/types.ts"
click node_templates "https://github.com/martinffx/atelier/blob/main/src/utils/templates.ts"
click node_errors "https://github.com/martinffx/atelier/blob/main/src/utils/errors.ts"
click node_claude_gen "https://github.com/martinffx/atelier/blob/main/src/generators/claude.ts"
click node_opencode_gen "https://github.com/martinffx/atelier/blob/main/src/generators/opencode.ts"
click node_claude_out "https://github.com/martinffx/atelier/blob/main/src/generators/claude.ts"
click node_opencode_out "https://github.com/martinffx/atelier/blob/main/src/generators/opencode.ts"
click node_skills_content "https://github.com/martinffx/atelier/blob/main/skills/code-review/SKILL.md"
click node_agents "https://github.com/martinffx/atelier/blob/main/agents/architect.md"
click node_workflows "https://github.com/martinffx/atelier/blob/main/.github/workflows/ci.yml"
click node_specs "https://github.com/martinffx/atelier/blob/main/docs/specs/2025-05-07-atelier-cli/design.md"

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_atelier_entry,node_init_cmd,node_update_cmd,node_remove_cmd toneBlue
class node_detect,node_config,node_models,node_types,node_templates,node_errors toneAmber
class node_claude_gen,node_opencode_gen,node_claude_out,node_opencode_out toneMint
class node_skills_content,node_agents,node_skills_cli toneRose
class node_workflows,node_specs toneIndigo
```

## Components

### CLI Runtime

Entry commands and project-facing control flow

- [Atelier CLI](https://github.com/martinffx/atelier/blob/main/src/atelier.ts): entrypoint · Bun/TypeScript executable surface · `src/atelier.ts`
- [Init](https://github.com/martinffx/atelier/blob/main/src/commands/init.ts): command · First-time setup and wiring · `src/commands/init.ts`
- [Update](https://github.com/martinffx/atelier/blob/main/src/commands/update.ts): command · Refresh generated harness assets · `src/commands/update.ts`
- [Remove](https://github.com/martinffx/atelier/blob/main/src/commands/remove.ts): command · Clean generated files · `src/commands/remove.ts`

### Core Services

Shared state, detection, templates, and error handling

- [Detect Harness](https://github.com/martinffx/atelier/blob/main/src/utils/detect.ts): detection · Selects Claude Code or OpenCode · `src/utils/detect.ts`
- [Project Config](https://github.com/martinffx/atelier/blob/main/src/utils/config.ts): state · Source of truth in .atelier/config.json · `src/utils/config.ts`
- [Models](https://github.com/martinffx/atelier/blob/main/src/models.ts): schema · Shared config and domain shapes · `src/models.ts`
- [Types](https://github.com/martinffx/atelier/blob/main/src/types.ts): contracts · Shared TypeScript contracts · `src/types.ts`
- [Templates](https://github.com/martinffx/atelier/blob/main/src/utils/templates.ts): rendering · Generates file content and layout · `src/utils/templates.ts`
- [Errors](https://github.com/martinffx/atelier/blob/main/src/utils/errors.ts): failure-boundary · Predictable CLI failure handling · `src/utils/errors.ts`

### Harness Backends

Harness-specific generators and emitted artifacts

- [Claude Gen](https://github.com/martinffx/atelier/blob/main/src/generators/claude.ts): generator · Emits Claude-specific harness files · `src/generators/claude.ts`
- [OpenCode Gen](https://github.com/martinffx/atelier/blob/main/src/generators/opencode.ts): generator · Emits OpenCode-specific harness files · `src/generators/opencode.ts`
- [Claude Assets](https://github.com/martinffx/atelier/blob/main/src/generators/claude.ts): generated-artifacts · Agent dirs and session hooks under .claude · `src/generators/claude.ts`
- [OpenCode Assets](https://github.com/martinffx/atelier/blob/main/src/generators/opencode.ts): generated-artifacts · Agents and plugin under .opencode · `src/generators/opencode.ts`

### Packaged Content

Agents and skills shipped with the repo

- [Skills Pack](https://github.com/martinffx/atelier/blob/main/skills/code-review/SKILL.md): content · Packaged knowledge artifacts for auto-invocation · `skills/code-review/SKILL.md`
- [Agent Personas](https://github.com/martinffx/atelier/blob/main/agents/architect.md): persona · Scout, Oracle, Architect definitions · `agents/architect.md`
- **Skills CLI**: external-tool · Optional npx skills add installation path

### Delivery

Release automation and design history

- [Release CI](https://github.com/martinffx/atelier/blob/main/.github/workflows/ci.yml): automation · CI and release-please publishing flow · `.github/workflows/ci.yml`
- [Specs](https://github.com/martinffx/atelier/blob/main/docs/specs/2025-05-07-atelier-cli/design.md): design-history · Design and plan artifacts for evolution · `docs/specs/2025-05-07-atelier-cli/design.md`

## Connections

- Atelier CLI → Init: dispatch · Routes the init command
- Atelier CLI → Update: dispatch · Routes the update command
- Atelier CLI → Remove: dispatch · Routes the remove command
- Init → Detect Harness: choose harness · Determines Claude Code vs OpenCode
- Init → Project Config: persist · Writes project-local configuration
- Update → Project Config: read · Loads existing project state
- Remove → Project Config: read · Uses config to know what to clean
- Project Config → Models: shape · Backed by shared config model
- Models → Types: define · Shared domain contracts support the model layer
- Init → Templates: render · Builds generated files from templates
- Update → Templates: render · Re-renders consistent output
- Init → Claude Gen: branch · Uses Claude backend when selected
- Init → OpenCode Gen: branch · Uses OpenCode backend when selected
- Update → Claude Gen: refresh · Updates Claude-managed files
- Update → OpenCode Gen: refresh · Updates OpenCode-managed files
- Claude Gen → Claude Assets: emit · Writes Claude-specific project artifacts
- OpenCode Gen → OpenCode Assets: emit · Writes OpenCode-specific project artifacts
- Claude Gen → Agent Personas: persona input · Uses agent definitions for Claude output
- OpenCode Gen → Agent Personas: persona input · Uses agent definitions for OpenCode output
- Claude Gen → Skills Pack: bundle · References packaged skills content
- OpenCode Gen → Skills Pack: bundle · References packaged skills content
- Init → Skills CLI: optional install · Can delegate skills installation externally
- Skills CLI → Skills Pack: install · Installs the packaged skills set
- Atelier CLI → Errors: fail fast · Shared predictable error handling
- Init → Errors: validate · Checks invalid project or inputs
- Update → Errors: validate · Rejects unsupported or inconsistent state
- Remove → Errors: validate · Protects destructive cleanup paths
- Release CI → Atelier CLI: ship · Build and release the CLI package
- Specs → Init: inform · Documents evolving command behavior
- Specs → Detect Harness: inform · Tracks provider and harness selection decisions
