cernly

module
v0.4.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2026 License: Apache-2.0

README

Cernly

Architecture facts from a git repository, with file and line evidence for every one of them.

cernly scan reads the git-tracked files of one commit (Compose files, Kubernetes manifests, Kustomize overlays and Helm charts, Dockerfiles, CI workflows, package manifests, env examples, Caddy, nginx and Traefik configuration, Prisma schemas, SQL migrations, Go, TypeScript and Python code, test files; Java and Spring through the optional java WebAssembly plugin, see below) and writes a facts file: services, data stores, dependencies (direct, and transitive from lockfiles), environment variable names, outside hosts, routes, database tables, AI tooling. cernly map derives the architecture from it: which code builds which service, which stack is production, which outside parties each service talks to. cernly mcp serves both to AI agents over the Model Context Protocol. cernly gate compares a scan with an earlier one and fails a build when it adds something the policy blocks. cernly sbom writes a CycloneDX bill of materials per service. cernly docs writes architecture docs in Markdown: arc42 sections and C4 views in Mermaid, every statement with its file and line. The map counts the surface (outside parties, data stores, columns to check, unpinned images, production stacks, routes) per service, with size and the Go import graph's coupling as context.

  • Deterministic: same commit, same binary, same flags, byte-identical output.
  • Evidence: every fact names the file and line it came from.
  • Safe: it never runs, builds or installs anything from the repository it reads. Only git-tracked files; symlinks and submodules are never followed.

Docs: https://cernly.dev (for agents: AGENTS.md and https://cernly.dev/llms.txt)

Install

go install github.com/cernly/cernly/cmd/cernly@latest

From a checkout: go build ./cmd/cernly (Go 1.26.8 or newer, as go.mod says).

Or a binary from releases (reproducible, with build provenance: gh attestation verify <file> --repo cernly/cernly), or Docker: docker run --rm -v "$PWD:/repo:ro" ghcr.io/cernly/cernly scan /repo.

Use

cernly scan --repo github.com/owner/name . > facts.json
cernly map facts.json > map.json
claude mcp add cernly -- cernly mcp .
cernly gate --base base.facts.json facts.json
cernly sbom --out bom.cdx.json facts.json
cernly docs --out ARCHITECTURE.md facts.json

Outside plugins are WebAssembly modules, signed with ed25519, that see only the tracked files they ask for and return facts in the same vocabulary; they cannot read anything else, reach the network or run the repository's code. Write one with plugin/sdk and test it with plugin/plugintest: see CONTRIBUTING. The repo's own, wasmplugins/java, is built and signed the same way and loaded with cernly scan --plugins <dir> --trust-key <key>.pub; releases do not ship a signed build of it yet.

A repository can exclude paths and declare its own domains and stack roles in .cernly.yml; every exclusion is visible in the facts file. The formats are schema/scan.v1.schema.json and schema/map.v1.schema.json (JSON Schema 2020-12).

Local viewer

web/viewer/build.sh builds dist/viewer/cernly-viewer.html: one file that opens one or two facts files from disk and shows the map, the findings, the AI tooling set up, the routes and hosts, the tables, the dependencies per service, the module graph, and what changed between two scans. The map is derived in the page by the same Go code, compiled to WebAssembly. The page makes no requests: its Content-Security-Policy allows none, and every script in it is listed by hash. The build is reproducible (Go 1.26.10, -trimpath, the committed lockfile): build it yourself and compare with dist/viewer/SHA256SUMS, or with the hash we publish.

Documentation

Licence

Apache License 2.0. Cernly is a trademark; the licence does not grant use of the name (TRADEMARKS.md).

Directories

