ntntlang/ntnt

ntntlang/ntnt

The NTNT Programming Language

  • Stars: 8
  • Forks: 1
  • Watchers: 8
  • Open issues: 4
  • License: Apache License 2.0
  • Homepage: https://ntnt-lang.org
  • Default branch: main
  • Created: 2026-01-05T23:08:44Z

Languages

  • HTML
  • PowerShell
  • Python
  • Rust
  • Shell

Top Contributors

  • larimonious (253 contributions)
  • joshcramer (174 contributions)

README

NTNT Programming Language

NTNT (/ɪnˈtɛnt/) is an open-source agent-native language with Intent-Driven Development built in. You define constraints and expected behavior. Agents implement. NTNT verifies continuously.

Early Stage: NTNT is in active development. The language is stable and running production apps, but expect breaking changes between minor versions.

Quick Start

From install to verified app in five prompts. Pick your tool, copy the prompt. Your agent handles the install, the syntax, and the demo.

Prompt 1 — Your First App:

Install NTNT (curl -sSf https://raw.githubusercontent.com/ntntlang/ntnt/main/install.sh | bash),
then run `ntnt learn <your-platform>` and read the generated rules before writing any code.

Build a web app in server.tnt: a GET / that returns a greeting and a GET /api/status that returns
JSON. Add a requires contract on one handler. Make the app look good. Write a server.intent file
with scenarios for both routes. Run `ntnt intent check server.tnt` until all pass, then
`ntnt run server.tnt`. Respond with the URL of the running app.

Replace with claude-code, codex, cursor, or copilot. The ntnt learn command generates platform-native config files so your agent loads the rules every session.

Prompt 2 — Add a Database:

Add a SQLite database to the app. Create a messages table, add POST /messages to save a message
and GET /messages to list them. Update server.intent with scenarios for both endpoints. Run
`ntnt intent check server.tnt` until all pass. Add a link to the homepage to /messages and a
form that posts a new message.

Prompt 3 — Add Authentication:

Add session-based authentication using cookies and SQLite. Create a login page, protect the
homepage and /messages so only logged-in users can access the site, and redirect unauthenticated
users to /login. Add a logout link to the app. Add contracts on the protected handlers. Update
server.intent to test login page renders, unauthenticated access redirects and POSTS and run
`ntnt intent check server.tnt` until all pass.

Prompt 4 — Refactor:

Refactor the app to use middleware, file-based routing, external HTML templates in a views/
directory for all pages, partials for nav and footer and add a static CSS file. Move functions
to lib folder. Make sure it still looks decent. Verify `ntnt intent check server.tnt` still
passes.

Four prompts. You’ve got a full-stack web app with a database, auth, templates, middleware, and file-based routing. You didn’t write any NTNT. Your agent did, and ntnt intent check proved it’s correct at every step.

Advanced Demo Prompts

These prompts extend the app further. Docker is required for Prompt 5.

Prompt 5 — PostgreSQL & Docker (requires Docker):

Migrate from SQLite to PostgreSQL. Create a Dockerfile and docker-compose.yml with the ntnt app
and a postgres container. Use environment variables for the connection string. Verify
`ntnt intent check server.tnt` still passes. Leave the app running when you're done.

Prompt 6 — Background Jobs:

Add a background job that fetches a new random cat fact from an API every 10 minutes and stores
it in the database. Display the latest cat fact on the homepage with a button that schedules an
immediate job to fetch a new one. Add a job log page that shows a record of all jobs run with
their status and timestamps. Verify `ntnt intent check server.tnt` still passes.

Hand-Crafted Code Path

Installation

macOS / Linux:

curl -sSf https://raw.githubusercontent.com/ntntlang/ntnt/main/install.sh | bash

Windows (PowerShell):

irm https://raw.githubusercontent.com/ntntlang/ntnt/main/install.ps1 | iex

Hello World

echo 'print("Hello, World!")' > hello.tnt
ntnt run hello.tnt

A Web API

import { json } from "std/http/server"
 
fn home(req) {
    return json(map { "message": "Hello!" })
}
 
fn get_user(req) {
    return json(map { "id": req.params["id"] })
}
 
get("/", home)
get("/users/{id}", get_user)
 
listen(3000)
ntnt run api.tnt
# Visit http://localhost:3000

Hot-reload: HTTP servers automatically reload when you edit the source file.

Intent-Driven Development

Write .intent files describing features, link code with @implements, and verify everything matches.

1. Write an intent file (server.intent):

## Glossary
 
| Term | Means |
|------|-------|
| a user visits {path} | GET {path} |
| the home page | / |
| the page loads | status 200 |
| they see {text} | body contains {text} |
 
---
 
Feature: Hello World
  id: feature.hello
 
  Scenario: Greeting
    When a user visits the home page
    → the page loads
    → they see "Hello, World"

2. Annotate your implementation (server.tnt):

import { html } from "std/http/server"
 
// @implements: feature.hello
fn home(req) {
    let name = req.query_params["name"] ?? "World"
    return html("<h1>Hello, #{name}!</h1>")
}
 
get("/", home)
listen(8080)

3. Verify:

$ ntnt intent check server.tnt
 
✓ Feature: Hello World
  ✓ Greeting
      When a user visits the home page
      → the page loads
      → they see "Hello, World"
 
Features: 1 passed | Scenarios: 1 passed | Assertions: 2 passed

For visual development, use Intent Studio:

ntnt intent studio server.intent
# Opens http://127.0.0.1:3001 with live ✓/✗ indicators

Build from Source

# Install Rust if needed: https://rustup.rs/
git clone https://github.com/ntntlang/ntnt.git
cd ntnt
cargo build --release
cargo install --path . --locked
ntnt --version

Why NTNT?

NTNT started as a question: if an AI agent is going to write most of your code, what does the language need to do differently?

Traditional languages are designed for humans writing code by hand. Syntax is crafted for readability. Error messages assume the author made a typo. Documentation is a nice-to-have. None of that is quite right when your primary developer is an LLM.

NTNT was built for human-AI collaboration. Requirements aren’t separate from the code — they’re verifiable tests woven into the development loop. Contracts aren’t just good practice — they’re how agents understand what to build. And a comprehensive standard library means no package manager, no dependency resolution, no supply chain attacks.

Key Features

FeatureDescription
Intent-Driven DevelopmentWrite requirements in .intent files. Link code with @implements. Run ntnt intent check to verify. Full traceability from requirement to implementation.
Design by Contractrequires and ensures built into function syntax. Agents read them as specs. Humans read them as docs. In HTTP routes, contract violations return 400/500 automatically.
Agent-Native Toolingntnt inspect outputs JSON describing every function, route, and contract. ntnt validate returns machine-readable errors. An agent can understand an entire codebase in one call.
Gradual Type SystemTwo independent axes: NTNT_LINT_MODE (static) and NTNT_TYPE_MODE (runtime). Start untyped, add annotations where they help, enable full type checking when you want it.
Built-In AuthOAuth/OIDC, JWT, CSRF, session management, local credentials, password reset, TOTP, staged auth challenges, and route/API protection — all in std/auth. Add Google/GitHub login or local email/password auth without dependency sprawl.
Background JobsLanguage-native job DSL with priority queues, cron, unique jobs, and dead letter handling. Memory, PostgreSQL, and Redis backends.
Secure by DesignNo package manager means no supply chain attacks. Auto-escaping, SSRF protection, and security headers ship with the language.
Batteries IncludedHTTP servers, PostgreSQL, SQLite, Redis, JSON, CSV, file I/O, crypto, concurrency — all in the standard library.
Hot ReloadHTTP servers reload automatically when you save. Edit code, refresh browser, see changes.

Design by Contract

fn withdraw(amount: Int) -> Int
    requires amount > 0
    requires amount <= self.balance
    ensures result >= 0
{
    self.balance = self.balance - amount
    return self.balance
}
 
// In HTTP routes:
// - Failed requires → 400 Bad Request
// - Failed ensures → 500 Internal Server Error

Design Philosophy

  • Simple & Intuitive — Readable by humans reviewing it, predictable for agents writing it.
  • Strong & Robust — Catch mistakes early, fail clearly, never silently corrupt.
  • Consistent — One pattern for everything. len() works on strings, arrays, and maps. query() works on PostgreSQL, SQLite, and Redis.
  • Secure by Default — A comprehensive standard library reduces the need for third-party dependencies, and with fewer dependencies comes less exposure to supply chain attacks. Auto-escaping, SSRF protection, and security headers ship with the language.
  • Progressive Types — Start untyped, add annotations where they help, enable full type checking when you want it.
  • Agent-Native Tooling — ntnt inspect returns structured JSON of every function, route, and contract. ntnt validate returns machine-readable errors. An agent can understand an entire codebase in one call.
  • Verification Built In — Intent files, @implements annotations, and ntnt intent check are part of the language itself, not a separate test framework bolted on after the fact.
  • Batteries Included — HTTP, auth, databases, crypto, jobs, concurrency, CSV, markdown. All in the standard library, all shipping with the binary. No package manager by design.
  • Documentation as a Constraint — The compiler refuses to build until every public function is documented. Documentation stays accurate because the build depends on it.
  • Less Code, More Done — Routes, database queries, auth flows, and job definitions that take dozens of lines in other languages take a few in NTNT.

Standard Library

Everything’s built in. No package manager needed.

CategoryModulesIncludes
Webstd/http/server, std/httpHTTP server with routing, middleware, static files; HTTP client
Datastd/json, std/csv, std/db/postgres, std/db/sqliteParse/stringify; PostgreSQL and SQLite with transactions
Key-Valuestd/kvUnified KV store (Redis, Valkey, DragonflyDB, SQLite, in-memory)
Authstd/authOAuth/OIDC, JWT, CSRF, sessions, local credentials, password reset, TOTP, staged challenges, route/API protection
Jobsstd/jobsBackground job DSL with priority queues, cron, unique jobs, retry, dead letters. Memory, PostgreSQL, and Redis backends
Concurrencystd/concurrentSpawn, typed channels (Tx/Rx), select, parallel, race, schedule, after
Collectionsstd/collectionspush, pop, sort, reverse, keys, values, entries, map, filter, reduce, find, any, all
I/Ostd/fs, std/path, std/envFile operations, path manipulation, environment variables
Textstd/string, std/url, std/markdownSplit, join, trim, replace, regex; URL encode/decode/parse; Markdown → HTML
Utilitiesstd/time, std/math, std/cryptoTimestamps, formatting; trig, log, exp; SHA256, AES-256-GCM, Argon2, UUID
Loggingstd/logStructured request logging with levels and JSON context

CLI Commands

CommandDescription
ntnt run file.tntRun a program
ntnt test server.tnt --get /healthTest HTTP endpoints (start, request, stop)
ntnt lint file.tntCheck for errors
ntnt intent check file.tntVerify code matches intent
ntnt intent studio file.intentLive visual test feedback
ntnt intent coverage file.tntFeature coverage report
ntnt validate file.tntValidate with JSON output
ntnt inspect file.tntProject structure as JSON
ntnt learn Set up AI agent config (claude-code, cursor, codex, copilot)
ntnt check file.tntQuick syntax check
ntnt worker file.tntStart background job workers for jobs defined in a file
ntnt jobs statusQueue depths, completed/failed/dead counts
ntnt jobs listList jobs by status, queue, or type
ntnt jobs inspect Detailed view of a single job
ntnt jobs retry Re-queue a failed or dead job
ntnt workers statusLive worker status and active jobs
ntnt workers scaleScale worker pools at runtime via control socket
ntnt migrate .Migrate old {expr} interpolation to #{expr}
ntnt docs std/stringLook up module/function docs
ntnt completionsGenerate shell completion scripts (bash, zsh, fish)
ntnt replInteractive REPL

Documentation

DocumentDescription
AI Agent GuideThe guide your agent reads — syntax rules, patterns, gotchas
Language SpecificationComplete syntax, types, contracts, and features
Stdlib ReferenceEvery function across all stdlib modules
Runtime ReferenceCLI, environment variables, server configuration
IAL ReferenceIntent Assertion Language primitives
Deployment GuideDocker, production config, hot-reload, environment setup
ArchitectureSystem internals and design decisions
IDD Design DocumentIntent-Driven Development philosophy and workflow
WhitepaperTechnical motivation and language design philosophy
Websitentnt-lang.org — learn, docs, benchmarks

Editor Support

VS Code: Copy the extension for syntax highlighting:

cp -r editors/vscode/intent-lang ~/.vscode/extensions/

Get Involved

NTNT is open source under the MIT license. The best way to contribute is to use it, break it, and file issues.


License

MIT + Apache 2.0