AGENTS.md · sqlfluff/sqlfluff
AGENTS.md from sqlfluff/sqlfluff: 289 lines covering Project Overview, Repository Structure, Universal Conventions, Core Commands and more.
Template by sqlfluff
Chalk Labs
Need help deploying AGENTS.md · sqlfluff/sqlfluff?
Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.
Install
Works with Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Claude Code. Read the repository before you give any tool access to your data.
curl -fsSL https://raw.githubusercontent.com/sqlfluff/sqlfluff/main/AGENTS.md -o AGENTS.md
Read it and adapt it to your project before use.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: prompt-engineering
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
What's in it
An AGENTS.md file: instructions coding agents (Codex, Cursor, Copilot, Gemini CLI and others) read before working in a repo.
- For
- Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Claude Code
- Length
- 289 lines
- File
AGENTS.md
Sections
- Project Overview
- Repository Structure
- Universal Conventions
- Core Commands
- Architecture Principles
- Development Workflows
- Component-Specific Instructions
- Common Pitfalls
- Configuration
- Plugin System
- Quick Reference
First lines (shown under the repo's MIT license)
# SQLFluff AI Coding Assistant Instructions ## Project Overview SQLFluff is a dialect-flexible SQL linter and auto-fixer supporting 25+ SQL dialects including T-SQL, PostgreSQL, BigQuery, MySQL, Snowflake, and more. The project is written primarily in **Python** with an experimental **Rust** component for performance optimization. **Core Architecture:** - **Parser-first design**: SQL is lexed → parsed into segment trees → linted by rules → optionally auto-fixed - **Dialect inheritance**: Each dialect extends ANSI base grammar using `.replace()` to override specific segments - **Segment-based AST**: Everything is a `BaseSegment` subclass forming a recursive tree structure - **Rule crawlers**: Rules traverse segment trees to find violations and generate `LintFix` objects ## Repository Structure ``` / ├── src/sqlfluff/ # Main Python package (see src/sqlfluff/AGENTS.md) │ ├── dialects/ # SQL dialect definitions (see src/sqlfluff/dialects/AGENTS.md) │ ├── rules/ # Linting rules by category │ ├── core/ # Parser, lexer, config infrastructure │ ├── cli/ # Command-line interface │ └── api/ # Public Python API ├── sqlfluffrs/ # Experimental Rust components (see sqlfluffrs/AGENTS.md) ├── test/ # Test suite (see test/AGENTS.md) │ ├── fixtures/ # Test data (SQL files, YAML expected outputs) │ ├── dialects/ # Dialect parsing tests │ └── rules/ # Rule testing infrastructure ├── docsv/ # VitePress documentation (see docsv/README.md) ├── plugins/ # Pluggable extensions (dbt templater, examples) ├── utils/ # Build and development utilities └── examples/ # API usage examples ``` ## Universal Conventions ### Language Support - **Python**: 3.10 minimum, 3.13 recommended for development, 3.14 supported - **Rust**: Experimental, used for performance-critical lexing/parsing ### Code Quality Standards - **Formatting**: Black (Python), rustfmt (Rust) - **Linting**: Ruff + Flake8 (Python), clippy (Rust) - **Type Checking**: Mypy strict mode (Python) - **Pre-commit hooks**: Run before all commits via `.venv/bin/pre-commit run --all-files` ### Testing Philosophy - All tests must pass before merging - Test coverage should reach 100% - Use YAML fixtures for dialect/rule tests - Mirror source structure in test directories ### Commit Messages - Keep messages clear and descriptive - Reference issue numbers when applicable - Use conventional commit style when appropriate ## Core Commands ### Environment Setup ```bash # Create development environment (first time) tox -e py312 --devenv .venv source .venv/bin/activate # Always activate before working in a new terminal source .venv/bin/activate ``` ### Testing ```bash # Run full test suite tox # Run specific Python version tests tox -e py312 # Run with coverage tox -e cov-init,py312,cov-report,linting,mypy # Quick dialect test (after adding SQL fixtures) python test/generate_parse_fixture_yml.py -d tsql ``` ### Quality Checks ```bash # Run all pre-commit checks (format, lint, type check) .venv/bin/pre-commit run --all-files # Individual checks ruff format src/ test/ # Format ruff check src/ test/ # Lint mypy src/sqlfluff/ # Type check ``` ### Building ```bash # Install package in editable mode (done automatically by tox --devenv) pip install -e . # Install plugins pip install -e plugins/sqlfluff-templater-dbt/ ``` ## Architecture Principles ### Layer Separation The codebase enforces strict architectural boundaries (via `importlinter` in `pyproject.toml`): - `core` layer cannot import `api`, `cli`, `dialects`, `rules`, or `utils` - `api` layer cannot import `cli` - Dependencies flow: `linter` → `rules` → `parser` → `errors`/`types` → `helpers` ### Immutability - Segments are immutable - never modify directly - Use `.copy()` or `LintFix` mechanisms for changes - Parser creates fresh tree structures ### Lazy Loading - Dialects loaded via `dialect_selector()` or `load_raw_dialect()` - Never import dialect modules directly - Supports dynamic dialect discovery ## Development Workflows ### Adding Dialect Features 1. Create `.sql` test files in `test/fixtures/dialects/<dialect>/` 2. Run `python test/generate_parse_fixture_yml.py -d <dialect>` to generate expected `.yml` outputs 3. Implement grammar in `src/sqlfluff/dialects/dialect_<name>.py` 4. Use `dialect.replace()` to override inherited ANSI segments 5. Verify: `tox -e generate-fixture-yml -- -d <dialect>` See `src/sqlfluff/dialects/AGENTS.md` for detailed dialect development guide. ### Grammar is Permissive, Not a Validator SQLFluff's parser is a **loose, allowable grammar** — not a SQL validator. It is deliberately more permissive than any real engine, and parsing SQL that a given database would reject is **not** a bug. So, when adding or reviewing dialect grammar: - ❌ Don't add (or ask contributors to add) "negative tests" asserting that invalid SQL fails to parse — no `unparsable` fixtures, no `pytest.raises(SQLParseError)` for "this should be rejected". - ✅ Only add positive fixtures: valid SQL that must parse, plus its expected `.yml` tree. - ❌ Don't tighten a grammar purely to reject something. Rejection is the engine's job; over-tightening breaks dialect variants, vendor extensions and templated SQL. - ✅ Keep clause ordering, optionality and combinations loose unless a *valid* statement would otherwise mis-parse. - ❌ **"`<engine>`-invalid SQL such as `...` parses successfully"** is not a finding on its own. Neither is "this accepts X despite the docs/docstring saying only Y". Both describe intended behaviour. - ✅ **Parse time is not execution time.** A statement the server accepts syntactically and then rejects at runtime (semantic errors, privilege errors, "unknown column", MySQL error 1396, …) must still parse cleanly. A finding here is only real if it names **valid SQL that fails to parse**, or valid SQL that parses into the wrong tree. "Invalid SQL is accepted" is working as designed.
Signals
- Stars
- 9,990
- Forks
- 1,262
- Open issues
- 263
- Last commit (this folder)
- Oct 12, 2026 (18 days ago)
- Last release
- Oct 2, 2026 (28 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/sqlfluff/sqlfluff
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
Done for you
Rather not set it up yourself?
Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.
See how we build AI agents →Read the case studies
Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.
- launches shipped
- 50+
- launches shipped
- media placements
- 500+
- media placements
- founders on every account
- 2
- founders on every account
Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block
Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.
Get AGENTS.md · sqlfluff/sqlfluff running in your business
Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.
Cite this page
AGENTS.md · sqlfluff/sqlfluff. Agent Mart. https://agentmart.dev/templates/sqlfluff-sqlfluff-agents-md (last updated 2026-10-24)