Path Synopsis
Package archdoc writes architecture documentation from one scan and its map: Markdown with arc42 sections and C4 context and container views in Mermaid.
Package archdoc writes architecture documentation from one scan and its map: Markdown with arc42 sections and C4 context and container views in Mermaid.
Package cli is the open scanner's command line: scan one commit, derive its map, serve both to AI agents over MCP, compare a scan with a base scan the caller passes, write its bill of materials, write its architecture docs.
Package cli is the open scanner's command line: scan one commit, derive its map, serve both to AI agents over MCP, compare a scan with a base scan the caller passes, write its bill of materials, write its architecture docs.
cmd
cernly command
Command cernly is the open scanner: scan one commit, derive its map, serve both to AI agents over MCP.
Command cernly is the open scanner: scan one commit, derive its map, serve both to AI agents over MCP.
cernly-site command
Command cernly-site builds the developer docs at cernly.dev into a folder:
Command cernly-site builds the developer docs at cernly.dev into a folder:
cernly-viewer command
Command cernly-viewer is the local viewer's WebAssembly module.
Command cernly-viewer is the local viewer's WebAssembly module.
Package config reads the repo-side hint file and combines it with the operator's settings.
Package config reads the repo-side hint file and combines it with the operator's settings.
Package defaults holds the shipped configuration: file patterns, skipped folders, the data store table, heuristics, reserved domains, and the provider and agent catalogues.
Package defaults holds the shipped configuration: file patterns, skipped folders, the data store table, heuristics, reserved domains, and the provider and agent catalogues.
Package depview groups one scan's dependencies by service: the direct ones the attach rule puts on a service, and the transitive ones its manifest folders reach through the lockfiles.
Package depview groups one scan's dependencies by service: the direct ones the attach rule puts on a service, and the transitive ones its manifest folders reach through the lockfiles.
Package drift compares two scans and their maps: which facts and which conclusions were added, removed or changed.
Package drift compares two scans and their maps: which facts and which conclusions were added, removed or changed.
Package explain says what each finding means to someone who is not reading code, and what to do about it.
Package explain says what each finding means to someone who is not reading code, and what to do about it.
Package fact defines the scan output (schema cernly.scan/v1) and its canonical, deterministic encoding.
Package fact defines the scan output (schema cernly.scan/v1) and its canonical, deterministic encoding.
Package ghfilter matches GitHub Actions filter patterns (branches, tags, paths) as the filter pattern cheat sheet describes them.
Package ghfilter matches GitHub Actions filter patterns (branches, tags, paths) as the filter pattern cheat sheet describes them.
internal
caddyfile
Package caddyfile lexes and parses Caddyfiles for the caddy plugin (routes) and the env plugin (the {$VAR} names a Caddyfile reads), https://cernly.dev/how/plugins/.
Package caddyfile lexes and parses Caddyfiles for the caddy plugin (routes) and the env plugin (the {$VAR} names a Caddyfile reads), https://cernly.dev/how/plugins/.
composefile
Package composefile holds what the compose and command plugins share about Compose files: the names Compose picks by default and how a stack is named.
Package composefile holds what the compose and command plugins share about Compose files: the names Compose picks by default and how a stack is named.
dotnetsln
Package dotnetsln reads the project list of a .sln or .slnx file.
Package dotnetsln reads the project list of a .sln or .slnx file.
envname
Package envname says what an environment variable name looks like.
Package envname says what an environment variable name looks like.
hostname
Package hostname decides which hosts are public, for the plugins that keep a host and drop the rest of a value (env, outbound).
Package hostname decides which hosts are public, for the plugins that keep a host and drop the rest of a value (env, outbound).
imageref
Package imageref reads image references as written, ${VAR:-default} templates included.
Package imageref reads image references as written, ${VAR:-default} templates included.
jsread
Package jsread reads TypeScript and JavaScript files for the env and outbound plugins: the environment variable names the code reads and the public hosts it calls, is configured for, or mentions.
Package jsread reads TypeScript and JavaScript files for the env and outbound plugins: the environment variable names the code reads and the public hosts it calls, is configured for, or mentions.
nginxconf
Package nginxconf lexes and parses nginx configuration for the nginx plugin (routes) and the env plugin (the ${VAR} names an envsubst template reads).
Package nginxconf lexes and parses nginx configuration for the nginx plugin (routes) and the env plugin (the ${VAR} names an envsubst template reads).
prismaschema
Package prismaschema lexes and parses Prisma schema files for the prisma plugin (tables, columns) and the env plugin (the env("…") names a schema reads).
Package prismaschema lexes and parses Prisma schema files for the prisma plugin (tables, columns) and the env plugin (the env("…") names a schema reads).
pyread
Package pyread reads Python source for the env and outbound plugins: the environment variable names the code reads and the public hosts it calls, is configured for, or mentions.
Package pyread reads Python source for the env and outbound plugins: the environment variable names the code reads and the public hosts it calls, is configured for, or mentions.
redact
Package redact removes credentials from values read from a repo before they are stored in a fact.
Package redact removes credentials from values read from a repo before they are stored in a fact.
scaling
Package scaling checks in tests that work grows linearly with the input.
Package scaling checks in tests that work grows linearly with the input.
sqlddl
Package sqlddl reads SQL migrations without running them: a lexer splits statements, and a replay applies the DDL that shapes tables and columns to an in-memory schema.
Package sqlddl reads SQL migrations without running them: a lexer splits statements, and a replay applies the DDL that shapes tables and columns to an in-memory schema.
testfile
Package testfile tells test code from other code by each language's own convention, from the path alone (size, test_suite reuses it).
Package testfile tells test code from other code by each language's own convention, from the path alone (size, test_suite reuses it).
version
Package version classifies version strings into the schemes semver, calver, date, pseudo and unknown.
Package version classifies version strings into the schemes semver, calver, date, pseudo and unknown.
yamlnode
Package yamlnode holds the small helpers the plugins share for reading parsed YAML nodes.
Package yamlnode holds the small helpers the plugins share for reading parsed YAML nodes.
Package localview derives what a viewer shows for scans on the reader's own machine: the map, the findings' words and the stack labels for one scan, and what changed between two.
Package localview derives what a viewer shows for scans on the reader's own machine: the map, the findings' words and the stack labels for one scan, and what changed between two.
Package mcp serves one scan to AI agents over the Model Context Protocol.
Package mcp serves one scan to AI agents over the Model Context Protocol.
Package pipeline scans a commit and derives its map.
Package pipeline scans a commit and derives its map.
Package plugin defines the contract every extractor plugin follows: read tracked files, return facts with evidence, nothing else.
Package plugin defines the contract every extractor plugin follows: read tracked files, return facts with evidence, nothing else.
plugintest
Package plugintest is the golden-test harness for WebAssembly plugin authors.
Package plugintest is the golden-test harness for WebAssembly plugin authors.
sdk
Package sdk is what a WebAssembly plugin imports: the wire format between the scanner and a plugin, and a Main that reads the input from stdin and writes the output to stdout.
Package sdk is what a WebAssembly plugin imports: the wire format between the scanner and a plugin, and a Main that reads the input from stdin and writes the output to stdout.
wasm
Package wasm runs outside plugins: WebAssembly modules, signed with ed25519, loaded through wazero (pure Go, no cgo).
Package wasm runs outside plugins: WebAssembly modules, signed with ed25519, loaded through wazero (pure Go, no cgo).
plugins
agentconfig
Package agentconfig reports the AI coding tools a repo is set up for, from the configuration files they leave in it (.cursor/, AGENTS.md, CLAUDE.md, ...).
Package agentconfig reports the AI coding tools a repo is set up for, from the configuration files they leave in it (.cursor/, AGENTS.md, CLAUDE.md, ...).
all
Package all links every built-in plugin into the binary.
Package all links every built-in plugin into the binary.
caddy
Package caddy reads Caddyfiles: which addresses a repo serves and where each path goes.
Package caddy reads Caddyfiles: which addresses a repo serves and where each path goes.
command
Package command finds build and deploy commands (docker build, docker compose -f …) in workflow steps, shell scripts, Taskfiles, Makefiles and package.json scripts.
Package command finds build and deploy commands (docker build, docker compose -f …) in workflow steps, shell scripts, Taskfiles, Makefiles and package.json scripts.
compose
Package compose extracts services and data stores from Docker Compose files.
Package compose extracts services and data stores from Docker Compose files.
deps
Package deps extracts direct dependencies from Go and npm manifests.
Package deps extracts direct dependencies from Go and npm manifests.
dockerfile
Package dockerfile reads Dockerfiles with BuildKit's own parser (the one Docker uses) and reports, per buildable stage, the base images, what is copied in from the build context, and what gets built.
Package dockerfile reads Dockerfiles with BuildKit's own parser (the one Docker uses) and reports, per buildable stage, the base images, what is copied in from the build context, and what gets built.
dotnet
Package dotnet reads .NET source and project structure: test suites, the project graph and EF Core migrations, from the projects the msbuild reader finds.
Package dotnet reads .NET source and project structure: test suites, the project graph and EF Core migrations, from the projects the msbuild reader finds.
dotnet/msbuild
Package msbuild reads .NET project files the way MSBuild evaluates the parts Cernly needs: project discovery, SDK-style detection, the Directory.Build.props and Directory.Packages.props chain, properties, PackageReference, ProjectReference and packages.config.
Package msbuild reads .NET project files the way MSBuild evaluates the parts Cernly needs: project discovery, SDK-style detection, the Directory.Build.props and Directory.Packages.props chain, properties, PackageReference, ProjectReference and packages.config.
env
Package env reports environment variable names: from example env files, Compose files and Go code, each by its own parser.
Package env reports environment variable names: from example env files, Compose files and Go code, each by its own parser.
kubernetes
Package kubernetes is the Kubernetes tool adapter: plain manifests, Kustomize overlays and, partly, Helm charts become stacks; workloads (Deployment, StatefulSet, DaemonSet, Job, CronJob, Pod) become services or data stores, with the Services that select them as evidence; image references go through the normalisation.
Package kubernetes is the Kubernetes tool adapter: plain manifests, Kustomize overlays and, partly, Helm charts become stacks; workloads (Deployment, StatefulSet, DaemonSet, Job, CronJob, Pod) become services or data stores, with the Services that select them as evidence; image references go through the normalisation.
migrations
Package migrations reads SQL migrations and schema dumps into the tables and columns they leave behind: each migration set is replayed in order, in memory, by package sqlddl.
Package migrations reads SQL migrations and schema dumps into the tables and columns they leave behind: each migration set is replayed in order, in memory, by package sqlddl.
nginx
Package nginx reads nginx configuration into route facts, the same shape the caddy plugin gives: per server and location, what handles it (proxy_pass and the other *_pass directives, return, root/alias) and where a proxy sends it, upstream blocks resolved to their servers.
Package nginx reads nginx configuration into route facts, the same shape the caddy plugin gives: per server and location, what handles it (proxy_pass and the other *_pass directives, return, root/alias) and where a proxy sends it, upstream blocks resolved to their servers.
outbound
Package outbound reports the public hosts code points at, graded by what the parser can prove: a request (net/http in Go; fetch or axios in TypeScript and JavaScript), a configured default, or a mere mention.
Package outbound reports the public hosts code points at, graded by what the parser can prove: a request (net/http in Go; fetch or axios in TypeScript and JavaScript), a configured default, or a mere mention.
ownership
Package ownership reports who owns a repo, as the repo itself says it: the owners a CODEOWNERS file names, and the entities a Backstage catalog-info.yaml describes (name, kind, type, owner, system, lifecycle).
Package ownership reports who owns a repo, as the repo itself says it: the owners a CODEOWNERS file names, and the entities a Backstage catalog-info.yaml describes (name, kind, type, owner, system, lifecycle).
prisma
Package prisma reads Prisma schema files into the tables and columns the schema declares: one db_table per model, one db_column per field the database stores.
Package prisma reads Prisma schema files into the tables and columns the schema declares: one db_table per model, one db_column per field the database stores.
size
Package size counts source files and lines per folder, as context for the map: one source_size fact per folder and language, and one more for its test files (by the language's convention, internal/testfile), with every counted file as evidence (line 1 to its last line).
Package size counts source files and lines per folder, as context for the map: one source_size fact per folder and language, and one more for its test files (by the language's convention, internal/testfile), with every counted file as evidence (line 1 to its last line).
tests
Package tests reports test suites: the test files of each Go module, npm package and Python project, found by the language's own naming convention, with the framework the module declares.
Package tests reports test suites: the test files of each Go module, npm package and Python project, found by the language's own naming convention, with the framework the module declares.
traefik
Package traefik reads Traefik's routers into route facts, the shape the caddy and nginx plugins give, from its two common sources:
Package traefik reads Traefik's routers into route facts, the shape the caddy and nginx plugins give, from its two common sources:
Package repo gives plugins a read-only, deterministic view of one checkout.
Package repo gives plugins a read-only, deterministic view of one checkout.
repotest
Package repotest builds repo views for tests.
Package repotest builds repo views for tests.
Package rules derives the map (schema cernly.map/v1) from a scan's facts: links from services to their code, and which stack is production.
Package rules derives the map (schema cernly.map/v1) from a scan's facts: links from services to their code, and which stack is production.
Package sbom writes a CycloneDX 1.6 bill of materials from one scan and its map.
Package sbom writes a CycloneDX 1.6 bill of materials from one scan and its map.
Package schema embeds the published JSON schemas, so the scanner can validate what a WebAssembly plugin returns against the same file plugin authors read.
Package schema embeds the published JSON schemas, so the scanner can validate what a WebAssembly plugin returns against the same file plugin authors read.
scripts
archive command
Command archive packs one release folder into a .tar.gz or a .zip that is the same bytes on any host: entries sorted by name, owner 0, fixed modes (0755 for the cernly binary and folders, 0644 for the rest) and one fixed date.
Command archive packs one release folder into a .tar.gz or a .zip that is the same bytes on any host: entries sorted by name, owner 0, fixed modes (0755 for the cernly binary and folders, 0644 for the rest) and one fixed date.
Package site builds the developer docs at cernly.dev from Markdown pages: HTML in the brand's layout, each page's Markdown beside it, llms.txt, llms-full.txt, sitemap.xml, JSON-LD and the JSON Schemas.
Package site builds the developer docs at cernly.dev from Markdown pages: HTML in the brand's layout, each page's Markdown beside it, llms.txt, llms-full.txt, sitemap.xml, JSON-LD and the JSON Schemas.
wasmplugins
java command
Command java is the Java/Spring stack adapter, the first WebAssembly plugin: built with GOOS=wasip1 GOARCH=wasm, signed, and loaded by the scanner like any outside plugin.
Command java is the Java/Spring stack adapter, the first WebAssembly plugin: built with GOOS=wasip1 GOARCH=wasm, signed, and loaded by the scanner like any outside plugin.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL