Racket Coding Practices
Application skill for official Racket style learning (from the archived awesome-guidelines style capsules). Scribble and Typed Racket files follow guide exceptions noted in upstream docs.
Core Principle
Racket quality is DrRacket-readable text + explicit module contracts, kebab-case names, top-down provide sections, rackunit-guarded changes.
When to Use / NOT
#lang racket libraries, HtDP/2htdp teaching code, PLT-style packages.
- Setting up DrRacket indent, rackunit,
raco test, contract-out in CI.
NOT when:
- Generated
.rkt from macros/tools, validate generators.
- Scribble-only layout rules, see Scribble exceptions in official guide.
Workflow
- Textual, indent, parens, width (
racket-style-formatting-textual.md).
- Naming/constructs, kebab-case, define/cond/for (
racket-style-naming-constructs.md).
- Modules, provide, contracts, size (
racket-style-modules-contracts.md).
- Testing, rackunit, handlers (
racket-style-testing-verify.md).
- Verify, DrRacket indent-all,
raco test on changed files.
Red Flags
- Tab characters
- Lines >102 without wrap (no file-local waiver)
- C-style closing paren on own line mid-form
- DrRacket indent-all changes file
- camelCase or snake_case identifiers
- Underscores in regular names
- Context-only cryptic abbreviations
- Nested
if/begin where cond/match fits
- Heavy nested
let where internal define works
- Long unnamed
lambda bodies
- Macro where function works
(provide (all-defined-out))
- provide blocks scattered at file bottom
- Missing purpose comment on exports
- Module >1000 lines without split plan
- Function >> screen height without decomposition
- Missing
contract-out on public ADT modules
- Catch-all
(lambda (_ #t) #t) handlers
- Bare
exn? handler catching breaks
- Manual parameter save/restore vs
parameterize
- Graphical syntax boxes in
.rkt
- Plural collection module names
- Magic numbers without named constants
- Bug fix without rackunit regression
- No
(module+ test …) on nontrivial new module
- Trailing whitespace
- Missing EOF newline
- Single
; where ;; section comment expected
- Graphical comment boxes breaking plain-text editors
Verification
- DrRacket "Indent All" leaves file unchanged (or documented exception at top)
raco test path/to/changed.rkt (or package test suite)
- provide/contract-out audit on new exports
- Handler predicate precision review
- Capsule checklist on kebab-case + top-down module layout
References
awesome-guidelines/references/racket-style-learning-note.md
awesome-guidelines/references/racket-style-formatting-textual.md
awesome-guidelines/references/racket-style-naming-constructs.md
awesome-guidelines/references/racket-style-modules-contracts.md
awesome-guidelines/references/racket-style-testing-verify.md
1---2name: racket-coding-practices3description: Use when authoring or reviewing Racket, DrRacket indent, kebab-case naming, define/cond/for idioms, provide/contract-out modules, rackunit tests, and raco test in CI.4---56# Racket Coding Practices78Application skill for official Racket style learning (from the archived `awesome-guidelines` style capsules). Scribble and Typed Racket files follow guide exceptions noted in upstream docs.910## Core Principle1112Racket quality is **DrRacket-readable text + explicit module contracts**, kebab-case names, top-down provide sections, rackunit-guarded changes.1314## When to Use / NOT1516- `#lang racket` libraries, HtDP/2htdp teaching code, PLT-style packages.17- Setting up DrRacket indent, rackunit, `raco test`, contract-out in CI.1819**NOT when:**2021- Generated `.rkt` from macros/tools, validate generators.22- Scribble-only layout rules, see Scribble exceptions in official guide.2324## Workflow25261. **Textual**, indent, parens, width (`racket-style-formatting-textual.md`).272. **Naming/constructs**, kebab-case, define/cond/for (`racket-style-naming-constructs.md`).283. **Modules**, provide, contracts, size (`racket-style-modules-contracts.md`).294. **Testing**, rackunit, handlers (`racket-style-testing-verify.md`).305. **Verify**, DrRacket indent-all, `raco test` on changed files.3132## Red Flags3334- Tab characters35- Lines >102 without wrap (no file-local waiver)36- C-style closing paren on own line mid-form37- DrRacket indent-all changes file38- camelCase or snake_case identifiers39- Underscores in regular names40- Context-only cryptic abbreviations41- Nested `if`/`begin` where `cond`/`match` fits42- Heavy nested `let` where internal `define` works43- Long unnamed `lambda` bodies44- Macro where function works45- `(provide (all-defined-out))`46- provide blocks scattered at file bottom47- Missing purpose comment on exports48- Module >1000 lines without split plan49- Function >> screen height without decomposition50- Missing `contract-out` on public ADT modules51- Catch-all `(lambda (_ #t) #t)` handlers52- Bare `exn?` handler catching breaks53- Manual parameter save/restore vs `parameterize`54- Graphical syntax boxes in `.rkt`55- Plural collection module names56- Magic numbers without named constants57- Bug fix without rackunit regression58- No `(module+ test …)` on nontrivial new module59- Trailing whitespace60- Missing EOF newline61- Single `;` where `;;` section comment expected62- Graphical comment boxes breaking plain-text editors6364## Verification6566- DrRacket "Indent All" leaves file unchanged (or documented exception at top)67- `raco test path/to/changed.rkt` (or package test suite)68- provide/contract-out audit on new exports69- Handler predicate precision review70- Capsule checklist on kebab-case + top-down module layout717273## References7475- `awesome-guidelines/references/racket-style-learning-note.md`76- `awesome-guidelines/references/racket-style-formatting-textual.md`77- `awesome-guidelines/references/racket-style-naming-constructs.md`78- `awesome-guidelines/references/racket-style-modules-contracts.md`79- `awesome-guidelines/references/racket-style-testing-verify.md`