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.3.tar.gz (53.5 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.3-py3-none-any.whl (72.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: prompt2bin-0.3.3.tar.gz
  • Upload date:
  • Size: 53.5 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.3.tar.gz
Algorithm Hash digest
SHA256 f83719b99913072c91428e9fdc323f29debcfd622ce515f8d8e6ce012dd5431a
MD5 37d4a953303b034c7d10a95efdddb659
BLAKE2b-256 3da26c18e3608a6bfc12791d64642e5c948f534bd00aaf9177e167b601fcb830

See more details on using hashes here.

Provenance

The following attestation bundles were made for prompt2bin-0.3.3.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.3-py3-none-any.whl.

File metadata

  • Download URL: prompt2bin-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 72.7 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5cf71258ee0af02d20d2f05e5c8ab441a1a310d6c3ad971e48d51139afe3857b
MD5 ff940c59603f3d18463395eaff176a92
BLAKE2b-256 27921f81fbc621b5f922397932c9642183e48983b1202a134d3704726af6a3d4

See more details on using hashes here.

Provenance

The following attestation bundles were made for prompt2bin-0.3.3-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