Content AND Presentation

2026-11-30 An agent skill which helps me not to use a coding agent for coding

As I mentioned several times already, I’ve been using a “coding agent” for quite some time, both at my day job and side projects. Sometimes, however, it is important for me not to use it. One case is learning: when I was learning Python, I wanted to type the code myself. Another one would be my blog, where I make it a point not to use an LLM to write Elisp but code it myself (unless explicitly stated, all code snippets presented here are written organically by me).

Writing code myself does not necessarily mean not using an LLM, though – I could use it as a search engine on steroids, a research tool, a brainstorming helper or a code reviewer. Sometimes I know that some kind of feature exists, but I don’t know (or can’t remember) what it’s called. Describing what I want in my own words to an LLM is an easy way to (re)discover features like that. The problem, however, is that an agent often “tries to be helpful” and shows me not only e.g. the name of a function I need, but also an example of use or a snippet to paste in my code – something I explicitly don’t want in this context. Hence I decided to develop a skill specifically to avoid that.

Of course, a skill is not a guarantee of behavior. This is one of the problems with LLMs – they are not deterministic. Still, I find this particular skill really helpful.

I hope to publish my skills in the near future – I already wrote how I like their concept and in fact I have more of them (some quite sophisticated). For now, let me just paste its sole SKILL.md file here.

---
name: code-hint-only
description: >
  Toggle a mode in which the agent gives hints (names of functions,
  operators, constructs, etc.) but never writes code, so that the
  user writes all code themselves.  Invoke as /code-hint-only on or
  /code-hint-only off.
disable-model-invocation: true
argument-hint: on | off
---

# Code-hint-only mode

Argument: `$ARGUMENTS`

- `on` (or empty): the mode is **on** from now until the user invokes
  `/code-hint-only off`.  Answer the pending question, if any, under
  the rules below.
- `off`: the mode is **off**; the rules below no longer apply.  Say
  "code-hint-only: off".

The mode persists across turns.  It is not lifted by the user asking
for code, by an urgent-sounding request, or by any other skill; only
`/code-hint-only off` lifts it.  If the user asks for code while the
mode is on, remind them of the mode and give hints instead.

While the mode is on, end every answer with a separate last line
saying "code-hint-only: on".

## Rules while on

The goal: every piece of actual code is written by the user.  The
agent helps by naming things and explaining ideas.

### Allowed
- Identifiers in backticks: function, method, class, module, package,
  option, keyword names, etc., e.g. "use `_.fromPairs` and `_.map`",
  "`str.title`", "the `--recursive` option of `grep`".
- Operators in backticks, named on their own, e.g. "use the `+`
  operator", "the `??` operator".
- Simple literals: numbers, strings, `true`/`false`/`null`/`None`,
  the empty tuple, empty array, empty object/dict.
- Naming syntax constructs without writing them: "use an arrow
  function", "a list comprehension", "destructuring", "a CTE".
- Prose explanations of an approach, algorithm, data flow, or why
  something fails.
- Quoting the user's own existing code verbatim to point at a
  location ("the line with `return result`"), never a modified
  version of it.
- Pointing to documentation, with URLs whenever available (official
  docs preferred, linked to the specific page or anchor).

