behave-lint

July 3, 2026 · View on GitHub

CI Release PyPI Python License: MIT Code style: Ruff

A fast, opinionated, extensible linter for Gherkin .feature files and Behave test suites.

behave-lint statically analyzes your Gherkin feature files for correctness, consistency, complexity, and style — without executing a single test. It ships with 50 built-in rules across 9 categories, supports auto-fix for 14 rules, and outputs in 5 formats including SARIF for GitHub Code Scanning. Includes watch mode for real-time feedback during development.

Why behave-lint?

Without behave-lintWith behave-lint
Duplicate step definitions cause silent match failuresBD001 detects duplicates at lint time
Inconsistent tag casing breaks CI filtersBS001 auto-fixes to snake_case
Trailing punctuation in steps clutters reportsBD005 strips it automatically
No Given-When-Then ordering enforcementBC001 catches structural violations
Feature files grow unchecked in complexityBX001-BX005 enforce limits
Hardcoded passwords leak into version controlBSEC001 flags hardcoded secrets
Ableist language goes unnoticed in testsBACC001 suggests inclusive alternatives

Installation

pip install behave-lint

Or with uv:

uv add behave-lint

For watch mode, install the optional dependency:

pip install behave-lint[watch]

For LSP support (VS Code, Neovim, Emacs):

pip install behave-lint[lsp]

Quick start

# Lint all feature files
behave-lint features/

# Apply safe auto-fixes
behave-lint features/ --fix

# Watch for changes and re-lint automatically
behave-lint features/ --watch

# JSON output for CI integration
behave-lint features/ --output json --output-file report.json

# SARIF for GitHub Code Scanning
behave-lint features/ --output sarif --output-file results.sarif

# List all available rules
behave-lint --list-rules

# Explain a specific rule
behave-lint --explain BC001

Features

  • 50 built-in rules across 9 categories: correctness, step definitions, consistency, complexity, style, pedantic, security, i18n, and accessibility.
  • Auto-fix — 14 rules with safe and unsafe fixes (--fix, --unsafe-fixes).
  • Watch mode — re-lint on file changes with --watch (requires pip install behave-lint[watch]).
  • LSP server — real-time diagnostics in VS Code, Neovim, Emacs (requires pip install behave-lint[lsp]).
  • 5 output formats — console (colored), JSON, SARIF, Markdown, and GitHub Actions inline annotations.
  • Zero-config — sensible defaults work out of the box. Override anything via [tool.behave-lint] in pyproject.toml.
  • Plugin system — write custom rules and reporters as Python packages. Register via entry points.
  • CI/CD ready — deterministic output, clear exit codes, SARIF integration with GitHub Code Scanning.
  • Fast — sub-second on typical projects through caching and parallel execution.

Rules

CategoryPrefixRulesDefault Severity
CorrectnessBC10Error
Step DefinitionsBD5Warning
ConsistencyBK5Warning / Info
ComplexityBX6Warning
StyleBS8Warning
PedanticBP7Info
SecurityBSEC3Error
I18NBI18N3Warning
AccessibilityBACC3Warning

Auto-fixable rules

RuleFixSafety
BC004Replace invalid tag characters with _Safe
BD004Convert {param}<param>Safe
BD005Remove trailing punctuation from stepsSafe
BS001Convert tags to snake_caseSafe
BS005Insert missing Feature description templateUnsafe
BP001Insert @smoke tag on untagged scenariosUnsafe
BP005Append Valid values to unnamed ExamplesUnsafe
BP006Insert As a / I want / So that descriptionUnsafe

See the Auto-Fix guide for the full list.

Configuration

Configure behave-lint in your pyproject.toml:

[tool.behave-lint]
select = ["BC001", "BC002", "BS001"]
ignore = ["BP001", "BP002"]
fail-on = "warning"
exclude = ["features/wip/"]

[tool.behave-lint.severity]
BK001 = "info"

[tool.behave-lint.rules]
BX001 = { max-steps = 8 }
BP003 = { min-length = 5 }

Precedence (lowest → highest):

  1. Built-in defaults
  2. pyproject.toml [tool.behave-lint]
  3. Environment variables (BEHAVE_LINT_*)
  4. CLI flags

See the Configuration guide for all options.

CI/CD integration

GitHub Actions with SARIF

- run: pip install behave-lint
- run: behave-lint features/ --sarif --output-file behave-lint.sarif
- uses: github/codeql-action/upload-sarif@v3
  with:
    sarif_file: behave-lint.sarif

Inline annotations

- run: behave-lint features/ --output github

See the CI/CD guide for full workflows.

Output formats

FormatFlagUse case
Console--output consoleLocal development (default)
JSON--jsonCI pipelines, custom tooling
SARIF--sarifGitHub Code Scanning
Markdown--output markdownPR comments, reports
GitHub--output githubInline PR annotations

See the Output Formats reference for schema details.

Examples

Runnable example projects in the examples/ directory:

ExampleDescription
basic-usageMinimal project with configuration
auto-fixBefore/after demo of --fix
ci-cdGitHub Actions with SARIF upload
custom-rulesCustom rule plugin with entry points

Documentation

Full documentation is hosted at mathiaspaulenko.github.io/behave-lint.

User guide

Rules

Guides

Design documents

Development

git clone https://github.com/MathiasPaulenko/behave-lint.git
cd behave-lint
uv sync
uv run pre-commit install

# Run tests
uv run pytest

# Lint
uv run ruff check behave_lint/ tests/

# Type check
uv run mypy behave_lint/

# Build docs
uv run mkdocs build --strict

See CONTRIBUTING.md for detailed contribution guidelines, coding standards, and PR workflow.

License

MIT