Ontology Tools
A Claude Code skill for working with Turtle (.ttl) domain ontologies: validate structure, apply ontology to implementation decisions, browse and search terms, and resolve ttl:// references.
What You Get
Ontology Health Checks
Parse any .ttl file, verify syntax, count triples, and surface structural gaps—missing labels, missing ranges, undocumented invariants.
Naming Checks
validate.py --check-names --check-wording --check-header reports a label that is missing, repeated, CamelCase or capitalized; a name that repeats its type or mixes separators; a term without a definition; the articles, conjunctions, negations, verbs and abbreviations in a name; a subclass label without its superclass's; and a missing version IRI or replacement of a deprecated term, each with its rule (OBO Foundry principle 12, Schober et al. 2009, the W3C vocabulary principles). --changed-since REF checks only the terms a change touches; ot:exempt "<rule>: <reason>" exempts one term from one rule; errors exit 1.
Implementation Audits
Check code, schema, or architecture decisions against declared ontology axioms. Every check gets a verdict: ✅ PASS, ❌ FAIL, ⚠️ MISMATCH, or ⚠️ ONTOLOGY GAP.
Named Invariant Enforcement
Named invariants (*:Inv_*) are extracted automatically and checked against the codebase with grep evidence.
Namespace Inspection
List all terms in a given namespace prefix to audit coverage.
Positions in the File
scripts/locate.py gives line numbers instead of grep: the prefixes and version (header), the banner sections (outline), a term's line range and section (where), the terms whose literals match a pattern (text), and the line a new term of a type goes after (anchor).
Renaming a Term
scripts/rename.py renames a term in the TTL, sets its label, and rewrites its ttl:// and qname citations in the files you name; it lists the other terms that name it, which a --changed-since naming check reads next.
Quick Start
The Problem
Your project has a Turtle ontology that declares the domain model—classes, properties, invariants, cardinalities. Over time, code drifts from what the ontology says. Catching that drift manually is slow and error-prone.
The Solution: Automatic Validation
With ontology-tools, Claude checks the code against the ontology for you:
User: "Validate this PR against the ontology"
Claude (using ontology-tools):
→ Reads the .ttl file
→ Identifies relevant axioms and invariants
→ Greps the codebase for evidence
→ Reports each check as PASS/FAIL with file:line pointers
User gets: A structured report with an overall verdict
Trigger Phrases
The skill activates when you ask Claude to:
- "Validate against the ontology"
- "Check domain invariants"
- "Does this violate the ontology?"
- "Ontology gap / ontology review"
- "Audit the domain model"
Usage Scenarios
Scenario 1: Validate a New Column
You're adding a database column and want to confirm it fits the declared domain.
me: "Does adding a `processed_at` timestamp column violate the ontology?"
Claude:
→ Reads ontology.ttl
→ Checks rdfs:range and cardinality restrictions for time-related properties
→ Reports PASS or FAIL with the relevant axioms
Scenario 2: Audit the Ontology Itself
You edited the TTL and want to catch gaps before merging.
me: "Validate the ontology for completeness"
Claude:
→ Runs the validator script (syntax + triple count)
→ Checks for missing labels, comments, domain/range declarations
→ Lists every gap with its term URI
Scenario 3: Pre-PR Invariant Check
Before opening a pull request, confirm no named invariants are violated.
me: "Ontology review for this PR"
Claude:
→ Reads all Inv_* instances from the TTL
→ Greps relevant source files for evidence
→ Returns a summary table with per-invariant verdicts
Installation
From GitHub
claude plugin install https://github.com/full-stack-biz/ontology-tools --scope user
From Marketplace
/plugin marketplace add full-stack-biz/ontology-tools
/plugin install ontology-tools@ontology-tools
Local Development
claude --plugin-dir /path/to/ontology-tools
Requirements
- System: Requires
uv for running the Python validator script
- Python: 3.11 or higher
- Dependencies:
rdflib (installed automatically by uv)
How the Skill Works Internally
The validator script (skills/ontology-tools/scripts/validate.py):
- Parses the
.ttl file with rdflib
- Reports triple count, syntax errors with line numbers
- Optionally checks
rdfs:label coverage (--check-labels)
- Optionally checks
rdfs:range declarations (--check-ranges)
- Accepts a
--namespace flag to list all terms in a given prefix