Skip to content
Skills Library
Programming · Building & coding

write-compact-code

/write-compact-code

Write a new Python or JavaScript file as compact Emmet-like notation that a bundled script expands into real source, so the repetitive structure never has to be emitted token by token. Use this when creating a file with repetitive shape — many similar methods, a batch of route handlers, parallel dataclasses or wrappers — or when the user asks to reduce token usage while writing code. Load the matching language reference before writing any notation; do not guess at node names.

Licence
MIT
Last repository change
12.08.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
4
Scripts
1
HTML comments
0
URLs in SKILL.md
3
Deprecation

No signals detected. Repository changed on 12.08.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What to check before installing
  • 1 scripts in this package. Review them before installing, as Claude may execute them.

Scripts: scripts/expand.py

What it does and when to use it

Write a new Python or JavaScript file as compact Emmet-like notation that a bundled script expands into real source, so the repetitive structure never has to be emitted token by token. Use this when creating a file with repetitive shape — many similar methods, a batch of route handlers, parallel dataclasses or wrappers — or when the user asks to reduce token usage while writing code. Load the matching language reference before writing any notation; do not guess at node names.

Original author description

Write a new Python or JavaScript file as compact Emmet-like notation that a bundled script expands into real source, so the repetitive structure never has to be emitted token by token. Use this when creating a file with repetitive shape — many similar methods, a batch of route handlers, parallel dataclasses or wrappers — or when the user asks to reduce token usage while writing code. Load the matching language reference before writing any notation; do not guess at node names.

How it works

  1. Workflow
  2. When this is worth it, and when it is not
  3. What the expander guarantees
  4. The one rule that causes wrong output rather than an error
  5. Comparison with the hook-based version
Original SKILL.md headings · 114 lines, 663 words
SKILL.md preview
---
name: write-compact-code
description: Write a new Python or JavaScript file as compact Emmet-like notation that a bundled script expands into real source, so the repetitive structure never has to be emitted token by token. Use this when creating a file with repetitive shape — many similar methods, a batch of route handlers, parallel dataclasses or wrappers — or when the user asks to reduce token usage while writing code. Load the matching language reference before writing any notation; do not guess at node names.
license: MIT
allowed-tools: Bash(python3 ${CLAUDE_SKILL_DIR}/scripts/expand.py *)
metadata:
  author: Emerick Chasse
  homepage: https://claudeusagelimits.com
---

# Write compact code

An output token costs about five times an input token. Structure — nesting,
repetition, block headers — is the part of a file that is expensive to emit and
cheap to describe. This notation describes it; `expand.py` writes it out.

```
fn[greet](name)>ret{f"hello {name}"}
```

```python
def greet(name):
    return f"hello {name}"
```

## Workflow

**1. Read the reference for the language first.** The grammar is small and the
expander refuses names it does not know, so guessing costs a turn:

- Python `.py`, `.pyi` → [reference/python.md](reference/python.md)
- JavaScript and TypeScript `.js`, `.mjs`, `.ts`, `.tsx`, `.jsx` → [reference/javascript.md](reference/javascript.md)

There is no reference for any other language, and that is not an oversight —
those are the two the expander implements. For anything else, write ordinary
source.

**2. Make one Bash call, with the notation on stdin via a quoted heredoc:**

```bash
python3 ${CLAUDE_SKILL_DIR}/scripts/expand.py --out src/router.py <<'NOTATION'
cls[Router]>(fn[route_$](self, request)>ret{self._dispatch($, request)})*4
NOTATION
```

The quoted delimiter (`<<'NOTATION'`, not `<<NOTATION`) is what stops the shell
expanding `$` before the expander ever sees it — and `$` is the repetition
index, so unquoted the whole feature silently produces empty names.

**Never pass notation as a command-line argument.** It contains `>`, `+`, `(`,
`{`, `$` and `*`, every one of which the shell claims first. A heredoc has no
quoting problem to get wrong.

**3. Check before writing when unsure.** `--check` prints the expansion and
writes nothing:

```bash
python3 ${CLAUDE_SKILL_DIR}/scripts/expand.py --lang python --check <<'NOTATION'
cls[A]>fn[b](self)>ret{1}
NOTATION
```

