What is ubCode?

ubCode is an X-as-Code engineering toolchain. One native engine helps you write, trace, check and publish requirements and documentation: live in your editor, in CI, and for your AI agents. It reads reStructuredText and MyST Markdown, indexes every need object and its relationships, and speaks the markup of Sphinx and Sphinx-Needs, so you can use it with Sphinx, or instead of it. (New to the vocabulary? Every bolded term on this site is defined in the Glossary.)

Note

Markdown is parsed when a project enables it through the [parse.parsers] configuration; Markdown (MyST) says what each flavour supports.

X-as-Code, and the part ubCode covers

X-as-Code keeps engineering artefacts — requirements, architecture, code, tests and their results, documentation, and in the wider practice also pipelines and environments — as versioned, reviewed text in Git, checked like code. ubCode covers the engineering-data layers: requirements, architecture (as needs and diagrams), code traces, tests and test results, documentation, and publishing them. Build pipelines, infrastructure and test environments stay with your CI and your own tools; x-as-code.useblocks.com describes the wider practice.

The diagram shows the layers ubCode covers, in trace order, with the documentation published from them, and, dashed, the layers that stay with your CI and tools.

        flowchart TB
    subgraph covered["ubCode"]
        direction TB
        subgraph data["linked, and checked in the editor and by ubc check in CI"]
            direction LR
            req["Requirements"] --> arch["Architecture"] --> code["Code traces"] --> tests["Tests"] --> results["Test results"]
        end
        data -- "published as" --> docs["Documentation<br/>HTML · PDF"]
    end
    subgraph outside["your CI and tools"]
        direction LR
        build["Software build"] ~~~ pipeline["CI pipelines"] ~~~ infra["Infrastructure,<br/>test environments"]
    end
    covered ~~~ outside
    classDef ub fill:#583eff,stroke:#583eff,color:#ffffff
    classDef other fill:transparent,stroke:#888888,stroke-dasharray:5 5
    class req,arch,code,tests,results,docs ub
    class build,pipeline,infra other
    style covered fill:transparent,stroke:#8a75ff,stroke-width:2px
    style data fill:transparent,stroke:#8a75ff
    style outside fill:transparent,stroke:#888888,stroke-dasharray:5 5
    

Kept as X-as-Code, engineering data can be checked the way code is. ubc check gives a deterministic verdict on links, schemas and required fields in a few seconds for this whole site, and exits non-zero on any warning or error; VS Code runs the same checks as you type and on every save. That is what lets people and AI agents work in a loop of write, check and fix (see Engineer with AI agents). The checks are formal — that a link exists and the data is valid — so whether a test really verifies its requirement still needs review, by people or by AI quality analysis against a rubric you set (experimental).

What problem does it solve?

Docs-as-code, the documentation layer of X-as-Code, puts requirements, specifications, test cases and documentation in the same repository as the code they describe. That is powerful, but it leaves four jobs to tooling, and ubCode takes on each of them:

  • Managing requirements and traceability — typed needs, links, schema validation, source-code and test traces, checked as you edit and gated in CI (see Manage requirements and traceability).

  • Publishing documentation — an HTML site and a PDF from the same sources, without Python (see Publish documentation).

  • Supporting an existing Sphinx project — live diagnostics, preview and navigation in the editor, and ubc check in CI, next to your Sphinx build (see Supercharge your Sphinx project).

  • Engineering with AI agents — AI does the writing, and the engine computes what is done and what comes next (see Engineer with AI agents).

Ways to use it

ubCode is not just a VS Code extension. The same engine is available through several interfaces, so you can pick what fits your workflow:

🧩 VS Code extension

Install the ubCode extension (also on Open VSX for Cursor, Kiro and VSCodium) for live diagnostics, previews, navigation, auto-completion, and graph views — right in your editor. See Installation for details.

🖥️ ubc CLI

A standalone binary that exposes the same engine on the command line. Run linting, build the needs index, diff two project revisions, or integrate checks into CI/CD pipelines — for example as part of a pre-commit hook or a pull-request gate. AI assistants can also drive the CLI to answer analysis questions about your requirements. See ubc CLI for download links and Using ubc in CI/CD for using it in CI/CD.

📄 HTML and PDF builders

ubc build html builds a static site and ubc build pdf a single PDF, from the same sources and without Sphinx. Both are Beta; see Building a static HTML site and Building a PDF.

🤖 MCP server

A Model Context Protocol server that gives AI assistants deep, structured access to your project’s requirements graph. See Model Context Protocol (MCP) server for details.

🤖 Pharaoh

ubCode’s agentic engineer, Experimental: ubc agent is its engine, with panels and a chat entry point in VS Code. See Pharaoh Agentic Engineer.

All of them share a single Rust core and the same ubproject.toml configuration, so results are consistent regardless of how you interact with the engine.

How it relates to Sphinx and Sphinx-Needs

Use ubCode with Sphinx, or instead of it.

  • Instead of Sphinx, ubCode builds the HTML site (ubc build html) and the PDF (ubc build pdf) itself; both builders are in beta.

  • With Sphinx, Sphinx can remain your documentation build system, and Sphinx-Needs your requirements-management extension, while ubCode gives you the analysis around them: diagnostics, preview, navigation, queries and CI checks.

  • Either way, ubCode re-implements the pipeline in Rust: it reads the same source files and the same need definitions, without running a Sphinx build.

Because ubCode does not execute Python, it relies on a declarative ubproject.toml configuration file rather than the Python-based conf.py. Starting from Sphinx-Needs 4.1, you can share configuration between both via the needs_from_toml option — see Coming from Sphinx-Needs for migration guidance.

Note

ubCode does not run Sphinx or any user Python code. It only reads RST files and known directives/roles. Custom Sphinx extensions that do not modify primary Sphinx-Needs data can still be used alongside ubCode.

Architecture at a glance

        flowchart TD
    core["`**Rust core engine**
    parsing · indexing · diagnostics · query`"]
    core --> ubc["`single native **ubc** binary`"]

    ubc -->|ubc serve lsp| lsp["language server"]
    ubc -->|ubc serve mcp| mcp["MCP server"]
    ubc -->|ubc check · diff · …| commands["direct CLI commands"]
    ubc -->|ubc build html · pdf| output["HTML site · PDF"]

    lsp --> vscode["VS Code extension"]
    mcp --> ai["`AI assistants
    (Copilot, etc.)`"]
    commands --> ci["terminal · CI/CD · pre-commit"]
    

The Rust engine handles all the heavy lifting: parsing RST, resolving need links, running lint checks, evaluating queries, and scanning source code for traceability markers. It is compiled into a single native ubc binary with no Python runtime: the VS Code extension bundles that binary and launches it as a language server (ubc serve lsp) and an MCP server (ubc serve mcp), while running ubc directly on the command line drives the very same engine.

Design trade-offs

To achieve real-time performance, ubCode makes deliberate trade-offs:

  • No Python execution — ubCode cannot run conf.py or custom Sphinx extensions. All configuration must be expressed declaratively in ubproject.toml.

  • Known directive/role set — ubCode understands a large set of Sphinx and Sphinx-Needs directives and roles, but directives added by third-party extensions need to be declared in the configuration.

  • Focus on primary data — ubCode indexes the primary traceability data (need objects, links, statuses, tags, and fields). Rendering-side features such as complex Sphinx-Needs visualizations are gradually being added.

These trade-offs are intentional and continuously minimized. See the Roadmap for upcoming improvements, Supported toolchain for the current feature coverage, and the differences register for every documented place where ubCode behaves differently from Sphinx.