Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Command model

Every source-facing command belongs to one of three namespaces. This gives automation a stable first decision: inspect, edit, or refactor.

  • paredit inspect reads and reports without writing.
  • paredit edit transforms one selected form; stdout by default, --diff for a unified diff, --write to update the file in place.
  • paredit refactor plans, previews, verifies, and applies semantic changes.

The only command outside these namespaces is the paredit completions <shell> meta command, which prints shell completion scripts for bash, zsh, fish, elvish, and powershell.

Run paredit <namespace> --help for the authoritative list on your installed version, and paredit <namespace> <command> --help for each command’s contract, arguments, and output formats. For a machine-readable catalog of the entire surface in one call, run:

paredit inspect capabilities --output json

Inspect

paredit inspect never writes source files. Prefer these commands for discovery, impact analysis, and preflight checks.

CommandPurpose
checkValidate that input is a balanced S-expression document.
dialectDetect Lisp dialect from --file extension or explicit --dialect.
statsPrint parse, dialect, and structural metrics for agent planning.
agent-reportPrint a complete JSON report for AI coding agent refactor planning.
capabilitiesPrint a machine-readable catalog of every command, flag, default, and enum value.
outlinePrint top-level forms with paths, spans, and definition hints.
formReport one selected form with local structure for refactor planning.
find-symbolFind exact atom occurrences without touching strings or comments.
symbolsReport exact atom occurrences across explicit files for rename planning.
callsReport list-head call sites across explicit files for arity refactor planning.
signatureCompare callable definitions and call-site arity across explicit files.
call-graphReport internal and optional external call graph edges.
impactReport refactoring impact risks for one symbol across explicit files.
workspaceDiscover Lisp sources under roots and report parse/refactor inventory.
dependenciesReport package, system, load, and qualified-symbol dependencies.
packagesReport Common Lisp package declarations across explicit files.
definitionsReport definition-like top-level forms across explicit files.
unused-definitionsReport definitions with no external exact atom references.
duplicatesReport repeated structural S-expression shapes across explicit files.
similarityReport structurally similar S-expression forms across explicit files.
letsReport local let bindings and inline safety for refactor planning.

Most reports accept --output json for machine-readable results.

Edit

paredit edit makes one structural transformation on the form selected by --path or --at (see Selecting forms). By default the rewritten document is printed to standard output and the file is untouched. Mutating commands also accept:

  • --diff — print a unified diff against the input instead of the whole rewritten document.
  • --write — persist the result back to --file. The write is refused if the rewritten document no longer parses, and file writes are staged with automatic rollback.
CommandPurpose
formatPrint a canonical, indentation-based rendering.
repair-unclosed-listsAppend matching delimiters for parser-detected unclosed lists; refuse all other parse errors.
selectPrint the S-expression selected by --path or --at.
replaceReplace the selected S-expression with replacement text.
killRemove the selected S-expression.
wrapWrap the selected S-expression in a new list.
spliceRemove one list pair while keeping its children.
raiseReplace the selected expression’s parent list with the selection.
transpose-forwardExchange the selected expression with its next sibling while keeping trivia in place.
transpose-backwardExchange the selected expression with its previous sibling while keeping trivia in place.
slurp-forwardPull the next sibling into the selected list.
slurp-backwardPull the previous sibling into the selected list.
barf-forwardPush the last child out of the selected list.
barf-backwardPush the first child out of the selected list.

For example, preview then apply a wrap of the third child of the first top-level form:

paredit edit wrap --file source.lisp --path 0.2 --diff
paredit edit wrap --file source.lisp --path 0.2 --write

Refactor

paredit refactor contains the reviewable workflow commands and the semantic refactorings they gate. See Refactor workflow for the plan/preview/verify/apply lifecycle.

Workflow commands

CommandPurpose
planProduce an ordered, gated refactoring plan for AI coding agents.
verifyVerify pre/post refactoring invariants for agents and CI gates.
previewPreview exact refactoring rewrites without modifying files.
checkValidate a refactor preview manifest without writing files.
statusSummarize a preview manifest into agent-safe next actions.
applyApply a previously generated preview manifest with hash guards.
diffRender a verified diff from a preview manifest without writing files.
workspace-planDiscover Lisp sources under roots and build a gated refactor plan.
workspace-previewDiscover sources and preview exact refactoring rewrites.
workspace-executeExecute a workspace refactor with preview gates and post-write verification.

Definition and file layout

CommandPurpose
remove-definitionPlan or remove a top-level definition from one file.
remove-unused-definitionsPlan or remove unused top-level definitions across files.
move-definitionPlan or move a top-level definition between files.
split-filePlan or split multiple top-level definitions into another file.
sort-definitionsPlan or sort contiguous top-level definition blocks in one file.
move-formPlan or move any top-level form between files.
insert-top-levelInsert exactly one top-level S-expression before, after, or at the end of a file.
replacement-planConvert duplicate groups into reviewed replace-forms batches.
replace-formsPlan or replace multiple reviewed forms in one file.

