Skip to main content

From natural language to verified machine code

Project description

                                  _   ____  _     _
  _ __  _ __ ___  _ __ ___  _ __ | |_|___ \| |__ (_)_ __
 | '_ \| '__/ _ \| '_ ` _ \| '_ \| __| __) | '_ \| | '_ \
 | |_) | | | (_) | | | | | | |_) | |_ / __/| |_) | | | | |
 | .__/|_|  \___/|_| |_| |_| .__/ \__|_____|_.__/|_|_| |_|
 |_|                        |_|

Natural language in, verified machine code out.

Python 3.11+ License: MIT Version


Describe what you need in plain English. A formal verification engine (Z3) proves safety properties. An LLM generates the C implementation. A test harness validates correctness. GCC compiles it to a binary.

"I need a lock-free audio ring buffer"
     ↓
  formal spec → Z3 proves 7/7 safety properties
     ↓
  LLM generates C → test harness validates
     ↓
  GCC → x86-64 assembly + machine code
     ↓
  audio_ringbuf.h  audio_ringbuf.s  audio_ringbuf.o

Install

pip install prompt2bin

Requires GCC and at least one LLM backend:

Backend Setup API key?
Claude CLI (default) Install Claude CLI No — uses subscription
Codex CLI Install Codex CLI No — uses subscription
Anthropic API pip install prompt2bin[anthropic] + set ANTHROPIC_API_KEY Yes
OpenAI API pip install prompt2bin[openai] + set OPENAI_API_KEY Yes

Auto-detects in priority order: CLI > API key. Set P2B_BACKEND to override.

Quick start

p2b is the short alias for prompt2bin.

# one-shot: describe what you need, get a binary
p2b "I need a memory pool for allocating small objects"

# scaffold a new project
p2b init my_project

# build all components + generate main.c + compile
p2b build my_project

# build and run
p2b run my_project

# interactive mode
p2b --interactive

Project builds

A project is a directory with a build.toml, component .prompt files, and an app.prompt:

my_project/
├── build.toml
├── app.prompt                # what the app does, how components wire together
├── specs/
│   ├── memory_pool.prompt    # "I need a memory pool for allocating small objects..."
│   └── message_queue.prompt  # "I need a queue for passing messages between two threads..."
└── build/                    # generated: .h .s .o for each component + main.c
[project]
name = "my_project"
target = "x86-64-linux"

[model]                         # optional: per-project LLM configuration
backend = "anthropic-api"       # claude, codex, anthropic-api, openai-api
name = "claude-sonnet-4-6"
reasoning = "high"              # low, medium, high
temperature = 0.2

[components.memory_pool]
prompt = "specs/memory_pool.prompt"

[components.message_queue]
prompt = "specs/message_queue.prompt"

Templates:

p2b init my_project --template starter     # memory pool + message queue demo
p2b init my_project --template grok-cli    # interactive xAI Grok API client

Build features: incremental caching (SHA-256), parallel builds (up to 4 workers), per-project model config.

Supported domains

Domain What Z3 proves
Arena allocators Overflow safety, alignment correctness, memory bounds
Ring buffers Capacity invariants, index bounds, data loss prevention
Process spawners Buffer bounds, timeouts, static memory bounds
String tables Table sizing, index masking safety, storage bounds
Terminal I/O Cursor/index bounds, input overflow prevention

Each domain has 7 verified safety properties. See examples/ for generated outputs including C code, assembly, and terminal transcripts.

Examples

"I want a fast game frame allocator for temporary per-frame scratch memory, maybe 64KB"
→ 7/7 properties verified → game_frame.h + .s + .o

"Handle crypto key material in memory — must be wiped when done, no traces left"
→ 7/7 properties verified → crypto_secure.h + .s + .o

page_size=100, min_align=3  (bad spec)
→ [FAIL] power_of_two → Code generation blocked.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

prompt2bin-0.3.2.tar.gz (52.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

prompt2bin-0.3.2-py3-none-any.whl (72.0 kB view details)

Uploaded Python 3

File details

Details for the file prompt2bin-0.3.2.tar.gz.

File metadata

  • Download URL: prompt2bin-0.3.2.tar.gz
  • Upload date:
  • Size: 52.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for prompt2bin-0.3.2.tar.gz
Algorithm Hash digest
SHA256 654862c01f6766462e484d3dfd5f714d3391236ee843824538ce6780dbe67c02
MD5 b66f4ba52e9cba6d90523d823fbc23b8
BLAKE2b-256 5f88910d6c0a156a0041a2161e6d80a5eb99dd17d4a8f3c55f0f97f9f2c20531

See more details on using hashes here.

Provenance

The following attestation bundles were made for prompt2bin-0.3.2.tar.gz:

Publisher: publish.yml on asianviking/prompt2bin

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file prompt2bin-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: prompt2bin-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 72.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for prompt2bin-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 033f309fccb52506f0b2b0996b40b71f8835d281a61165f57a46dbe0b02e1d70
MD5 ca88f85cfa04da5a20ed6430efdcdd41
BLAKE2b-256 e66797c9276cab54a8a334cdf5009c0a6cde95e3e8e7340a4e4d2c15df8b235e

See more details on using hashes here.

Provenance

The following attestation bundles were made for prompt2bin-0.3.2-py3-none-any.whl:

Publisher: publish.yml on asianviking/prompt2bin

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page