Skip to main content

unifold: architecture as code

Your project structure is your architecture. Keep your documentation, architecture, and project structure aligned.

A folder with a unifold.yaml is a unit: it declares what it provides and what it needs, next to the code, and the unit above connects every need to a provider. The unifold tool checks that the map is consistent and generates the diagrams, so nobody draws them and they cannot disagree with the files. Every unit keeps its documents in the same places, so that a person or a coding agent can understand one folder without reading its neighbours.

Why

One large architecture document, one root file for agents and a wiki beside the code go stale, and neither a newcomer nor a coding agent can take them in. Here the knowledge about a folder is in that folder. Structure is declared once and generated, because it is cheap to derive and expensive to keep correct by hand. Reasons are written, because they cannot be derived, and because nobody should make the same mistake twice.

The standard is explainable in one minute and adoptable in five. That is why the normative text is one page, and why everything else is reference, explanation or a tutorial.

How it works

# billing/unifold.yaml
summary: Creates invoices
needs:
  clock:
    summary: A time source
    contract: ../docs/references/clock.md
# platform/unifold.yaml
summary: Shared runtime services
capabilities:
  clock:
    summary: The current time
    contract: ../docs/references/clock.md
# unifold.yaml in the repository root
unifold: "0.2"
name: shop
summary: Shop backend
wiring:
  billing.clock: platform.clock

billing says what it needs, never who supplies it; the root connects the need to platform. Both sides name one document, docs/references/clock.md of the root: the contract of the connection, which says what a clock gives and in which form. unifold check reads the three manifests and writes the component diagram. It fails on a need without a provider, and on two sides that name different contracts. Without the wiring line in the root:

error W2 unifold.yaml: need 'billing.clock' has no provider
    fix: Add `billing.clock: platform.clock` to the wiring.

unifold show billing prints the unit, its need and who finally provides it. The tutorial Your first map takes fifteen minutes.

What a unit has

File What it is
unifold.yaml The manifest: what the unit provides and needs, and the wiring of its children. Checked against the other manifests.
README.md The front page: what the unit is for, and why it is built this way. The contracts say what can be relied on.
docs/ Everything else written about the unit, in fixed places sorted by what the reader is doing: tutorials, skills, references, explanation, decisions. A file exists only when it has content.
AGENTS.md Generated: where the documents and skills of the unit are, for coding agents.

How people use it

A newcomer opens a folder and reads its README.md. docs/tutorials/ teaches, docs/skills/ says how to do a task, docs/references/ holds the facts, docs/explanation/ the reasoning, the invariants, the runtime, the deployment and the risks, and docs/decisions/ the choices. A reviewer runs unifold check and works through the review checklist.

How agents use it

unifold init --agents installs the two skills, writes their stubs into .agents/skills/ and .claude/skills/, and adds the unifold block to the root AGENTS.md. Every unit's AGENTS.md is generated: a pointer to README.md, the documents by kind, the skills. Most agents read AGENTS.md and find the stubs; Kiro and Aider do not (agents). Every agent with a shell can run unifold show, which prints a folder's capabilities, needs and resolved neighbours, as text or JSON.

What this repository provides

The standard

The standard on one page, spec.md, with the reference chapters beside it and a JSON Schema for the manifest. Published at unifold.md.

The skills

Two skills in the Agent Skills format. unifold, with file templates, teaches an agent to find its unit, read the right files, change manifests and documents, and check the result. unifold-convert brings an existing repository into the map: the agent chooses the units, writes their manifests, and compares them with the code. No script derives units from code.

The tool

The reference tool, described in tool.md and tested by tests/conformance.py. It checks manifests, wiring, contracts and documents, and generates the diagrams and the AGENTS.md files. A GitHub Action and pre-commit hooks run it.

Questions

Do I need the tool? Anyone can implement the standard, but its two promises, "checked" and "generated", need a checker. The reference tool is one Python file.

Do I need an AI agent? No. The files are YAML and Markdown.

Does it read my code? No. It reads the unifold.yaml files and the Markdown documents, so your code may be in any language. Keeping the code and the map in step is part of every change and its review.

Do I have to write documentation? Every unit has a README.md that says what it is for and why. Everything else in docs/ is written when there is something to say.

Does it fit a project with one package? Yes: a project of one unit. The map is one box; unifold defines how to structure your docs (requirements).

What ends up in my repository? The unifold.yaml files, the generated diagrams and the generated AGENTS.md of every unit. The standard is not copied; the root manifest names its version. With --agents, also the skills, the tool and the stubs.

What about my docs/ folder, docs site and ADR tool? docs/ is where unifold keeps the documents, sorted by kind, and a software artifact can be built from it. Existing decision records move to docs/decisions/ (documents).

Needs

Python

Python 3.9 or newer with PyYAML, for the tool and the tests. The standard itself needs nothing.

Commands

# test the tool
python3 tests/conformance.py
# check an example
python3 docs/skills/unifold/scripts/unifold.py check examples/plantwatch
# build the site and check its links
python3 site/build.py --check
Kind Pages
The standard spec.md, the standard on one page; unifold.schema.json
Reference documents, writing, agents, tool, tool JSON, rules
Explanation requirements, reasoning, wiring, invariants, risks, decisions
Tutorial Your first map
Examples slugline, a tested Cargo workspace; plantwatch, a design written before any code, with every document convention

Contributing and licence

Changes to the standard are proposed as decision records; see CONTRIBUTING.md and the decisions.

Licensed under either of the Apache License, Version 2.0 (LICENSE-APACHE) or the MIT license (LICENSE-MIT), at your option. The templates of the skill and everything the tool generates may be used without attribution. Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this work by you shall be dual licensed as above, without any additional terms or conditions.

Metadata

Release files for unifold 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for unifold 0.2.0
File Size Uploaded Provenance Actions
unifold-0.2.0.tar.gz 75.3 kB Without provenance Details for unifold-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for unifold 0.2.0
File Interpreter ABI Platform Actions
unifold-0.2.0-py3-none-any.whl Python 3 none any Details for unifold-0.2.0-py3-none-any.whl

Total release size: 154.1 kB

Release files / unifold-0.2.0.tar.gz

Download URL unifold-0.2.0.tar.gz
Size 75.3 kB
Tags Source
SHA-256 checksum
How to use checksums
dc210d32eee2c01fa8ff12202e90a99b3db5511ebc6937e6df10123dac14f6a2
BLAKE2b-256 checksum
How to use checksums
0a9ef4651f5fda20f2271adfcc0b15c357c1ec18d94e3b3dbdadb29967e266c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / unifold-0.2.0-py3-none-any.whl

Download URL unifold-0.2.0-py3-none-any.whl
Size 78.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
faec123e0383a0735987ad194adcef17c4910bbb23552dcc27f5227dc9f17cda
BLAKE2b-256 checksum
How to use checksums
0443856622e97b80c256871d52843a396e88a4c233f27f833881870731153e71
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for unifold 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page