SuperAPIAI Directory

tnl

github.com · AI coding

TNL (Typed Natural Language): per-feature English contracts that coding agents can look up, propose edits to and verify implementations against.

Open website Alternatives
PricingOpen source开源项目(可免费自部署)
PlatformsLinux

About this tool

TNL (Typed Natural Language) is a structured English contract scheme for AI coding agents, used to have agents implement features according to explicit, persistable, machine-verifiable contracts.

Purpose During development, AI coding agents often silently make design decisions, deviate from the original plan, and lose context at the end of a session. TNL aims to solve this problem: establish an English contract with a fixed schema for each feature, proposed by the agent, approved by the user, saved to disk, and read in every future session. The author likens it to Claude Code's plan mode, but more compact, persistable, and machine-verifiable.

Main capabilities The schema of a TNL contract contains seven fields:

  • id / title: what the feature is
  • scope: feature-level or repository-level
  • paths: the files that this change is allowed to touch
  • surfaces: named external interfaces (CLI commands, routes, MCP tools)
  • behaviors: numbered MUST / SHOULD / MAY clauses, i.e., the contract body
  • non-goals: what is explicitly out of scope
  • rationale: the reason, for future readers' reference

A contract file is divided into three regions: the machine region (id, paths, surfaces), the contract region (behaviors, including RFC 2119 keywords and [semantic] / [test: ...] prefixes), and the human region (intent, non-goals, rationale).

behaviors uses RFC 2119 keywords: MUST / MUST NOT are hard requirements, SHOULD / SHOULD NOT are strong preferences, and MAY is permission. Clause prefixes include: [semantic] indicates that verification requires judgment (non-structural); [test: <file>::<name>] indicates binding the clause to a named test, and tnl verify checks whether that test still exists.

How to use Every feature request (new or modification) goes through 7 steps:

  1. Scope: the agent scans tnl/ for files whose paths overlap with the request; if any exist, it is an edit, otherwise it is a new TNL.
  2. Clarify: when requirements are ambiguous, the agent asks questions first.
  3. Propose: the agent in chatoutputs the complete TNL content inline; at this point nothing is written to disk.
  4. Wait for approval: the user reviews, gives feedback, and approves; nothing is written before approval is obtained.
  5. Save: the agent writes the approved TNL to tnl/<slug>.tnl.
  6. Implement: the agent writes code and tests according to the contract, with paths limiting the scope of changes.
  7. Self-attest: the agent lists each MUST clause and where it is satisfied; silent omissions are considered unsatisfied.

Subsequent work will return to "edit existing TNL" at step 1, and the next session directly reads the approved contract as context, rather than rediscovering design decisions from the code.

Integration No new tools, new agents, or new workflows are needed; TNL can be plugged into the agent you are already using. Claude Code, Codex, Gemini, and Cursor can get first-class tnl init support (including stanza + hooks + MCP). Any agent that can read a Markdown instruction file can be integrated manually by copying in two steps: copy tnl/workflow.tnl from the repository to the project's tnl/workflow.tnl; paste the TNL workflow stanza (i.e., the block below <!-- tnl:workflow-stanza --> that tnl init --agent claude writes into CLAUDE.md) into the agent's instruction file. tnl verify, the PreToolUse hook that re-presents the contract mid-edit, and the MCP server are all optional layers.

Minimal installation (tnl init) writes only: the tnl/ directory, the tnl/workflow.tnl baseline session principles, and appends the TNL workflow stanza to CLAUDE.md. For Codex use --agent codex (writes AGENTS.md), for Gemini use --agent gemini (writes GEMINI.md), for Cursor use --agent cursor (writes AGENTS.md + .cursor/mcp.json). Without --agent, init auto-detects the target (.claude/ → Claude; AGENTS.md → Codex; GEMINI.md → Gemini; .cursor/ → Cursor). Repeatedly running tnl init is safe and idempotent; existing files are detected and upgraded as the template evolves.

tnl verify runs two layers of checks: Layer 1 checks whether paths and dependencies exist; Layer 2 checks test binding integrity—whether the test referenced by each [test:] annotation still exists. If either layer fails, the exit code is 2, which CI can use as a gate.

MCP integration tnl init automatically registers the TNL MCP server with supported agents. After registration, the agent gains six tools. MCP can also be run manually.

Improvements over plan mode

  • Structure: seven fixed fields, so reviewers see the same content every time and agents produce a consistent shape every time.
  • Persistence: plan mode's output is a chat message that disappears when the session ends; TNL is a disk file that coexists with the code, so the next session reads the contract instead of re-analyzing the source code.
  • Execution: each MUST clause maps to a file or test when self-proving; tnl verify checks that paths exist and test bindings are resolvable; the PreToolUse hook re-injects the contract on every Edit/Write to prevent silent agent drift.
  • Incremental adoption: no bulk migration is needed; the next feature uses TNL while the rest of the repository remains unchanged, and the knowledge base accumulates as work proceeds.

Use cases Suitable for teams or individuals using AI coding agents to develop medium-sized codebases (the example in the text is a 16KLOC Python codebase) who want the agent's design decisions to be explicit, persistent, and verifiable.

Limitations and caveats TNL requires Node 20 or higher. The author's A/B evaluation shows (small sample of 2–3 per cell, LLM sessions are noisy, and the tool was built by the author): TNL outperformed the baseline in every model pairing comparison, with a gap of +3 to +6 scenarios. The stronger the model, the smaller the gap. TNL runs with 15–38 explicit MUST clauses encoded before writing code. In subsequent tasks, TNL agents reuse existing contracts (4/4 samples edited existing TNL), while baseline agents must reread the code each time. The project uses the MIT license.

The specific content required, such as Node 20+, the MIT license, and the evaluation report, comes from the source material; other feature details, charging model, pricing, and platform support scope are not provided in the source material.

Up/Down to navigate · Enter to open · ESC to closeBrowse all tools