GUIDE

Ontology-Driven Development in Practice

Start a project with an ontology, run every change through it, and let machines check the code against it. This guide shows the whole flow in diagrams, from the first file to a pipeline where people review the ontology and most code review is automated.

Requirements→Ontology→Agreement→Tests→Code→Checks→Merge
1

The ontology is the source of truth

Requirements and prompts feed the ontology. Code is built from the ontology.

In ontology-driven development (ODD), a small machine-readable ontology is written after the requirements and before the design. It records what exists (object types, properties, links) and how it may change (action types with parameters, rules, rejection conditions and side effects). Each element names the requirement IDs it realizes.

The ontology is not documentation that follows the code. It comes first, and everything else is built from it or checked against it.

INPUTS TO THE ONTOLOGY RequirementsREQ-001, NFR-001 … Issues, conversationsnew or changed needs Prompts to an agentnever straight to code Ontology *.oont.yaml object types · links action types · validations requirement IDs People review here BUILT FROM IT / CHECKED AGAINST IT Tests Code Agent tools & context CI checks
Figure 1. Requirements and prompts go into the ontology. Code, tests, agent tools and checks come out of it.
RULE 1

Change the ontology before the code. When behavior changes, the requirements and the ontology change first, in their own commit.

RULE 2

Implement from the ontology, never from the prompt. A request that the ontology does not cover is turned into ontology changes first.

RULE 3

Leave evidence. Commits, code, tests and the pull request show which element each change came from, so it can be checked without asking.

2

Getting started

Five steps from an empty repository (or an existing one) to an ontology that CI and agents use.

STEP 1InstallVS Code extensionoont CLIODD agent skill STEP 2Requirementsnumber themREQ-001 …requirements.md STEP 3First ontologytypes, links,actions, validations→ 0 errors, 0 warnings STEP 4Reviewon the diagram,with the business;record open questions STEP 5Wire it upCI: oont validateCLAUDE.md loadsskill + ontology
Figure 2. Getting started. After step 5, every change follows the loop in section 3.
  1. 01
    Install the tools

    Install the Ontology-Driven Development VS Code extension for diagnostics and the diagram. Install the oont CLI with npm install -D @yaggytter/object-ontology-cli. Copy the ontology-driven-development skill into your project, for example to skills/ontology-driven-development/.

  2. 02
    Number the requirements

    Copy the requirements template to ontology/requirements.md. In a new project, number what the user asks for. In an existing project, derive the requirements from what it already promises: user documentation, feature lists, policies and test names. Aim for 15–30 to start.

  3. 03
    Write the first ontology

    Nouns become object types, relations become link types, verbs become action types, business rules become validations. Put every requirement ID on the elements that realize it. In an existing project, write only behavior you confirmed in the code, and set x-implementedBy and x-tests to today's files.

    oont validate --strict ontology
    # 1 file checked: 0 errors, 0 warnings
  4. 04
    Review it with people

    Open the diagram (Cmd+Alt+O / Ctrl+Alt+O). Walk through object types, actions and their rejection conditions with the people who know the business. Questions without an answer go to the "Open questions" list instead of being guessed.

  5. 05
    Wire it into CI and the agent

    Add oont validate --strict ontology to CI. Paste the skill's CLAUDE.md snippet so the agent loads the workflow and the ontology in every session.

    repository/
    ├── CLAUDE.md                     # project settings; loads the skill and the ontology
    ├── ontology/
    │   ├── app.oont.yaml             # the source of truth
    │   └── requirements.md           # requirement bodies and open questions
    ├── skills/ontology-driven-development/
    └── src/ …                        # built from the ontology
3

Everyday development

Every change in behavior goes through the ontology. People decide the "what"; the agent builds the "how".

PERSON AI AGENT CI Requestissue or prompt Agree on theontology diff Escalations onlysee section 5 1Find theimpact 2Change REQs+ ontology 3Tests fromvalidations 4Implementas written 5Evidence +trace report oont validate--strict Gates G1–G7+ ontology-based AI review missing concept → back to the ontology
Figure 3. The development loop. The only human decision in the normal path is agreeing on the ontology diff.

1–2. Ontology first

  • Read the ontology and list the requirements and elements the request touches.
  • Behavior that fits no element means a missing concept. Add it.
  • Change requirements.md, the registry and the elements. Write each rejection condition as a validation with description and expr.
  • Run oont validate --strict, commit the ontology on its own, and agree on the diff.

3–5. Code from the ontology

  • For each validation, one test where it holds and one where it rejects.
  • Implement exactly the parameters, rules, validations and side effects as written. If something is missing, go back to step 2.
  • Leave the evidence below and write the trace report into the pull request.
