Structural Coherence Engineering

AI writes great code.
TRACE keeps it
coherent.

Files drift across sessions. Anchors change but consumers don't. Docs fall behind.
TRACE enforces structural integrity — automatically.

$npm install -g trace-coherenceclick to copy
GitHub
~/my-project
$ trace gate start
 
━━━ Start Gate — MyProject ━━━
 
TRACE state exists
Baseline tests passing (52/52)
No unresolved debt (0/5)
Integrity checksums verified
Config validation passed
AI context generated
 
GATE PASSED Session open.
The Problem

AI doesn't remember what it broke.

Every AI-assisted session operates without memory of what depends on what.

Anchor Drift

AI modifies a core interface. Six files depend on it. They silently break.

Context Loss

Session crashes or token limit hits. The AI has no idea where you left off.

Silent Regressions

Tests removed. Complexity creeps in. Docs fall behind. Nobody notices until production breaks.

What your AI doesn't know
user.model.ts changed — 6 consumers stale
auth.service.ts removed a test
cart.controller.ts now 680 lines
API docs not updated in 4 sessions
Last session ended mid-refactor
The Framework

Five pillars of structural coherence.

Automated, gate-enforced checks at every session boundary.

T
Truth Anchoring
One authoritative source per concept. Change the anchor, all consumers must update.
R
Registry Enforcement
Documentation is a verified artifact, not an afterthought.
A
Automated Verification
Tiered testing that grows. Tests never shrink.
C
Controlled Evolution
Complexity thresholds, auto-calibrated to your project.
E
Execution Contracts
Every change type has preconditions and postconditions.
With TRACE — gate end output
Anchors coherent (12/12)
All consumers synced
Tests: 52/52 passing
Complexity within thresholds
Docs updated
Lint + typecheck passed
Integrity checksums regenerated
Getting Started

New project or existing — pick your track.

Full enforcement from day one, or gradual adoption with zero disruption.

Track 1 — New Projects

Full Enforcement

trace init

Scaffolds everything. Gates default to "block." Define anchors, run gate start, build.

Gates: Block mode
Track 2 — Existing Projects

Clean as You Code

trace scan

Auto-detects anchors, consumers, tests, quality tools. Old code gets a baseline pass. Only new code enforced.

Gates: Warn mode (gradual)

Every session, four steps.

Gate Start

Validates state, integrity, debt.
Generates AI context.

Build

Code with checkpoints.
Auto-observation captures changes.

Gate End

5-pillar check, quality tools,
consumer sync, planning.

Ship

Handoff ready.
Next session cold-starts cleanly.

The CLI — 28 commands · 1 dependency · 53 KB

Everything you need. Nothing you don't.

Works with any language, any AI tool, any CI system.

CommandWhat it does
Onboarding
trace initNew project — full enforcement from day one
trace scanExisting project — auto-detection + baseline
Coherence
trace checkFull 5-pillar coherence validation
trace statusQuick health overview
trace deps <id>Dependency graph + transitive impact analysis
trace impact <id>Pre-work blast radius + consumer sync snapshot
trace searchFull-text search across all TRACE artifacts
Session
trace gate startIntegrity + config validation + AI context (supports --scope)
trace gate endQuality tools + consumer sync + planning + metrics
trace checkpointCrash recovery + auto-observation via git diff
trace overrideEmergency bypass with tracked debt
Planning
trace planKanban-style backlog board in YAML
trace plan addAdd item with priority and sprint
trace plan moveMove item between status columns
trace plan releaseAuto-generate release notes from completed items
CI/CD & Maintenance
trace ciPR-scoped analysis with JSON + GitHub PR commenting
trace metricsOutcome analysis + threshold calibration
trace integritySHA-256 tamper detection for TRACE files
trace validateConfig validation with "did you mean?" suggestions
trace upgradeSchema migration — add missing sections safely
trace watchFile monitor + auto-session when AI skips gates
trace licenseScan dependencies for license compliance
trace deps auditDependency governance (policy, security, audit)
AI Process Enforcement
trace hook installPre-commit hook — blocks incoherent commits
trace hook uninstallRemove the pre-commit hook
trace hook statusCheck if hook is active
MCP Server
trace mcpStart MCP server (AI calls TRACE automatically)
trace mcp setupShow config for Claude Code, Cursor, Kiro
Security

Zero network calls. Zero telemetry.

Reads file structure, not file content. Nothing phones home.

Built-in Protection

SHA-256 integrity checksums at every gate
Consumer sync blocks stale drift
License compliance scanning
CI enforcement on every PR
Enterprise compliance
GDPR — processes zero personal data
SOC2 — all data stays local
ISO 27001 — integrity verification built in
HIPAA / PCI — not applicable (no PII/PHI)
Autonomous AI Integration

TRACE works without you running commands.

Connect the MCP server to your AI tool. TRACE checks impact before changes, validates coherence after, and audits dependencies automatically. You never type trace gate start again.

MCP Server

trace mcp exposes 6 tools to your AI. It reads context, checks impact, validates coherence, and audits deps — all automatically.

AI Instructions

AI_INSTRUCTIONS.md tells AI to follow gates with mandatory gate statements. Behavioral nudge for tools without MCP.

Auto-Session Watch

trace watch detects ungated file changes, auto-opens sessions, logs to PROJECT_LOG. History never lost.

Pre-Commit Hook

trace hook install blocks incoherent commits. The hard stop that catches everything else.

FAQ

Common questions, straight answers.

Does TRACE increase token usage?
About 1,300 to 2,100 tokens per session with built-in optimizations: scoped context (only load relevant anchors), brief check mode (one-line result when coherent), smart deduplication (skip if context is fresh), and handoff truncation (last 3 entries only). One prevented drift incident saves 50,000+ tokens of debugging.
Does it work with my language / AI tool / CI system?
Yes. Language-agnostic (TypeScript, Python, Go, Java, Rust), tool-agnostic (Claude, Copilot, Cursor, ChatGPT), and CI-agnostic (GitHub Actions, GitLab CI, Jenkins, CircleCI).
How hard is it to adopt on an existing project?
Run trace scan and you're started. Auto-detects anchors, consumers, tests, quality tools. Uses "Clean as You Code" so only new code is enforced.
What about AI tools that skip TRACE gates?
This is expected. TRACE handles it with three layers: AI_INSTRUCTIONS.md tells the AI to follow gates, trace watch captures changes even when AI skips gates, and trace hook install blocks incoherent commits. No single layer is enough. All three together close the gap.
What about dependency governance?
trace deps audit checks all packages against configurable policy rules: blocked packages, license restrictions, staleness, and security vulnerabilities. Three modes: strict (allowlist only), moderate (rule-based), and permissive (flag only). Runs automatically at gate end.
How many dependencies?
One. The yaml package. Everything else is Node.js core. 53 KB compressed.
From the Blog

Why we built TRACE. How it works.

Deep dives, real-world stories, and practical guides.

Start now

Structure over discipline.
Enforcement over intention.

AI systems are stateless. Human memory is unreliable. TRACE creates persistent structural memory for your codebase.

$ npm install -g trace-coherence

View on GitHub