Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx skills add nickolaslin33/agent-skills --skill format-preserving-editsgit clone --depth 1 https://github.com/nickolaslin33/agent-skillsWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/nickolaslin33/agent-skills/format-preserving-edits)<a href="https://agentmods.dev/skills/nickolaslin33/agent-skills/format-preserving-edits"><img src="https://agentmods.dev/badge/skills/nickolaslin33/agent-skills/format-preserving-edits/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/nickolaslin33/agent-skills/format-preserving-edits"><img src="https://agentmods.dev/badge/skills/nickolaslin33/agent-skills/format-preserving-edits.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00283 | $0.03176 |
| Opus 5 | $0.00142 | $0.01588 |
| Sonnet 5 | $0.00057 | $0.00635 |
| Haiku 4.5 | $0.00028 | $0.00318 |
Grade A, and why
format-preserving-edits scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 9d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 163 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Format-Preserving Edits
為什麼這件事重要
設定檔是人維護的,排版是維護者長年累積的閱讀習慣:哪些欄位對齊、區塊之間空幾行、 key 用什麼順序排,都是他們找東西的路標。
一旦你把檔案 json.load() 進來再 json.dump() 出去,等於用序列化器的品味覆寫了
維護者的品味。語意可能一模一樣,但 diff 從「我改了 1 行」變成「我改了 5000 行」,
review 的人只能盲簽。 而且 round-trip 經常無聲地改掉或刪掉內容:註解、鍵序、
非 ASCII 的寫法、1.0 vs 1、大整數精度、重複 key。
所以驗收標準有兩條,缺一不可:語意對 + diff 形狀對。
鐵則
Parser 只准用來「讀」和「驗證」,不准用來「寫」。
看到自己要打這些,就停下來換做法:
| 別用 | 為什麼 |
|---|---|
json.dump / json.dumps 寫回既有檔 |
重排全檔、ensure_ascii 改掉中文的寫法、數字的表示法可能變(1.0 寫成 1、1e3 寫成 1000.0) |
yaml.dump / yaml.safe_dump |
吃掉全部註解、改引號、重排 key、把 on/yes 之類的值改型別 |
ConfigParser.write() |
吃掉註解、小寫化 key、統一 = 兩側空白 |
ET.tostring / minidom.toprettyxml |
重排縮排、改自閉合標籤寫法、動屬性順序 |
prettier / black / gofmt 掃過整個檔 |
除非這個 repo 本來就有這個 formatter 在 CI 跑 |
| 「順手把這裡對齊一下」 | 對齊的改動會跟你真正的修改混在同一份 diff 裡,review 的人分不出哪幾行才是重點 |
例外:repo 本身就有 formatter(.prettierrc、pre-commit hook、CI 檢查),那就跟著它跑——
這時候「正規化」才是這個 repo 的慣例。動手前先確認:ls .prettierrc* .editorconfig .pre-commit-config.yaml 或看 CI 設定。
流程
(以下 $SKILL_DIR 指本 skill 的安裝目錄,依你的環境代入實際路徑。)
1. 先量格式,不要用猜的
python3 "$SKILL_DIR"/scripts/sniff_format.py <檔案> [更多檔案...]
它會報告:BOM/換行字元/檔尾有沒有換行/縮排字元與階距(含離群值另外列)/
空行分段習慣/冒號與逗號後的空白/非 ASCII 是直接寫還是 \uXXXX/單行容器數量/
最外層 key 是不是排序過。
離群值怎麼處理:檔案是人維護的,一定有例外——多數縮排 4 格,某個區塊 2 格。
- 跟多數走,不要學離群值。
- 但如果你要改的內容就在離群區塊裡面,跟那個區塊的局部慣例走: 局部一致比全域一致重要,讀的人是連著上下文一起看的。
- 不要順手修正離群值。 那是另一個 commit 的事,混進來只會讓你的 diff 沒人看得懂。
2. 找一筆同類的既有條目當骨架
這是整套做法裡最有效的一招,勝過任何風格推論:要加一個商品,就去找一個已經在 檔案裡的商品;要加一個關卡,就複製一個既有的關卡。骨架、縮排、欄位順序、引號、 對齊全部自動正確,你只要改值。
S="$SKILL_DIR"/scripts
python3 $S/json_surgery.py keys f.json # 這層有哪些 key
python3 $S/json_surgery.py show f.json --key ItemAlpha # 原文長什麼樣
python3 $S/json_surgery.py clone f.json --key ItemAlpha --to ItemBeta -i
clone 會原封不動複製那個區塊、只換 key 名,並照檔案原有的空行分段插在後面。
複製完再逐欄改值(用 Edit 工具就好)。
3. 動刀:改動量決定用什麼工具
| 情境 | 工具 |
|---|---|
| 改幾個值、加一小段 | Edit 工具,直接貼上符合原格式的文字 |
| 需要括號配對才找得到範圍、或同一個 key 在多處出現 | json_surgery.py(--scope 限定路徑) |
| 同樣的改動要套到 N 個檔 | 寫一支一次性 script 呼叫 json_surgery 的函式,或迴圈跑 CLI |
| YAML / TOML / INI / XML | 見 references/formats.md(多半仍是 Edit 工具或行級 script) |
What ships with it
4 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 9d ago First seen · 163 lines · 283 tokens per session scan A 93e348a6f798
format-preserving-edits is a skill published in the GitHub repository nickolaslin33/agent-skills (2 stars, last pushed 21d ago), licensed MIT. It adds 283 tokens to every session and 3,176 once invoked, about $0.0014 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other skills, from other repositories
systematic-debugging
Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes.
local-ai-agents
Build local-first AI agents that run entirely on a developer workstation with Microsoft Foundry Local and Qwen function-calling models. Covers Small Language Models (SLMs), the OpenAI-compatible local endpoint, sandboxed local tools, local RAG with Chroma, local MCP servers, hybrid cloud/local routing, and the…
next-cache-components-adoption
Turn on Cache Components in a Next.js app and resolve the blocking routes it surfaces. Use when the user wants to enable, adopt, or migrate to Cache Components, flip the cacheComponents flag, work through a flood of blocking-prerender / instant validation errors, run the cache-components-instant-false codemod, or…
insight-error-page
Write or audit an insight-kind error page for the Next.js dev overlay. Use when creating a new errors/ .mdx page, auditing an existing one, or checking that a page matches the framework fix cards. Covers page structure, title alignment, FixCard cards with Copy prompt button, code snippets, terminology verification…
next-cache-components-optimizer
Drive a Next.js route to instant navigation by setting up an agentic loop, under Cache Components / PPR, on initial load (hard navigation) and client-side navigation (soft navigation). Encode the goal as a failing @next/playwright instant() e2e and work it to green, one verified route at a time; the shipped test then…
next-partial-prefetching-adoption
Turn on Partial Prefetching in a Next.js app and work through the insights it surfaces. Use when the user wants to enable or adopt Partial Prefetching, flip the partialPrefetching flag, opt routes in with export const prefetch = 'partial', audit Link prefetch={true} behavior, preserve existing prefetched UI with…