REQUIREMENTREQ-002one item lentat a time ONTOLOGYborrowItemvalidation:status == available TEST NAMEREQ-002borrowItem:rejects a lent item CODE// Ontology:actionTypes.borrowItem COMMITOntology:Requirements:trailers PULL REQUESTtracetable Each link is plain text, so a script or a reviewer can follow it in either direction.
Figure 4. The evidence chain. Any step can be traced back to the requirement and forward to the code.

Example: one change, end to end

A request arrives: "an item can be lent to only one member at a time". The agent does not open the code. It changes the ontology first:

# ontology/app.oont.yaml  (commit 1: docs(ontology): add REQ-002 to borrowItem)
requirements:
  REQ-002: { title: An item can be lent to one member at a time, source: requirements.md }
actionTypes:
  borrowItem:
    requirements: [REQ-001, REQ-002]
    x-implementedBy: [src/lending/borrowItem.ts]
    x-tests: [src/lending/borrowItem.test.ts]
    validations:
      - description: Only an available item can be borrowed.
        requirements: [REQ-002]
        expr: "item.status == 'available'"

After the ontology diff is agreed, the tests and the code follow, and both point back to the element:

// src/lending/borrowItem.test.ts
it("REQ-002 borrowItem: rejects an item that is already lent", …)

// src/lending/borrowItem.ts
// Ontology: actionTypes.borrowItem (REQ-001, REQ-002)
export function borrowItem(item: Item, member: Member): Item { … }

# commit 2
feat(lending): reject borrowing an item that is already lent

Ontology: actionTypes.borrowItem
Requirements: REQ-002
ElementRequirementsOntology commitImplemented inTests
actionTypes.borrowItemREQ-001, REQ-002a1b2c3dsrc/lending/borrowItem.tsborrowItem.test.ts (2 tests)

The trace report in the pull request. Below it: oont validate --strict 0/0 and the test result.

4

Ontology checks in CI/CD

Turn the rules into gates that fail the build. NOW works with today's tools. G7 also needs an agent that you run.

Pullrequest G1Ontologyvalidoont validate--strictNOW G2Trace-abilityoont trace--strictNOW G3Ontologyfirstoont commitstrailersNOW G4Validationcoverageoont coverage--strictNOW G5Generatedin syncoont export +git diffNOW G6Testsyour testcommandNOW G7AI reviewoont review-context +an agentNOW
Figure 5. Deterministic gates first, the AI review last. A failure at any gate stops the pipeline.
GateWhat it provesHow
G1 NOWThe ontology is well-formed, every reference resolves, and every requirement is realized by some element.oont validate --strict ontology
G2 NOWEvery action type says where it is implemented and tested, and those files exist.oont trace --strict ontology from the repository root. Run it on the head of the pull request: the ontology commit may name files that a later commit adds.
G3 NOWThe ontology came first: every element a code commit names in its Ontology: trailer was already in the ontology before that commit, and its Requirements: IDs are in the registry.oont commits <base>..<head> --ontology ontology/app.oont.yaml --code src. A commit with no behavior change says Ontology: none. --since skips history from before the trailers.
G4 NOWEach requirement that a validation realizes is named, with its action, in a test of that action.oont coverage --strict ontology, with tests named like REQ-002 borrowItem: rejects ….
G5 NOWAgent tool definitions and the context summary checked into the repository match the ontology.oont export tools / summary, then git diff --exit-code.
G6 NOWThe behavior described by the validations holds.The project's test command (tests named after requirements and elements).
G7 NOWThe diff does what the named elements say, and nothing they do not say.oont review-context writes the material; an agent other than the author reviews it with the skill's review guide. See section 5.

A GitHub Actions example

G1–G5 use only the oont CLI (G3 and G7 need the full history: fetch-depth: 0). The G7 step only writes the review context; running the agent on it depends on your setup (see section 5). Adjust the paths to your project.

name: ontology-gates
on: pull_request
jobs:
  gates:
    runs-on: ubuntu-latest
    env:
      ONTOLOGY: ontology/app.oont.yaml
    steps:
      - uses: actions/checkout@v4
        with: { fetch-depth: 0 }
      - uses: actions/setup-node@v4
        with: { node-version: 20 }
      - run: npm install -g @yaggytter/object-ontology-cli@0.7

      - name: G1 ontology is valid
        run: oont validate --strict ontology

      - name: G2 traceability
        run: oont trace --strict ontology

      - name: G3 ontology first
        run: |
          oont commits "${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}" \
            --ontology "$ONTOLOGY" --code src

      - name: G4 validation coverage
        run: oont coverage --strict ontology

      - name: G5 generated artifacts are in sync
        run: |
          oont export tools "$ONTOLOGY" -o generated/agent-tools.json
          oont export summary "$ONTOLOGY" -o generated/ontology-summary.md
          git diff --exit-code generated/

      - name: G6 tests
        run: npm test

      # G7: the material for the AI review; an agent reviews it (section 5)
      - name: G7 review context
        run: |
          oont review-context "${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}" \
            --ontology "$ONTOLOGY" --code src -o review-context.md