Packages

CommandPurpose
add-exportPlan or add a symbol to a Common Lisp defpackage :export option.
sort-package-exportsPlan or sort defpackage :export symbol designators.
sort-package-optionsPlan or sort defpackage option forms.
merge-package-optionsPlan or merge duplicate defpackage option forms.
rename-packagePlan or rename package designators and qualified prefixes.

Renames

CommandPurpose
rename-atRename whatever symbol occupies a byte offset, dispatching to the owning namespace and scope.
rename-symbolRename exact atom occurrences without touching strings or comments.
rename-in-formRename exact atom occurrences inside one selected form.
rename-bindingRename one local binding and only the references in its lexical scope.
rename-symbolsPlan or apply an exact atom rename across explicit files.
rename-functionPlan or apply a Common Lisp callable definition and designator rename.
rename-macroletPlan or apply a macrolet/compiler-macrolet binding and call-site rename.
rename-symbol-macroPlan or apply a define-symbol-macro binding and value-reference rename.
rename-local-functionPlan or apply a flet/labels local function binding and call-site rename.

Calls and functions

CommandPurpose
replace-function-callsPlan or replace callable call-site heads across explicit files.
wrap-function-callsPlan or wrap callable call sites in another function or macro call.
unwrap-function-callsPlan or remove a unary wrapper around callable call sites.
unwrap-callReplace one selected wrapper call with one selected argument.
thread-expressionConvert a nested call chain into a thread-first or thread-last pipeline.
unthread-expressionConvert a threading pipeline back into nested calls.
extract-functionExtract the selected expression into a top-level function with inferred parameters.
extract-local-functionExtract the selected expression into a Common Lisp flet or labels binding.
extract-constantExtract the selected expression into a top-level constant.
inline-functionInline one selected function call using a selected function definition.
inline-lambdaReplace a safe, immediately invoked Common Lisp lambda with a parallel let.
inline-local-functionInline the sole direct call in a safe, single-binding Common Lisp flet form.
inline-symbol-macroExpand a conservative single-binding Common Lisp symbol-macrolet form.
inline-literal-constantInline an immutable self-evaluating Common Lisp defconstant value.
convert-labels-to-fletConvert a non-recursive Common Lisp labels form into flet.
convert-flet-to-labelsConvert a Common Lisp flet form into labels when definition references cannot be captured.
rename-blockRename a selected Common Lisp block and matching return-from references.
rename-tagRename one tag in a selected Common Lisp tagbody and matching go references.
remove-unused-blockRemove a selected Common Lisp block with no matching return-from.
remove-unused-tagRemove an unreferenced tag from a selected Common Lisp tagbody.

Parameters and bindings

CommandPurpose
add-function-parameterAdd a parameter to a selected function and explicit call sites.
move-function-parameterMove one positional parameter in a function and its call sites.
swap-function-parametersSwap two positional parameters in a function and its call sites.
reorder-function-parametersReorder all positional parameters in a function and its call sites.
remove-function-parameterRemove one positional parameter from a function and its call sites.
introduce-letReplace the selected expression with a local binding in the enclosing list.
inline-letInline a single local let binding into its body.
convert-let-to-let-starConvert a Common Lisp or Emacs Lisp let to let* when later initializers do not reference earlier bindings.
convert-let-star-to-letConvert a Common Lisp let* to let when later initializers do not reference earlier bindings.
convert-do-star-to-doConvert a Common Lisp do* to do when later initializers and step expressions do not reference earlier bindings.
convert-prog-star-to-progConvert a Common Lisp prog* to prog when later initializers do not reference earlier bindings.
merge-nested-let-starMerge a directly nested Common Lisp or Emacs Lisp let* into one sequential binding form.
split-let-starSplit a Common Lisp or Emacs Lisp let* into nested sequential binding forms at --binding-index.
merge-nested-letMerge directly nested Common Lisp or Emacs Lisp parallel let forms when inner initializers are independent.
merge-nested-fletMerge directly nested Common Lisp flet forms when inner definitions do not reference outer local functions.
split-letSplit a Common Lisp or Emacs Lisp parallel let at --binding-index without capturing initializer references.
eliminate-empty-binding-formRemove an empty Common Lisp or Emacs Lisp let or let* from a known expression position.
flatten-prognFlatten directly nested Common Lisp or Emacs Lisp progn forms in a safe expression context.
convert-if-to-condConvert a Common Lisp or Emacs Lisp (if test then [else]) form to cond.
convert-cond-to-ifConvert simple Common Lisp or Emacs Lisp cond clauses to nested if forms.
convert-when-to-ifConvert a Common Lisp or Emacs Lisp when form to if.
convert-unless-to-ifConvert a Common Lisp or Emacs Lisp unless form to if.
convert-if-to-whenConvert a Common Lisp or Emacs Lisp if without a meaningful else to when.
convert-if-to-unlessConvert a Common Lisp or Emacs Lisp if with a literal nil then branch to unless.
remove-unused-bindingPlan or remove one unused local let binding.