Defining Your First Feature
Specs are written in Markdown. They describe what a feature does and why, without implementation details.
1. Create a PRD
Section titled “1. Create a PRD”Create a prd.md file in your repository root:
# My Project
## Feature: User Authentication
Users need to log in securely.
### Scenario: Successful login- Given a user has valid credentials- When the user submits the login form- Then the user is authenticated and redirected
### Scenario: Invalid credentials- Given a user has invalid credentials- When the user submits the login form- Then an error message is displayed2. Generate feature specs
Section titled “2. Generate feature specs”Preview what SpecLeft would create:
specleft plan --dry-runWhen it looks right, run it for real:
specleft planSpecLeft creates one file per feature under .specleft/specs/:
This is also called a “feature unit”
.specleft/specs/├── feature-user-authentication.md3. Inspect a feature unit
Section titled “3. Inspect a feature unit”Open .specleft/specs/feature-user-authentication.md:
# Feature: User Authentication
## Scenarios
### Scenario: Successful login- Given a user has valid credentials- When the user submits the login form- Then the user is authenticated and redirected
### Scenario: Invalid credentials- Given a user has invalid credentials- When the user submits the login form- Then an error message is displayed4. Generate skeleton tests
Section titled “4. Generate skeleton tests”Preview generation without writing files:
specleft test skeleton --dry-runGenerate the tests:
specleft test skeletonExample skeleton output:
from specleft import specleft
@specleft( feature_id="feature-user-authentication", scenario_id="successful-login", skip=True,)def test_successful_login(): with specleft.step("Given a user has valid credentials"): pass # TODO: implement test step
with specleft.step("When the user submits the login form"): pass # TODO: implement test step
with specleft.step("Then the user is authenticated and redirected"): pass # TODO: implement test step5. Run tests safely
Section titled “5. Run tests safely”Skeleton tests are skipped until you implement them:
pytestSKIPPED: Scenario 'successful-login' not yet implemented6. Track progress
Section titled “6. Track progress”Check what is implemented vs. skipped:
specleft statusFind the next scenario to implement:
specleft next