Elisp Package Review Skill
You are performing a structured code review of an Emacs Lisp package. Your goal
is to produce a prioritised action plan the author can work through at their
own pace. Do NOT rewrite code unless explicitly asked — flag issues and explain
them clearly.
Phase 1: Orientation
Before diving into issues, briefly orient yourself:
- Read every
.elfile in the package. - Identify the package's purpose, entry points, public API, and key data flows.
- Note the Emacs version target and any declared dependencies (
Package-Requires). - Check whether
lexical-bindingis enabled in every file.
State a one-paragraph summary of what the package does before listing any issues.
Phase 2: Review Dimensions
Work through each dimension below in order. Collect ALL findings before
presenting — do not present dimension-by-dimension.
1. Correctness & Bugs
Look for logic errors and runtime hazards:
- Unguarded
car/cdron potentially-nil values — usewhen,if-let, or
and to guard.
- Off-by-one errors in list/string indexing.
- Mutation of shared structure — accidental aliasing via
setcar/setcdr. - Process/buffer leaks — processes or temp buffers created but never cleaned
up; missing unwind-protect.
- Async race conditions — timer or sentinel callbacks that assume buffer/
process state that may have changed.
- Wrong equality predicate —
eqvsequalvsstring=misuse. - Incorrect use of
mapcarvsmapc— usingmapcarwhen return value is
discarded (wasteful allocation).
save-excursion/save-restrictionmisuse — forgetting to restore state
after buffer modifications.
- Hook not removed on cleanup — hooks added in init but never removed in
teardown/disable path.
- Advice not removed —
advice-addwithout correspondingadvice-removein
disable/unload path.
- Missing
require— symbols used from libraries not explicitly required. - Circular or redundant
require— files requiring each other or requiring
things already guaranteed by dependencies.
2. Emacs Lisp Style & Conventions
Check against established community conventions:
File header:
;;; package-name.el --- Short description -*- lexical-binding: t -*-;;; Commentary:section present and informative.;;; Code:marker present.;;; package-name.el ends herefooter present.Package-Version,Package-Requires,Author,Keywords,URLheaders
present and accurate.
Naming:
- All public symbols prefixed with
package-name-(or agreed namespace). - Internal/private symbols prefixed with
package-name--(double dash). - Constants use
defconstnotdefvar. - Booleans named with
-psuffix (package-name-verbose-p).
Docstrings:
- Every
defun,defvar,defcustom,defface,define-minor-modehas a
docstring.
- First line of docstring is a complete sentence ending in
.and ≤80 chars. - Interactive commands document their argument in the first line if applicable.
defcustomdocstrings describe valid values.
Customisation:
- User-facing variables use
defcustom, notdefvar. defcustomhas correct:type,:group, and:safewhere appropriate.- A
defgroupexists for the package.
Functions:
- Prefer
cl-libover deprecatedclpackage (cl-loop,cl-destructuring-bind, etc.). - Prefer
seq-functions over manual recursion for sequence operations. - Avoid
flet/labels— usecl-flet/cl-labels. - Avoid
lexical-let— unnecessary withlexical-binding: t. interactivespec is correct and uses modern forms (e.g.(interactive "r")
not deprecated forms).
- Functions that modify buffers use
with-current-bufferrather than relying on
implicit current buffer.
Control flow:
- Prefer
when/unlessover(if ... nil)/(if ... t). - Prefer
condover deeply nestedif. - Prefer
pcaseover complexcondmatching on structure. - Avoid
(not (not x))— use(and x t)or just trust truthiness.
3. Performance & Optimisation
- Repeated
buffer-substring/buffer-stringin tight loops — cache the
result.
re-search-forwardin loops withoutnarrow-to-region— can be
O(n²); consider reorganising.
appendin loops — quadratic; preferpush+nreverse.lengthon a list to check emptiness — usenullorconspinstead.- Uncompiled lambdas in hot paths — prefer named functions or ensure byte
compilation.
- Large
defconstdata — consider lazy initialisation if not always needed. sit-for 0/redisplayin loops — usually a sign of a design smell;
flag and explain.
- Synchronous process calls blocking UI — prefer async with sentinels or
make-process.
- Unnecessary
with-temp-buffer— if only string operations are needed,
avoid buffer allocation.
- Timer granularity — timers firing too frequently (< 0.1s) without clear
need.
font-lock-add-keywordscalled repeatedly — should be called once, not on
every mode activation.
4. Autoloads & Load-Time Cost
- All entry-point commands and public functions the user calls directly should
have ;;;###autoload cookies.
- No expensive computation at top level (i.e. outside any function) — this runs
at load time.
defvar/defcustomat top level is fine;defunbodies running at load
time are not.
requireat top level is acceptable but flag heavy requires that could be
deferred with with-eval-after-load or autoload.
5. Compatibility & Portability
- Flag use of functions introduced after the declared minimum Emacs version in
Package-Requires.
- Flag OS-specific code paths without appropriate guards (
system-typechecks). - Flag hard-coded paths.
- Flag any use of
(require 'cl)— must use(require 'cl-lib).
6. Error Handling & Robustness
condition-caseused where failures are plausible (network, file I/O,
subprocess).
- Error messages are user-readable (not raw Lisp objects).
user-errorused for user-facing mistakes (noterror), so Edebug doesn't
trap them.
unwind-protectused wherever resources (buffers, processes, overlays) are
allocated.
Phase 3: Output Format
Present findings as a structured action plan using the following format.
Group by severity. Within each group, order by file then by approximate line
number.
## Package Review: <package-name>
### Summary
<One paragraph: what the package does, overall impression, headline numbers>
---
### 🔴 Critical — Fix Before Release
Issues that will cause errors, data loss, or broken behaviour.
#### C1. <Short title>
**File:** `foo.el` **~Line:** 42
**Issue:** <Clear explanation of the problem and why it matters>
**Suggestion:** <What to do — no code rewrite, just direction>
#### C2. ...
---
### 🟠 Important — Strong Recommendation
Style violations, missing conventions, or meaningful inefficiencies.
#### I1. <Short title>
...
---
### 🟡 Minor — Worth Addressing
Small style issues, minor optimisations, nitpicks.
#### M1. <Short title>
...
---
### 💡 Optimisation Opportunities
Performance improvements worth considering, ordered by estimated impact.
#### O1. <Short title>
...
---
### ✅ Strengths
Brief list of things done well — keep this honest and specific.
Phase 4: Closing Note
After the plan, add a short paragraph:
"This is a plan for you to action at your own pace — not all items need to be
addressed. Prioritise 🔴 Critical items first. Feel free to ask me to elaborate
on any specific finding or to help implement a fix."
Review Principles
- Flag, don't fix. Explain the problem and point in a direction. The author
decides what to do.
- Be specific. Always cite the file and approximate line number.
- Be proportionate. A one-file utility and a major package deserve different
levels of rigour — calibrate accordingly.
- No ERT / testing review. Do not comment on presence or absence of tests.
- Respect intent. If a pattern looks unusual but is clearly deliberate,
note it as a question rather than a violation.