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 racketlibraries, HtDP/2htdp teaching code, PLT-style packages.- Setting up DrRacket indent, rackunit,
raco test, contract-out in CI.
NOT when:
- Generated
.rktfrom 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 teston 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/beginwherecond/matchfits - Heavy nested
letwhere internaldefineworks - Long unnamed
lambdabodies - 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-outon 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.mdawesome-guidelines/references/racket-style-formatting-textual.mdawesome-guidelines/references/racket-style-naming-constructs.mdawesome-guidelines/references/racket-style-modules-contracts.mdawesome-guidelines/references/racket-style-testing-verify.md