**4. Read the file afterwards.** The receipt says so, and it matters: you wrote
notation, the expander wrote source. An `Edit` needs `old_string` to match what
is on disk, and what is on disk is the expansion.

## When this is worth it, and when it is not

Worth it when the file has **repetitive structure** — a class of similar
methods, a batch of handlers, parallel wrappers. `*N` with `$` is where the
saving actually lives, and it grows with N.

Not worth it for a single short function, an edit to an existing file, or a file
whose difficulty is in its expressions rather than its shape. Notation costs you
attention and costs the user a turn if it fails; ordinary source is often
cheaper overall. Say so rather than reaching for it reflexively — recommending a
token optimisation that loses money is worse than not having one.

## What the expander guarantees

- **Python is compiled before it is written.** A `SyntaxError` means nothing is
  written and you see the error and the expansion. JavaScript gets no such
  check — `compile()` exists for Python in the standard library and there is no
  dependency-free equivalent, so run the project's linter afterwards.
- **The file is encoded in full before the first byte is written**, so a failure
  cannot leave a truncated file behind.
- **stdin is decoded as UTF-8 explicitly**, not with the locale — otherwise an
  accented identifier arrives as mojibake on a cp1252 Windows console, silently.
- **An unknown node name is refused by name**, pointing at the reference.

## The one rule that causes wrong output rather than an error

`>` descends and **stays down** until a group closes. So:

```
cls[Config]>fn[__init__](self)>set[self.x]{1}+fn[load](self)>ret{2}
```

puts `load` **inside** `__init__`, as a closure. Python accepts a nested
function, so this compiles, nothing raises, and you get a class with one method
instead of two.

Group every sibling that has children of its own:

```
cls[Config]>(fn[__init__](self)>set[self.x]{1})+(fn[load](self)>ret{2})
```

This is the mistake to check for when the output looks structurally odd.

## Comparison with the hook-based version

This skill decodes through an explicit `Bash` call you choose to make. The paid
[CULP plugin](https://claudeusagelimits.com) does the same job in a `PreToolUse`
hook on `Write` and `Edit`, across 28 languages, so the decode happens
automatically and compact syntax never reaches disk even briefly. Both are worth
knowing about; this one is free, open, and yours to fork.

---

Part of the [Usage Limits Optimizer](https://claudeusagelimits.com/claude-usage-limits-skill/),
a free and open plugin. MIT licensed.
Files in this package (4)
  • SKILL.md 5 KB
  • reference/javascript.md 5 KB
  • reference/python.md 5 KB
  • scripts/expand.py 18 KB

Versions

The database has no other skills named write-compact-code.

Database snapshot: 13.11.2026 · package version d5e39a58556b (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 95n8n-code-javascript
    Write JavaScript code in n8n Code nodes. Use when writing JavaScript in n8n, using $input/$json/$node syntax, making HTTP requests with $helpers, working with dates using DateTime, troubleshooting Code node errors, or choosing between Code node modes.
  • 90neo-python
    Use this skill when writing, reviewing, debugging, or architecting Python 3.10+ code, including type hints, structural pattern matching, dataclasses, async/task groups, packaging-aware project structure, testability, and maintainability.
  • 100rc-python
    Idiomatic typed Python 3.12+ — asyncio, dataclasses, pytest, ruff, uv. Use when writing or reviewing Python. Do not use for JS/TS or Go.
  • 90n8n-code-javascript
    Write JavaScript code in n8n Code nodes. Use when writing JavaScript in n8n, using $input/$json/$node syntax, making HTTP requests with $helpers, working with dates using DateTime, troubleshooting Code node errors, or choosing between Code node modes.
  • 95n8n-code-javascript
    Write JavaScript code in n8n Code nodes. Use when writing JavaScript in n8n, using $input/$json/$node syntax, making HTTP requests with $helpers, working with dates using DateTime, troubleshooting Code node errors, or choosing between Code node modes.
  • 95n8n-code-javascript
    Write JavaScript code in n8n Code nodes. Use when writing JavaScript in n8n, using $input/$json/$node syntax, making HTTP requests with $helpers, working with dates using DateTime, troubleshooting Code node errors, or choosing between Code node modes.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.