Spec Syntax (Markdown)
SpecLeft specs are plain Markdown with YAML frontmatter. Each file describes one feature, story, or scenario.
Directory structures
Section titled “Directory structures”Specs can be organized in two ways:
Flat structure
.specleft/specs/└── authentication.md└── reset-password.mdOR
Hierarchical structure (recommended for larger projects)
.specleft/specs/└── authentication/ └── _feature.md └── login/ └── _story.md └── successful-login.md └── failed-login.md └── reset-password/ └── _story.md └── email-sent.md └── invalid-email.mdFeature Unit
Section titled “Feature Unit”A feature unit describes a single feature and its scenarios.
## Feature: Authentication
### Scenarios
#### Scenario: Valid credentialspriority: critical
- Given …- When …- Then …
#### Scenario: Invalid passwordpriority: high
- Given …- When …- Then …
---confidence: lowsource: prd.mdassumptions: - email/password loginopen_questions: - password complexity rules?tags: - auth - securityowner: dev-teamcomponent: identity---Feature metadata file (_feature.md)
Section titled “Feature metadata file (_feature.md)”---feature_id: authenticationcomponent: identityowner: auth-teampriority: hightags: [auth, security]---
# Feature: User Authentication
Describe the purpose and scope of the feature.Story metadata file (_story.md)
Section titled “Story metadata file (_story.md)”---story_id: loginfeature_id: authenticationpriority: hightags: [auth, login]---
# Story: User Login
Describe a specific user journey within the feature.Scenario unit (<scenario>.md)
Section titled “Scenario unit (<scenario>.md)”This scenario would get converted into a test skeleton:
---scenario_id: successful-loginstory_id: loginfeature_id: authenticationpriority: criticalexecution_time: fasttags: [smoke, login]---
# Scenario: Successful login
## Steps- **Given** a user has valid credentials- **When** the user submits the login form- **Then** the user is authenticatedTest data tables
Section titled “Test data tables”Use ## Test Data to create parameterized scenarios:
## Test Data| username | password | expected ||----------|----------|----------|| alice | secret | success || bob | wrong | error |
## Steps- **Given** a user with username `{username}` and password `{password}`- **When** they attempt to log in- **Then** the result is `{expected}`Valid values
Section titled “Valid values”- Step keywords (optional):
Given,When,Then,And,But - Priority:
critical,high,medium,low - Execution time:
fast,medium,slow
ID rules
Section titled “ID rules”Feature, story, and scenario IDs must be unique and match ^[a-z0-9-]+$.