Project Overview
We’ll build a REST API for a todo application with the following features:- CRUD operations for todos
- User authentication
- Database persistence
- API documentation
Prerequisites
Before starting, ensure you have:- Longshot installed (installation guide)
- Modal account configured (
modal setup) - A GitHub repository with push access
- LLM API credentials (OpenAI, Anthropic, or compatible)
Step-by-Step Guide
Create a specification file
Create a
SPEC.md file in your repository describing what you want to build:SPEC.md
Run Longshot with the dashboard
Execute Longshot with the Rich TUI dashboard for real-time monitoring:This will:
- Parse your specification
- Create a task decomposition plan
- Spawn parallel workers in Modal sandboxes
- Execute tasks concurrently
- Merge results into your repository
- Run reconciliation to fix any issues
Understanding Task Decomposition
Longshot’s root planner broke your specification into granular tasks:- Project scaffolding - Initialize project structure
- Database setup - Models, migrations, connection
- Authentication - User model, JWT, registration/login
- Core features - Todo CRUD operations
- Validation - Request/response schemas
- Testing - Unit and integration tests
- Documentation - OpenAPI/Swagger specs
- Containerization - Dockerfile, docker-compose
- Finalization - Reconciler fixes any issues
Handling Build Issues
If Longshot encounters build failures, the reconciler automatically:- Detects issues - Monitors build health every 10 seconds (configurable)
- Analyzes failures - Examines test failures, linting errors, type errors
- Creates fix tasks - Spawns new workers to resolve issues
- Retries - Attempts fixes up to
FINALIZATION_MAX_ATTEMPTStimes
Manual Intervention
If the reconciler can’t fix an issue:Advanced Options
Reset Before Running
Reset your repository to the initial commit before running:Debug Mode
Enable verbose logging for troubleshooting:LOG_LEVEL=debug and shows:
- Detailed task decomposition
- Worker dispatch and completion events
- Merge queue operations
- LLM request/response summaries
Iterative Development
After the initial build, make incremental changes:Best Practices
Write detailed specifications
Write detailed specifications
The more detail you provide in your specification, the better results you’ll get:
- List all features and requirements explicitly
- Specify technical choices (frameworks, libraries, patterns)
- Include non-functional requirements (testing, performance, security)
- Provide examples of expected behavior
Start with smaller scopes
Start with smaller scopes
For your first project:
- Start with a well-defined, medium-sized project (not too large)
- Use familiar tech stacks
- Provide clear acceptance criteria
- Review results before scaling up
Monitor resource usage
Monitor resource usage
Keep an eye on costs:
- LLM API usage (check token counts in run summary)
- Modal compute costs (reduce
MAX_WORKERSif needed) - Adjust
SANDBOX_CPU_CORESandSANDBOX_MEMORY_MBbased on your workload
Review and refine
Review and refine
Treat Longshot output as a first draft:
- Review all generated code
- Run tests and verify functionality
- Make manual adjustments as needed
- Use Longshot again for improvements: “Refactor X to improve Y”
Troubleshooting
Common Issues
Workers timing out
Workers timing out
If workers frequently timeout:
.env
Merge conflicts
Merge conflicts
If you encounter frequent merge conflicts:
.env
LLM rate limits
LLM rate limits
If you hit rate limits:
.env
Next Steps
Architecture
Learn how Longshot works under the hood
CLI Reference
Explore all CLI options and commands