Vibe safely
Project description
Vibesafe
Vibe safely - AI-powered code generation with verifiable specs.
Vibesafe is a developer-facing system that lets engineers write readable specs as Python code that AI fills in. It creates a verifiable, hash-locked boundary between human intent and generated code, while keeping iteration and integration friction-free.
Core Goals
- Readable Specs: Developers write small, typed, example-based specs they themselves will read
- Trustable Code: Generated code is hash-verifiable and versioned; no hidden AI state
- Fast Iteration: Iteration loop is fast, local, and test-driven
- Composability: Generated functions compose naturally with normal Python modules
Quick Start
Installation
# Install with uv
uv pip install -e .
# Or with pip
pip install -e .
Basic Usage
- Write a spec:
# examples/math/ops.py
from vibesafe import vibesafe, VibesafeHandled
@vibesafe.func
def sum_str(a: str, b: str) -> str:
"""
Add two integers represented as strings.
>>> sum_str("2", "3")
'5'
>>> sum_str("10", "20")
'30'
"""
a_int, b_int = int(a), int(b)
yield VibesafeHandled()
- Configure vibesafe:
# vibesafe.toml
[provider.default]
kind = "openai-compatible"
model = "gpt-4o-mini"
api_key_env = "OPENAI_API_KEY"
- Generate implementation:
# Set API key
export OPENAI_API_KEY="your-key-here"
# Compile the function
vibesafe compile --target examples.math.ops/sum_str
# Test it
vibesafe test --target examples.math.ops/sum_str
# Use it in code
from __generated__.examples.math.ops import sum_str
print(sum_str("5", "7")) # "12"
Features
Phase 1 (MVP) - Implemented ✅
- ✅ Python 3.12+ support
- ✅ Pure functions with
@vibesafe.func - ✅ HTTP endpoints with
@vibesafe.http(FastAPI) - ✅ Doctest-based verification + lint/type gates (ruff, mypy)
- ✅ Hash-locked checkpoints + drift detection
- ✅ OpenAI-compatible providers with on-disk caching
- ✅ CLI commands:
scan,compile,test,status,diff,save - ✅ Dependency freezing via
--freeze-http-deps - ✅ Jinja2 prompt templates
- ✅ Basic MCP server for editor integration
Phase 2 (Coming Soon)
- Interactive REPL mode
- Property-based tests with Hypothesis
- Advanced dependency tracing
- Multiple provider backends
- Sandbox execution
- Web UI dashboard
CLI Commands
vibesafe scan
List all vibesafe units in the project:
vibesafe scan
vibesafe scan --write-shims # Also generate __generated__ shims
vibesafe compile
Generate implementations:
vibesafe compile # Compile all units
vibesafe compile --target MODULE # Compile specific module
vibesafe compile --target UNIT_ID # Compile specific unit
vibesafe compile --force # Force recompilation
vibesafe test
Run doctest verification:
vibesafe test # Test all units
vibesafe test --target UNIT_ID # Test specific unit
vibesafe save
Activate checkpoints (after tests pass):
vibesafe save # Save all (if all tests pass)
vibesafe save --target UNIT_ID # Save specific unit
vibesafe save --target UNIT_ID --freeze-http-deps # Also snapshot runtime deps
When --freeze-http-deps is provided, Vibesafe writes requirements.vibesafe.txt and embeds the captured package versions into each checkpoint’s meta.toml.
vibesafe status
Summarize registered units, doctest counts, and active checkpoint hashes:
vibesafe status
Use this to confirm new specs are registered and active hashes match the latest spec revision.
vibesafe diff
Inspect drift between the current spec hash and the active checkpoint:
vibesafe diff # Check all units
vibesafe diff --target UNIT_ID # Focus on one unit
The command reports mismatched hashes and the filesystem location of the stale checkpoint.
Architecture
project/
├── vibesafe.toml # Configuration
├── prompts/
│ ├── function.j2 # Function prompt template
│ └── http_endpoint.j2 # HTTP endpoint template
├── examples/
│ └── math/
│ └── ops.py # Spec with @vibesafe.func
├── __generated__/ # Generated shims
│ └── examples/
│ └── math/
│ └── ops.py # Auto-generated imports
└── .vibesafe/
├── checkpoints/ # Implementation checkpoints
│ └── examples/math/ops/sum_str/
│ └── <hash>/
│ ├── impl.py
│ └── meta.toml
├── index.toml # Active checkpoint mapping
└── cache/ # LLM response cache
How It Works
- Spec Definition: Mark functions with
@vibesafe.funcor@vibesafe.http - AST Extraction: Parse signature, docstring, and pre-VibesafeHandled body
- Hash Computation: Create deterministic hash from spec + model + template
- Code Generation: Render prompt via Jinja2, call LLM with seed
- Verification: Run doctests against generated implementation
- Checkpoint Storage: Save implementation with metadata in
.vibesafe/ - Runtime Loading:
__generated__shims load active checkpoints
Error Handling
- Use the
VibeHandledalias (exported alongsideVibesafeHandled) in spec stubs so docs and code snippets stay consistent. - The pipeline raises descriptive exceptions to guide remediation:
VibesafeMissingDoctestwhen a spec lacks doctests.VibesafeValidationErrorif generated code fails basic sanity checks (e.g., wrong function signature).VibesafeProviderErrorwhen upstream LLM calls fail.VibesafeHashMismatchandVibesafeCheckpointMissingduring runtime loading if checkpoints drift or are missing. Handle these in tooling or surface them to contributors to tighten specs.
Configuration
See vibesafe.toml for full configuration options:
- Provider settings: Model, temperature, API keys
- Path configuration: Where checkpoints and cache are stored
- Prompt templates: Customize code generation prompts
- Sandbox options: Optional execution isolation
Examples
See the examples/ directory for:
examples/math/ops.py- Pure function examplesexamples/api/routes.py- FastAPI endpoint examples
Development
# Install dev dependencies
uv pip install -e ".[dev]"
# Run tests
pytest
# Run tests in parallel
pytest -n auto
# Type checking
mypy src/vibesafe
# Linting
ruff check src/vibesafe
# Format code
ruff format src/vibesafe
CI/CD
The repository uses GitHub Actions for continuous integration:
Standard CI Pipeline
- Linting: Runs
ruffto check code style and quality - Type Checking: Runs
mypyfor static type analysis - Testing: Runs
pytestwith parallel execution and coverage reporting - Matrix Testing: Tests on Python 3.12 and 3.13
Claude-Powered Automation
This repository includes AI-powered code review and test analysis:
-
Automated Code Review: Claude Sonnet 4 reviews all PRs, providing:
- Summary of changes
- Code quality feedback
- Security and performance concerns
- Actionable suggestions
-
Test Failure Analysis: When tests fail, Claude analyzes the failure and provides:
- Root cause analysis
- Debugging steps
- Classification (bug vs. flaky test vs. environment issue)
- Priority assessment
Setup: See .github/CLAUDE_ACTIONS.md for configuration instructions.
Requirements: Set ANTHROPIC_API_KEY in repository secrets.
License
MIT
Contributing
Contributions welcome! Please open an issue or PR.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vibesafe-0.1.2b2.tar.gz.
File metadata
- Download URL: vibesafe-0.1.2b2.tar.gz
- Upload date:
- Size: 27.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
805ee1fd22db9a1c5e63a8f302f0f17bce0db803987f7414efc8c021d3c55525
|
|
| MD5 |
2f3f25841f8f04f676769d70ef309bba
|
|
| BLAKE2b-256 |
39e5b81452f114200c879735462c6e186e32798c4d4a738e154303e5ccb0af35
|
Provenance
The following attestation bundles were made for vibesafe-0.1.2b2.tar.gz:
Publisher:
pypi-publish.yml on julep-ai/vibesafe
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vibesafe-0.1.2b2.tar.gz -
Subject digest:
805ee1fd22db9a1c5e63a8f302f0f17bce0db803987f7414efc8c021d3c55525 - Sigstore transparency entry: 656252747
- Sigstore integration time:
-
Permalink:
julep-ai/vibesafe@06f54b1c85105126dda3c23eb83c84be6737232d -
Branch / Tag:
refs/pull/3/merge - Owner: https://github.com/julep-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@06f54b1c85105126dda3c23eb83c84be6737232d -
Trigger Event:
pull_request
-
Statement type:
File details
Details for the file vibesafe-0.1.2b2-py3-none-any.whl.
File metadata
- Download URL: vibesafe-0.1.2b2-py3-none-any.whl
- Upload date:
- Size: 33.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea0deb12be72fabc7648248de186c5e9fe067c06ec1c579b5912888ac7d692f6
|
|
| MD5 |
3eb6462a33b5286e2cc1cbfcbb18e8a0
|
|
| BLAKE2b-256 |
b9b9b23b92fb50df9842c26b42ff93513b9571e1c5f5120fa729ba0289dd1b0f
|
Provenance
The following attestation bundles were made for vibesafe-0.1.2b2-py3-none-any.whl:
Publisher:
pypi-publish.yml on julep-ai/vibesafe
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vibesafe-0.1.2b2-py3-none-any.whl -
Subject digest:
ea0deb12be72fabc7648248de186c5e9fe067c06ec1c579b5912888ac7d692f6 - Sigstore transparency entry: 656252764
- Sigstore integration time:
-
Permalink:
julep-ai/vibesafe@06f54b1c85105126dda3c23eb83c84be6737232d -
Branch / Tag:
refs/pull/3/merge - Owner: https://github.com/julep-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@06f54b1c85105126dda3c23eb83c84be6737232d -
Trigger Event:
pull_request
-
Statement type: