| name | daemon-repl |
| description | Daemon REPL for Elisp โ evaluate Elisp code in a running Emacs daemon via emacsclient, validate brackets before save, auto-evaluate .el files on change. Use when you need to run Elisp from outside Emacs, check daemon status, or validate Elisp syntax. |
| metadata | {"molecules":["daemon-repl","elisp","repl","emacsclient"],"level":"compound"} |
Daemon REPL for OV5
Not the Clojure brepl CLI tool. This is the Elisp daemon REPL for OV5. These two skills have similar names but different tools:
daemon-repl (this skill) โ Elisp evaluation via emacsclient
brepl (see that skill) โ Clojure nREPL client via babashka
brepl brings bracket-fixing REPL concepts from ClojureScript to Emacs Lisp in OV5. It enables AI agents to safely generate, validate, and evaluate Elisp code.
Emacsclient Bash Pattern (for opencode agents)
When calling from outside Emacs (e.g., from a shell or an agent), use this pattern:
emacsclient -s /tmp/emacs$(id -u)/pmf-value-stream -a false --eval "$(cat <<'EOF'
(gptel-daemon-repl-status)
EOF
)"
Safety rules:
- Always use
-a false so emacsclient never auto-spawns a daemon.
- Always use heredoc (
<<'EOF') for Elisp quoting โ prevents shell variable expansion.
- Wrap multi-form code in
progn.
For a different server name, replace pmf-value-stream with your daemon name. For the default server daemon:
emacsclient -s /tmp/emacs$(id -u)/server -a false --eval "$(cat <<'EOF'
(gptel-daemon-repl-status)
EOF
)"
Concepts
- Bracket fixing: Validate and auto-fix unbalanced parentheses before saving
.el files
- Daemon REPL: Evaluate expressions via
emacsclient in a running Emacs daemon
- Auto-eval: Watch
.el files and automatically evaluate them after save
- Self-heal integration: On evaluation failure, trigger OV5 self-healing
Usage
Evaluate Expression (Elisp API)
For Emacs-internal use:
(gptel-daemon-repl-eval-expression "(+ 1 2 3)")
Returns result as string, or signals error if daemon is not running.
Evaluate Expression (emacsclient)
From outside Emacs:
emacsclient -s /tmp/emacs$(id -u)/server -a false --eval "$(cat <<'EOF'
(gptel-daemon-repl-eval-expression "(+ 1 2 3)")
EOF
)"
Evaluate File (Elisp API)
(gptel-daemon-repl-eval-file "lisp/modules/foo.el")
Loads the file in the daemon. Reports success/failure.
Evaluate File (emacsclient)
emacsclient -s /tmp/emacs$(id -u)/server -a false --eval "$(cat <<'EOF'
(gptel-daemon-repl-eval-file "lisp/modules/foo.el")
EOF
)"
Validate Brackets (Elisp API)
(gptel-daemon-repl-validate-brackets "(defun foo () 42")
Returns plist:
:valid โ t if balanced
:fixed-content โ auto-fixed string (if fixable)
:error โ error message (if unfixable)
Check Status
Elisp API:
(gptel-daemon-repl-status)
emacsclient:
emacsclient -s /tmp/emacs$(id -u)/server -a false --eval "$(cat <<'EOF'
(gptel-daemon-repl-status)
EOF
)"
Returns plist with:
:enabled โ is brepl active?
:server-accessible โ is daemon socket reachable?
:socket-dir โ where sockets are found
:watches โ number of active directory watches
Interactive Status Buffer
M-x gptel-daemon-repl-show-status
Opens *brepl-status* buffer with full diagnostics.
Configuration
(setq gptel-daemon-repl-enabled t) ; Master switch
(setq gptel-daemon-repl-eval-on-save t) ; Auto-eval after save
(setq gptel-daemon-repl-validate-brackets t) ; Fix brackets before save
(setq gptel-daemon-repl-socket-dir nil) ; Auto-detect if nil
(setq gptel-daemon-repl-default-server "server") ; Server name
Integration with OV5
Edit Tool Hook
When an AI agent edits an .el file via the Edit tool:
- Before save:
gptel-daemon-repl-validate-brackets checks syntax
- Auto-fix: If unbalanced, fixes are applied automatically
- After save: File is evaluated via
emacsclient
- On failure:
gptel-auto-workflow--self-heal-semantic is triggered
Experiment Workflow
When OV5 experiments generate new Elisp:
;; After writing experiment output
(gptel-daemon-repl-eval-file experiment-file)
;; โ If error, self-heal fixes syntax/runtime issues
;; โ If success, file is ready for commit
Error Recovery
Evaluation errors trigger the self-healing pipeline:
- brepl detects eval failure
- Calls
gptel-auto-workflow--self-heal-semantic on the file
- Self-heal audits, fixes syntax, re-evaluates
- Loop continues until file loads cleanly
Socket Discovery
brepl auto-discovers Emacs daemon sockets in this order (from gptel-ext-daemon-repl.el lines 71-88):
server-socket-dir (Emacs 29+ built-in)
/run/user/$UID/emacs/ (XDG, Linux)
/tmp/emacs$UID/ (standard, macOS/Linux)
${TMPDIR}/emacs$UID/ (macOS with custom TMPDIR)
~/.emacs.d/server/ (fallback)
Override with gptel-daemon-repl-socket-dir.
File Watch
brepl watches lisp/modules/ for .el changes:
(gptel-daemon-repl-watch-directory "lisp/modules/")
Only evaluates:
.el files (not .elc, not autoloads)
- Not in
tests/ directories
- Not dotfiles
Requirements
- Emacs daemon running (
emacs --daemon or server-start)
emacsclient in PATH
file-notify support (for auto-eval watch)
Files
lisp/modules/gptel-ext-daemon-repl.el โ main module
tests/test-daemon-repl.el โ test suite
- Loaded via
lisp/gptel-config.el
Related Skills
brepl โ Clojure nREPL client (separate tool, similar name โ don't confuse)
ov5 โ OV5 cowork guide (pipeline, researcher, evolution)
ov5-status โ focused system health check