Expert guide for developing PRQL compiler with tiered testing, snapshot testing, error handling best practices, and CLI usage patterns
Expert development guide for PRQL (Pipelined Relational Query Language) — a modern SQL replacement. This skill covers the complete development workflow including tiered testing strategy, snapshot testing patterns, error handling conventions, and CLI usage.
Use a three-tier testing approach to iterate quickly while validating thoroughly:
Fast tests on core packages for rapid iteration:
```sh
task prqlc:test
cargo insta test -p prqlc --lib -- resolver
cargo insta test -p prqlc --test integration -- date
```
Comprehensive validation sufficient for most changes:
```sh
task prqlc:pull-request
```
Only run when changes affect language bindings:
```sh
task test-all
```
**Token Optimization**: The test suite minimizes output with:
Prefer inline snapshots for almost all tests:
```rust
insta::assert_snapshot!(result, @"expected output");
```
Initialize with empty snapshots, then run with `--accept`:
```rust
insta::assert_snapshot!(result, @"");
```
Run test commands with `--accept` to auto-fill results.
**Prefer small inline `insta` snapshot tests** over full integration tests:
**Use inline tests for:**
**Use integration tests** (`prqlc/tests/integration/queries/*.prql`) only when:
**Example inline test:**
```rust
#[cfg(test)]
mod test {
use insta::assert_snapshot;
#[test]
fn test_my_feature() {
let query = "from employees | filter country == 'USA'";
assert_snapshot!(crate::tests::compile(query).unwrap(), @"");
}
}
```
View `prqlc` output for any compilation stage:
```sh
cargo run -p prqlc -- compile "from employees | filter country == 'USA'"
cargo run -p prqlc -- fmt "from employees | filter country == 'USA'"
cargo run -p prqlc -- --help
```
Run all lints:
```sh
task lint
```
Never panic on user input or recoverable errors. Use proper error returns:
Avoid 2nd person (you/your). Use softer modal verbs like "might" for friendlier tone:
Build and view crate documentation:
```sh
cargo doc -p prqlc
View target/doc/prqlc/index.html
View target/doc/prqlc/module_name/index.html
View target/doc/prqlc/fn.compile.html
```
For releases or environment issues, consult `web/book/src/project/contributing/development.md`.
1. **Test incrementally**: Start with fast inner-loop tests, expand only as needed
2. **Snapshot everything**: Inline snapshots make tests readable and maintainable
3. **Never panic**: Handle user errors gracefully with proper error types
4. **Friendly errors**: Use indirect language ("might be missing") instead of accusatory tone
5. **Token efficiency**: Testing infrastructure optimized to reduce AI context usage
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/prql-development-workflow/raw