···11+---
22+name: resyntax
33+description: "Use this skill whenever running Resyntax to analyze or refactor Racket code. Triggers include: any mention of 'resyntax', 'refactoring' in a Racket context, requests to find idiomatic improvements in Racket code, or requests to clean up or modernize Racket code. Also use when the user asks to run linting or style checks on Racket files."
44+---
55+66+# Resyntax
77+88+## Overview
99+1010+Resyntax is a refactoring tool for Racket. It analyzes Racket code and suggests
1111+idiomatic improvements, powered by `syntax-parse`-based refactoring rules. Use
1212+it to find and automatically apply refactorings such as removing legacy API
1313+calls, simplifying expressions, and modernizing code style.
1414+1515+Resyntax has two modes: **analyze** (report suggestions) and **fix** (apply
1616+changes to files directly).
1717+1818+---
1919+2020+## Running Resyntax
2121+2222+Resyntax is a *launcher*, not a `raco` command. Run it as `resyntax`, NOT
2323+`raco resyntax`.
2424+2525+```sh
2626+# Analyze a single file (report suggestions without modifying anything)
2727+resyntax analyze --file path/to/file.rkt
2828+2929+# Analyze all files in a directory
3030+resyntax analyze --directory path/to/project/
3131+3232+# Analyze an installed package
3333+resyntax analyze --package my-package
3434+3535+# Analyze only files changed relative to a Git branch
3636+resyntax analyze --local-git-repository . origin/main
3737+```
3838+3939+### Applying fixes
4040+4141+Use `resyntax fix` to apply suggested changes directly to files. **Always prefer
4242+`resyntax fix` over manually reproducing suggestions.** This ensures changes are
4343+exactly what Resyntax intended and makes auditing easier.
4444+4545+```sh
4646+# Fix a single file
4747+resyntax fix --file path/to/file.rkt
4848+4949+# Fix all files in a directory
5050+resyntax fix --directory path/to/project/
5151+5252+# Fix an installed package
5353+resyntax fix --package my-package
5454+5555+# Fix only files changed relative to a Git branch
5656+resyntax fix --local-git-repository . origin/main
5757+```
5858+5959+---
6060+6161+## Workflow: Using Resyntax to refactor code
6262+6363+Follow this workflow when using Resyntax to improve code quality:
6464+6565+### Step 1: Analyze to find suggestions
6666+6767+Run `resyntax analyze` first to see what Resyntax would change, without
6868+modifying any files. Review the output to understand the suggestions.
6969+7070+```sh
7171+resyntax analyze --file path/to/file.rkt
7272+```
7373+7474+Output looks like:
7575+7676+```
7777+resyntax: path/to/file.rkt:43:5 [rule-name]
7878+7979+ Description of the suggested change.
8080+8181+ 43 (original-code ...)
8282+8383+ 43 (suggested-replacement ...)
8484+```
8585+8686+Each suggestion includes:
8787+- The file, line, and column
8888+- The rule name in brackets (e.g. `[syntax-protect-migration]`)
8989+- A description of why the change is suggested
9090+- The original code and the replacement
9191+9292+### Step 2: Apply fixes with `resyntax fix`
9393+9494+Once you've reviewed the suggestions and they look appropriate, use
9595+`resyntax fix` to apply them:
9696+9797+```sh
9898+resyntax fix --file path/to/file.rkt
9999+```
100100+101101+Resyntax modifies files in place. It may run multiple passes, since applying one
102102+fix can unlock further fixes.
103103+104104+### Step 3: Run tests to verify
105105+106106+Always run the project's tests after applying fixes:
107107+108108+```sh
109109+raco test path/to/file.rkt
110110+```
111111+112112+### Step 4: Review the diff
113113+114114+Check what Resyntax actually changed:
115115+116116+```sh
117117+git diff
118118+```
119119+120120+This lets you (and reviewers) confirm the changes are correct before committing.
121121+122122+---
123123+124124+## Useful options
125125+126126+### Limiting scope
127127+128128+```sh
129129+# Apply at most N fixes
130130+resyntax fix --file foo.rkt --max-fixes 5
131131+132132+# Modify at most N files
133133+resyntax fix --directory src/ --max-modified-files 3
134134+135135+# Modify at most N lines total
136136+resyntax fix --directory src/ --max-modified-lines 50
137137+```
138138+139139+### Targeting specific rules
140140+141141+```sh
142142+# Only analyze with a specific refactoring rule
143143+resyntax analyze --file foo.rkt --refactoring-rule if-else-false-to-and
144144+145145+# Only fix with a specific refactoring rule
146146+resyntax fix --file foo.rkt --refactoring-rule syntax-protect-migration
147147+```
148148+149149+### Timeouts
150150+151151+The default analyzer timeout is 10 seconds per analyzer per file. Increase it
152152+for files that are slow to expand:
153153+154154+```sh
155155+resyntax analyze --file foo.rkt --analyzer-timeout 30000
156156+```
157157+158158+### Git integration
159159+160160+The `--local-git-repository` option is useful for analyzing only files that have
161161+been modified in a branch:
162162+163163+```sh
164164+resyntax analyze --local-git-repository /path/to/repo origin/main
165165+```
166166+167167+### Output formats for `resyntax fix`
168168+169169+```sh
170170+# Output a commit message summarizing fixes to stdout
171171+resyntax fix --file foo.rkt --output-as-commit-message
172172+173173+# Output results as JSON
174174+resyntax fix --file foo.rkt --output-as-json
175175+176176+# Create individual Git commits for each fix
177177+resyntax fix --directory src/ --create-multiple-commits
178178+```
179179+180180+---
181181+182182+## Important: always use `resyntax fix`, not manual edits
183183+184184+When applying Resyntax suggestions, **always use `resyntax fix`** to apply
185185+changes rather than manually editing files to match the suggestion output. This
186186+is important because:
187187+188188+1. It guarantees the applied change exactly matches what Resyntax computed.
189189+2. It eliminates the risk of introducing typos or subtle differences when
190190+ reproducing suggestions by hand.
191191+3. It makes code review easier — reviewers can trust that the diff came from the
192192+ tool itself.
193193+194194+The only reason to manually edit would be if `resyntax fix` fails on a specific
195195+file (e.g., due to expansion errors) but `resyntax analyze` was able to show the
196196+suggestion. In that case, note in the commit message that the change was applied
197197+manually based on a Resyntax suggestion.