Reality-First Development Protocol - Prevents AI hallucination and ensures spec-driven development
Project description
RFD Protocol
Reality-First Development - Prevents AI hallucination and ensures spec-driven development
What is RFD?
RFD (Reality-First Development) is a protocol that eliminates AI hallucination in software development by enforcing concrete reality checkpoints. Instead of trusting AI claims about what was implemented, RFD validates that code actually runs, tests pass, and features work.
Core Benefits
- ๐ฏ Prevents AI Hallucination: Drops error rate from 48% to ~0%
- ๐ Spec-Driven Development: Features must be specified before implementation
- โ Reality Checkpoints: Every change is validated against working code
- ๐ Session Persistence: Context maintained across Claude Code sessions
- ๐ Universal Drop-in: Works with any tech stack (25+ languages)
Quick Start
Installation
Option 1: Via pip (Recommended)
pip install rfd
Option 2: From source
git clone https://github.com/rfd-protocol/rfd.git
cd rfd
pip install -e .
Initialize in Your Project
For a new project:
mkdir my-project && cd my-project
rfd init
For an existing project:
cd your-existing-project/
rfd init
This creates:
PROJECT.md- Your project specificationCLAUDE.md- Claude Code integration configPROGRESS.md- Build progress tracking.rfd/- RFD system directory
Basic Workflow
-
Define specifications first:
rfd spec create
-
Start feature development:
rfd session start user_auth
-
Build and validate continuously:
rfd build rfd validate
-
Save working checkpoints:
rfd checkpoint "User auth working"
Project Architecture
Our repository follows modern Python packaging standards with a clear separation of concerns:
rfd-protocol/
โโโ README.md # This file
โโโ PROJECT.md # Project specification
โโโ pyproject.toml # Modern Python packaging config
โโโ requirements.txt # Runtime dependencies
โ
โโโ src/rfd/ # ๐ฏ MAIN PACKAGE (modern Python layout)
โ โโโ __init__.py # Package entry point, version info
โ โโโ cli.py # Command-line interface
โ โโโ rfd.py # Core RFD orchestration class
โ โโโ validation.py # AI hallucination detection engine
โ โโโ session.py # Session management & persistence
โ โโโ build.py # Build automation engine
โ โโโ spec.py # Specification management
โ โโโ templates/ # Project templates
โ
โโโ tests/ # ๐งช COMPREHENSIVE TEST SUITE
โ โโโ conftest.py # Shared pytest fixtures
โ โโโ unit/ # Fast, isolated tests
โ โโโ integration/ # Component interaction tests
โ โโโ system/ # End-to-end workflow tests
โ โโโ fixtures/ # Test data and sample projects
โ
โโโ .rfd/ # ๐๏ธ LEGACY SYSTEM (for compatibility)
โ โโโ rfd.py # Legacy CLI entry point
โ โโโ validation.py # Legacy validation engine
โ โโโ session.py # Legacy session management
โ โโโ build.py # Legacy build engine
โ โโโ spec.py # Legacy spec management
โ โโโ memory.db # SQLite persistent state
โ โโโ context/ # Session context files
โ
โโโ docs/ # ๐ DOCUMENTATION
โ โโโ AGENTS.md # Agent orchestration definitions
โ โโโ CLAUDE.md # Claude Code CLI configuration
โ โโโ INSTALL.md # Installation instructions
โ โโโ RFD-PROTOCOL.md # Core protocol specification
โ โโโ @RFD-PROTOCOL.md # Protocol summary
โ โโโ RFD-PLAN.md # Development roadmap
โ โโโ archive/ # Historical documents
โ
โโโ tools/ # ๐ง DEVELOPMENT TOOLS
โ โโโ comprehensive_audit.py # Codebase audit tool
โ โโโ detailed_bug_analysis.py # Bug analysis tool
โ
โโโ research/ # ๐ RESEARCH & BACKGROUND
โ โโโ brain-dump.md # Original problem statement
โ โโโ CONSENSUS-FINAL.md # Design decisions
โ โโโ round-*/ # Development phases
โ
โโโ scripts/ # ๐ LEGACY SCRIPTS
โ โโโ [legacy tools] # Historical development scripts
โ
โโโ nexus_rfd_protocol/ # ๐ TRANSITION PACKAGE
โ โโโ [legacy modules] # Old package structure (being phased out)
โ
โโโ .github/workflows/ # ๐ CI/CD PIPELINE
โ โโโ ci.yml # Continuous integration
โ โโโ release.yml # Automated releases
โ
โโโ rfd -> .rfd/rfd.py # ๐ SYMLINK (legacy compatibility)
Directory Purposes
Core Directories
src/rfd/: Modern Python package following PEP standards. This is the main codebase.tests/: Comprehensive test suite with 90+ test functions across unit/integration/system categories..rfd/: Legacy system directory for backward compatibility. Contains working database and CLI.
Documentation Directories
docs/: Essential documentation and specifications.docs/archive/: Historical documents from development phases.research/: Background research and design decisions.
Development Directories
tools/: Development and analysis tools.scripts/: Legacy development scripts..github/workflows/: CI/CD automation.
Transition Directories
nexus_rfd_protocol/: Old package structure being phased out.rfd(symlink): Legacy CLI compatibility.
Core Concepts
Reality-First Principles
- Code that runs > Perfect architecture
- Working features > Planned features
- Real data > Mocked responses
- Passing tests > Theoretical correctness
Validation Engine
RFD continuously validates:
- โ Files actually exist (detects AI file creation lies)
- โ Functions are implemented (not just claimed)
- โ APIs respond correctly
- โ Tests pass with real data
- โ Build processes work
Session Management
- Persistent Context: RFD maintains what you're working on across restarts
- Memory: AI remembers what worked/failed in previous sessions
- Progress Tracking: Visual progress through complex features
- Auto-Recovery: Continue from last checkpoint if interrupted
Integration with Claude Code
RFD is designed to work seamlessly with Claude Code:
- Install RFD in your project:
rfd init - Claude Code reads
CLAUDE.mdautomatically - AI follows RFD workflow - validates every change
- Context persists in
.rfd/context/memory.json
Example Claude Code Session
# AI automatically follows this workflow:
rfd check # Check current status
rfd build # Implement features
rfd validate # Verify everything works
rfd checkpoint "Feature X" # Save progress
Command Reference
Core Commands
rfd init # Initialize RFD in current directory
rfd check # Quick status check
rfd spec create # Interactive spec creation
rfd spec review # Review current specification
Development Workflow
rfd session start <feature> # Start working on a feature
rfd build [feature] # Build/compile feature
rfd validate [--feature X] # Run validation tests
rfd checkpoint "message" # Save working state
rfd session end # Mark feature complete
State Management
rfd revert # Revert to last checkpoint
rfd memory show # Show AI memory
rfd memory reset # Clear AI memory
Specification Format
RFD uses frontmatter-based PROJECT.md files:
---
version: "1.0"
name: "My API"
stack:
language: python
framework: fastapi
database: sqlite
features:
- id: user_auth
description: "User signup and login"
acceptance: "POST /signup returns 201, POST /login returns token"
status: pending
rules:
max_files: 20
max_loc_per_file: 200
must_pass_tests: true
---
# My API Project
This API handles user authentication and data management.
Getting Started Guide
For Brand New Projects
-
Create project directory:
mkdir my-awesome-project cd my-awesome-project
-
Initialize RFD:
rfd initThis will walk you through:
- Project name and description
- Technology stack selection
- Initial feature definitions
- Acceptance criteria
-
Review generated files:
PROJECT.md- Your specificationCLAUDE.md- AI instructionsPROGRESS.md- Progress tracking
-
Start developing:
rfd session start <first-feature> # Write code... rfd build rfd validate rfd checkpoint "First feature working"
For Existing Projects
-
Add RFD to existing project:
cd existing-project/ rfd init
-
RFD will analyze your project:
- Detect programming language
- Identify build system
- Suggest initial feature breakdown
-
Define what you want to build:
- Edit generated
PROJECT.md - Add acceptance criteria for features
- Set validation rules
- Edit generated
-
Start RFD workflow:
rfd check # See current state rfd session start <feature> # Continue development with RFD validation
What You Need to Provide
Minimum Required:
- Project goal: What are you building?
- Technology stack: Language, framework, database
- First feature: What's the first thing you want working?
Recommended:
- Acceptance criteria: How do you know a feature is done?
- Validation rules: Max files, complexity limits
- Test requirements: What tests must pass?
Technology Stack Support
RFD works with any stack by detecting your configuration:
- Python: FastAPI, Flask, Django, any framework
- JavaScript/TypeScript: Express, NestJS, Next.js, React, Vue
- Go: Gin, Echo, standard library
- Rust: Actix, Rocket, Axum
- Java/Kotlin: Spring Boot, Quarkus
- C/C++: Any build system
- And 20+ more languages...
Development
Running Tests
# All tests
pytest
# By category
pytest -m unit # Fast unit tests
pytest -m integration # Integration tests
pytest -m system # End-to-end tests
# With coverage
pytest --cov=src/rfd --cov-report=html
Code Quality
# Linting
ruff check src tests
# Formatting
ruff format src tests
# Type checking (optional)
mypy src --ignore-missing-imports
Troubleshooting
Common Issues
"No feature specified"
rfd session start <feature_id> # Start a session first
"Validation failed"
rfd validate # See what's failing
rfd build # Fix build issues first
"Lost context"
rfd check # See current state
cat .rfd/context/current.md # Check session file
Debug Mode
export RFD_DEBUG=1
rfd validate # Verbose output
Legacy vs Modern CLI
We provide two CLI options:
- Modern:
rfd(via pip install) - Uses src/rfd/ package - Legacy:
./rfdorpython .rfd/rfd.py- Uses .rfd/ directory
Both provide the same functionality for backward compatibility.
Architecture Decisions
Why Both docs/RFD-PROTOCOL.md and docs/@RFD-PROTOCOL.md?
docs/RFD-PROTOCOL.md: Complete protocol specification with all detailsdocs/@RFD-PROTOCOL.md: Summary version for quick reference with @ prefix for Claude Code CLI
Why Keep Legacy .rfd/ Directory?
- Backward Compatibility: Existing projects using RFD continue working
- Migration Path: Gradual transition to modern package structure
- Working Database: Contains SQLite state and session data
- Symlink Compatibility: Legacy
./rfdcommand still works
Why Both nexus_rfd_protocol/ and src/rfd/?
- Transition Period: Moving from old package name to new clean structure
- Testing: Ensuring both old and new imports work during transition
- Release Safety: No breaking changes for existing users
Contributing
RFD Protocol is open source. Contributions welcome!
- Fork the repository
- Create a feature branch
- Use RFD to develop your feature ๐
- Ensure tests pass:
pytest - Submit a pull request
Development Setup
git clone https://github.com/rfd-protocol/rfd.git
cd rfd
pip install -e ".[dev]"
pytest # Run tests
License
MIT License - see LICENSE file.
Support
- GitHub Issues: Report bugs
- Documentation: Full docs
- Discord: Community chat
Built with RFD Protocol - This project was developed using its own reality-first methodology.
Version History
- v1.0.0: Production release with modern Python packaging, comprehensive test suite, CI/CD pipeline, and full documentation.
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 rfd_protocol-2.0.2.tar.gz.
File metadata
- Download URL: rfd_protocol-2.0.2.tar.gz
- Upload date:
- Size: 49.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a3954fd766fb92b8a17fd95da06f4e4a8b2daaa964a54c0281c1ae79262b925
|
|
| MD5 |
1e4ccbe1feded65fa9fa092a0b1d7daa
|
|
| BLAKE2b-256 |
b934d782e6acc69451786339eed55f555ce5d25fa20db9988088ec12c614b2be
|
File details
Details for the file rfd_protocol-2.0.2-py3-none-any.whl.
File metadata
- Download URL: rfd_protocol-2.0.2-py3-none-any.whl
- Upload date:
- Size: 32.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
852bb9ec08af74ab5e13f29c666fc04b559b914c731dea9f429b90568e57f246
|
|
| MD5 |
d35075e7c086b367fa462fc15eb7599f
|
|
| BLAKE2b-256 |
706380450ba4702a30b954f0c918646d3bf6cd2918c05b8ce17a4a01a8a20006
|