### Forbidden
- Code blocks (fenced with ``` or indented), of any language and any
  length.
- Function or method calls, with or without arguments:
  `_.map(arr, f)`, `s.title()`.
- Expressions combining tokens: `a + b`, `x ?? 0`, `s => [s, true]`.
- Statements, declarations, snippets, pseudocode, diffs, patches,
  etc.
- Non-empty collection literals: arrays, objects, dicts, tuples,
  sets, etc.
- Full shell command lines, SQL queries, regexes, config file
  fragments, Emacs Lisp forms, etc. -- all of these count as code.
- Ready-to-paste text for the user to use as-is: skills, prompts,
  system prompts, agent instructions, templates, etc. -- these count
  as code too.
- Describing an API's signature or argument order: the user looks
  that up.  Point to the documentation instead.
- Prose that is a token-by-token dictation of code ("call map on arr
  with a function that returns an array of s and true").  Describe
  intent, not a transcription.

### Tools
- Never create, edit or delete files: no Write, Edit or NotebookEdit,
  and no Bash commands that write files (redirections, `sed
  --in-place`, `tee`, `git apply`, etc.).
- Do not spawn subagents to write code.
- Reading files, searching, and running read-only commands to
  understand the user's code is fine.
- Do not copy commands to the clipboard while the mode is on.

### Self-check
Before sending each answer, scan every backticked span.  Each must be
a single identifier, a single operator, or a simple literal.  There
must be no code blocks at all.  Rewrite anything else as prose naming
the pieces.  Check that the last line says "code-hint-only: on".

As you can see, this skill is still somewhat specific to Claude Code (the disable-model-invocation and argument-hint frontmatter keywords are not part of the Agent Skills spec, and as far as I know, neither is the $ARGUMENTS placeholder). In fact, I plan to start using other LLM “harnesses” besides Claude Code, so I will also make my skills more tool-agnostic.

The nice thing about skills is that you don’t have to write them yourself – you can describe what the skill should do and the agent can generate it for you. I have a suspicion that it might be better to write them yourself, though, since the generated ones tend to be very verbose. At least with Claude Code, my experience is that it has a tendency (sometimes annoying and sometimes useful) to support all possible edge cases. For example, sometimes I just need a simple one-off script or even, say, ImageMagick invocation and I really don’t care about supporting spaces in filenames (something I almost never use). One day I will perform an experiment and compare an LLM-generated skill with an “equivalent” one written by myself. Interestingly, Anthropic’s skill-creator skill has some support for evaluating skills; it would be pretty simple to adapt it to comparing two skills supposed to perform the same task. (Another, perhaps better way could be to write a set of scripts which would run the claude command-line tool in controlled conditions and then evaluate the results deterministically, for example using regexen or a Markdown parser.) Two problems with that (or in fact any) approach to skill testing/evaluation is that it’s not really a proper scientific experiment – Anthropic can change the model’s parameters at any time, so you don’t really control it. (You can do that with a local model, though.)

Anyway, that’s it for today, see you next week!

CategoryEnglish, CategoryBlog, CategoryLLM

Comments on this page

2026-11-23 Improving support for named frames in Emacs

At my day job, I use multiple Emacs frames a lot. I often work on two or sometimes even more projects in parallel, and the way I don’t get lost is that I keep every project in a separate frame. Moving between them with other-frame (C-x 5 o, which I also bound to M-<f6>) is sometimes slightly clunky – especially that from time to time I’d like to be able to see the list of all my frames and possibly select one of them. (Before you tell me that my window manager could do that, let me explain that I use terminal Emacs inside a virtual machine, so I only see one frame at a time.)

A bit surprisingly, Emacs does not seem to have similar support for frames as it has for buffers. Everybody knows about switch-to-buffer, bu did you know about select-frame-by-name? It is like its poor cousin – for example, it cannot be used to create new frames. Also, believe it or not, but frame names in Emacs are not unique!

Let’s fix the latter problem first. My first thought was to advise set-frame-name, but I think rewriting it is a better solution – it is a short function, and you can only put an advice before or after the function, not in the middle of it. (Technically, there is the :override advice combinator, but using it would mean rewriting the function anyway.)

(defun mbork-set-unique-frame-name (name)
  "Set the name of the selected frame to NAME.
Do not allow to use a name of an existing frame.  This function is based
on `set-frame-name'."
  (interactive
   (list (completing-read "Frame name: " (make-frame-names-alist))))
  (when (string-empty-p name)
    (user-error "Frame name must not be empty"))
  (when (assoc name (make-frame-names-alist))
    (user-error "Frame called %s already exists" name))
  (modify-frame-parameters (selected-frame)
                           (list (cons 'name name))))

This function is probably far from ideal. If the user decides to invoke set-frame-name and deliberately set a frame’s name to the same as some other frame’s name, there’s no stopping them. Still, it’s good enough for me.

Let’s now write a function to switch to a frame with the given name, and if the user provides a string which is not a name of an existing frame, to create a new one with that name. Of course, I started with select-frame-by-name and modified it.

(defun mbork-select-or-create-frame-by-name (name)
  "Select or create the frame whose name is NAME and raise it.
This function is based on `select-frame-by-name'."
  (interactive
   (let* ((frame-names-alist (make-frame-names-alist))
          (input (completing-read
                  "Select Frame: "
                  frame-names-alist nil nil nil 'frame-name-history)))
     (when (string-empty-p input)
       (user-error "Frame name must not be empty"))
     (list input)))
  (select-frame-set-input-focus
   (or (cdr (assoc name (make-frame-names-alist)))
       (make-frame (list (cons 'name name))))))

And that’s it for today, see you next week!

CategoryEnglish, CategoryBlog, CategoryEmacs

Comments on this page

2026-11-16 Copying the current location improved again

Last year I improved my code for copying the current location to the kill ring. Recently it occurred to me that this was not the last word. In fact, I’m pretty surprised I didn’t think of it earlier – it’s sort of obvious in hindsight. The idea is that it should copy the range of lines when the region is active.

A naive way is to use the line number of region-beginning and region-end if the region is active. This is not as simple as it looks, though. The problem is that if region-end is at the beginning of line, it’s actually better not to count that last line. For example, if the buffer looks like this (both point and mark are denoted by an asterisk):

Lorem ipsum
*dolor sit amet,
consectetur
*adipiscing elit

the range should be 2–3, not 2–4, since only lines 2 and 3 are actually highlighted. This is how count-words-region works. Looking at count-lines (which is called by count-words-region) reveals this snippet:

(if (bolp)
    (1- (line-number-at-pos))
  (line-number-at-pos))

so I’d like to do the same in my function.

While at that, I thought that I could fix a few bugs I introduced in my command. The problem was that it assumed that it was ran in either a file buffer or a Dired buffer, and within a project (for example, a Git repo). I often accidentally run it in e.g. Magit buffers showing an old version of a file or even temporary buffers with no backing files. (I thought that including the commit hash in the former case would be useful.) Also, it didn’t work outside a version control repo or (in general) a project.

(defun mbork-copy-current-location (no-line-number)
  "Show the current location and put it into the kill ring.
Here, \"location\" means the filename and line number (after a colon) or
a line number range (if the region is active).  Use the filename
relative to the parent of the current project root directory, so it
starts with the main project dir.  With \\[universal-argument], the line
number is omitted."
  (interactive "P")
  (let* ((current-project (project-current))
         (project-files (if current-project
                            (project-files current-project)
                          '()))
         (file-name (if current-project
                        (file-relative-name
                         (or buffer-file-name
                             dired-directory
                             (when (bound-and-true-p magit-buffer-file-name)
                               (concat magit-buffer-file-name ":" magit-buffer-revision))
                             (buffer-name))
                         (file-name-concat (project-root current-project)
                                           ".."))
                      (abbreviate-file-name (or buffer-file-name (buffer-name)))))
         (file-base-name (file-name-nondirectory file-name))
         (count (length (cl-remove-if-not
                         (lambda (filename)
                           (string= file-base-name
                                    (file-name-nondirectory filename)))
                         project-files)))
         (location (if (use-region-p)
                       (format "%s-%s"
                               (line-number-at-pos (region-beginning) t)
                               (save-excursion
                                 (goto-char (region-end))
                                 (if (bolp)
                                     (1- (line-number-at-pos nil t))
                                   (line-number-at-pos nil t))))
                     (line-number-at-pos nil t)))
         (location-full
          (format (if (or no-line-number (eq major-mode 'dired-mode)) "%s" "%s:%s")
                  (if (= count 1)
                      file-base-name
                    file-name)
                  location)))
    (kill-new location-full)
    (message location-full)))

Now I have to admit that I did use an LLM here. Disclaimer: it didn’t write any code, but I asked it to review what I have written. (If you are in the LLM-skeptical camp, don’t worry; all code on my blog is hand-written unless explicitly stated, by the way.) I have to admit that its review was much more thorough than what I would do. For example, it never occurred to me that it won’t work correctly in a “synthetic” Dired buffer (where instead of listing the contents of a directory you give the dired function a list of file names), or that if I named a non-file buffer with a slash at the beginning, it would treat that as a (possibly non-existent) path and do weird things (try it for yourself!), or that if a region is active but contained within one line, I’d get something like file:1337-1337. But those are extreme edge cases I don’t really care about that much – it’s not really worth fixing them in a function which is an interactive, convenience command. Even if I get an error or an absurd value once in a while, it just doesn’t matter.

So, what’s the lesson here? I guess there are a few. First of all, when you write interactive commands, it’s good to think about basic cases, like what it is going to do when invoked with a prefix argument or what it is going to do when the region is active. The second thing is that you probably don’t care about corner cases until you really run into them – Emacs is a huge, complicated machine, and your command might error out when evaluated in a state you never knew even existed.

Anyway, that’s it for today – happy hacking as usual!

CategoryEnglish, CategoryBlog, CategoryEmacs

Comments on this page

More...

CategoryBlog