Skip to the content.

Repository Analysis

coding-ethos is a Python CLI and bundled ETHOS enforcement package. Its core job is to keep generated agent documentation, generated tool configuration, and hook prompt grounding aligned with a shared structured ethos.

System responsibilities

The CLI is intentionally thin. New behavior should usually land in one of the narrow modules above, with cli.py limited to wiring and exit-code handling.

Source-of-truth files

coding_ethos.yml is the shared documentation contract. It defines the principle list, agent profiles, quick references, merge topics, and detailed section prose. repo_ethos.yml is the repo-local refinement layer used when generating this repository’s checked-in agent files.

config.yaml is the bundle-wide enforcement contract. It controls generated tool configs and hook policy. Consumer repositories refine those defaults with repo_config.yaml or repo_config.yml.

pre-commit/prompts/ contains Jinja templates used to render .code-ethos/gemini/prompt-pack.json. The prompt pack is generated from ethos content, repo context, enforcement settings, and template text.

Generated artifacts

Agent-facing generated artifacts:

Enforcement generated artifacts:

Generated Markdown files should not be hand-edited unless the task is explicitly about the generated output itself. Change the ethos YAML or renderer logic, regenerate, and review the derived diff.

Runtime flow

For agent document generation, the CLI resolves the target repo, primary ethos YAML, and optional repo overlay. It loads and validates the primary bundle, applies the overlay when present, renders all deterministic output, and writes files into the target repo. With --merge-existing, only AGENTS.md, CLAUDE.md, and GEMINI.md are merge-preserved.

For tool-config sync, the CLI loads config.yaml, applies an optional consumer repo config, renders the supported tool config files, and either writes them or reports drift.

For Gemini prompt-pack sync, the CLI merges ethos context and enforcement config, renders every prompt template, attaches check selectors and runtime metadata, and writes .code-ethos/gemini/prompt-pack.json.

For hooks, the Makefile installs repo-local Git hook shims that call the Go helper and compiled policy entrypoints. cutover also syncs Claude, Codex, and Gemini repo-local agent hook settings, verifies the git wrapper path, and checks required runtime ignores before declaring the hook surface ready.

Validation boundaries

The primary ethos loader rejects malformed schema versions, empty principle lists, duplicate principle ids, duplicate orders, unknown related principle ids, unsupported agents, malformed sections, and empty required fields.

The repo overlay rejects non-mapping repo payloads, unsupported agent notes, unknown principle override ids, malformed override sections, duplicate additional principle ids, and invalid final principle collections.

The generated config path treats missing or out-of-sync generated files as verification failures rather than silently tolerating drift.

Change impact guide

Verification contract

The canonical test command is:

make test

The local toolchain and hook-path check is:

make doctor

The current repository gate is:

make check

Hook changes should also run:

make validate
make go-test

Generated artifacts must be synced before finishing changes that affect their source inputs:

make generate
make sync-tool-configs
make sync-gemini-prompts