LIMITS

The tools do not evaluate validation expr; it documents the rule for people and agents. G4 checks that a requirement is tested, not that the test is right. G3 trusts the Ontology: none claim; G7 is where that claim is checked.

5

Toward a software factory

Proposed practices for making most human code review unnecessary. People review the ontology; machines review the code against it.

Code review is expensive because the reviewer has to rebuild the intent from the diff. In ODD, the intent is already written down and agreed: it is the ontology. That lets us split review in two. People review the "what", the ontology diff, where business knowledge is needed. Machines review the "how", whether the code matches the agreed ontology, which can be checked step by step.

PROPOSAL The review material (oont review-context) and the review guide in the agent skill are available now. Routing, auto-merge and the metrics below are practices to try.

LAYER 0 · DETERMINISTIC Gates G1–G6: ontology, trace, coverage, sync, tests Same input, same result. Blocks automatically. Every change. LAYER 1 · AI REVIEW (G7) Does the diff match the named elements, and only them? Findings must cite an element; independent of the author agent. LAYER 2 · PEOPLE Ontology diffs and escalations only Business decisions, not line-by-line code reading.
Figure 6. The review funnel. Each layer handles what the layer above cannot decide.

Route each change by what it changes

ChangeRequired reviewMerge
Ontology diff: a new concept, action, validation or requirementPEOPLE The domain owner approves the ontology. The AI review checks it for contradictions and open questions.Human approval
Code that implements an already-approved ontology changeLayer 0 passes and the AI review has no blocking findings.Automatic
No change in behavior (Ontology: none): refactoring, tests, dependenciesLayer 0 passes and the AI review confirms that behavior did not change.Automatic
The AI review finds behavior that no element describes, or a conflict with the ontologyPEOPLE Decide: add it to the ontology, or remove it from the code.Human decision
Touches a cross-cutting requirement (NFR-: security, privacy, accessibility)PEOPLE A person reviews, even if everything passes.Human approval

Deterministic review from the ontology

  • Generate, then diff. Types, schemas, API contracts and agent tool definitions are generated from the ontology. A hand-made change to them fails G5.
  • Test skeletons per validation. Generate a "holds" and a "rejects" test stub for every validation, so a missing test is a visible gap, not an oversight.
  • Impact by query. Run SPARQL over the ontology, for example "which actions modify Booking?", to decide which tests and which owners a change involves.
  • Owners by element. Map object types and actions to owners, like CODEOWNERS but for concepts, so the right person is asked only when an ontology diff touches their area.

AI review against the ontology

  • Grounded input. Give the reviewer the output of oont review-context (commits, trailers, the named elements as written, their requirements, the diffs) and the ontology summary (oont export summary). Nothing else defines "correct".
  • Narrow questions. For each named element: do parameters, rules, validations and side effects match? Is there behavior no element describes? Is an Ontology: none claim true?
  • Structured, citable findings. Each finding names an element path and the lines involved. Findings that cite no element are dropped; this removes most noise.
  • Independent and verified. Run the reviewer separately from the agent that wrote the code, and have a second pass try to disprove each blocking finding before it blocks.
{ "element": "actionTypes.borrowItem",
  "verdict": "mismatch",
  "kind": "undeclared-behavior",
  "evidence": "src/lending/borrowItem.ts:42 sends an email; sideEffects lists only the return date notice",
  "action": "add the side effect to the ontology, or remove it from the code",
  "blocking": true }

An example finding. Because it names an element and a line, both a person and a script can check it.

Roll it out step by step

  1. Shadow mode. Run the AI review as comments only. Compare their findings with human reviews.
  2. Block on deterministic gates. Make Layer 0 required.
  3. Auto-merge the safest route. Start with Ontology: none changes, then implementation of approved ontology diffs.
  4. Keep people on the ontology. Human approval of ontology diffs stays required.

Measure and adjust

  • Share of pull requests merged without human code review.
  • Defects found after merge, and for each: was the ontology wrong, was a gate missing, or did the review miss it?
  • False positives of the AI review, by finding kind.
  • Time from an agreed ontology diff to merge.

A defect traced to the ontology is fixed in the ontology. A defect that slipped past the gates becomes a new gate.

CAVEATS
  • An ontology can be wrong. That is why people own it, and why it gets the human review that code no longer does.
  • AI review is probabilistic. Never let it be the only gate for security, privacy or data loss.
  • Start where the ontology is mature. A thin ontology gives the reviewers little to check against.