paperfit-undo

paperfit-undo is a command for Claude Code from OpenRaiser/PaperFit. It costs 0 tokens per session (557 once invoked), scanned A, original, MIT.

A command for restoring the most recent backup made before PaperFit automatically edited a paper's source files.

In plain words
What is it for?
Rolling back the main LaTeX file, optionally restoring PaperFit's state file, refreshing the paper scan, and checking the resulting status.
Why use it?
It provides a controlled way to undo the latest automatic write without asking the user to find backup files manually. It can also restore the saved task state when a matching backup exists.

Command for Claude Code

Part of the paperfit plugin — 8 skills, 9 commands, 6 agents shipped together

Install

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.

agentmods
npx agentmods add commands/openraiser/paperfit/paperfit-undo
Clone the repo
git clone --depth 1 https://github.com/OpenRaiser/PaperFit

Made for: Claude Code.

Or install paperfit, the plugin that ships this one along with the rest of its 8 skills, 9 commands, 6 agents.

Wrote 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.

agentmods badge for paperfit-undo

README.md
[![agentmods](https://agentmods.dev/badge/commands/openraiser/paperfit/paperfit-undo.svg)](https://agentmods.dev/commands/openraiser/paperfit/paperfit-undo)
Your own site
<a href="https://agentmods.dev/commands/openraiser/paperfit/paperfit-undo"><img src="https://agentmods.dev/badge/commands/openraiser/paperfit/paperfit-undo.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 557 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.00557
Opus 5 $0.00000 $0.00279
Sonnet 5 $0.00000 $0.00111
Haiku 4.5 $0.00000 $0.00056

Measured 6d ago against content hash 87d971c3fd43, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

paperfit-undo 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 6d 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.

.claude/commands/paperfit-undo.md · 66 lines

What it actually says

/paperfit-undo — 回滚最近一次源码写入

作用: 恢复最近一次 PaperFit 自动写回前的备份版本,优先回滚主 .tex,必要时一并恢复 data/state.json

用户入口说明:

  • 这是回滚入口,用户只需要表达“撤销上次自动修改”之类的意图。
  • 不要要求用户手动定位备份文件再执行恢复命令。
  • 回滚后的输出应解释恢复了什么、当前状态如何,而不是只给文件路径。

防呆约束:

  • 不要使用 git reset --hardgit checkout -- 之类的破坏性命令
  • 不要调用内部任务管理工具来“创建回滚任务”
  • data/backups/ 中没有匹配备份,应明确说明无法自动回滚,而不是猜测性覆盖文件

工具调用约定

在论文项目根目录内:

  • 主源码备份通常位于 data/backups/<main_tex文件名>.*.bak
  • 状态备份通常位于 data/backups/state_*.json
  • 回滚后可执行 paperfit run scripts/paperfit_portrait.py refresh --main <main_tex> 让画像重新对齐

用法

/paperfit-undo

也可以由自然语言触发,例如:

撤销 PaperFit 上一次自动修改
回滚到上一个安全版本

执行流程

  1. 读取 data/state.json,确定 main_tex
  2. 检查 data/backups/ 中最新的 main_tex 备份文件,以及最近一个 state_*.json
  3. 先向用户说明将恢复哪两个文件:
    • main_tex <- latest .bak
    • data/state.json <- latest state backup(若存在)
  4. 执行文件恢复。
  5. 若画像文件存在,执行:
paperfit run scripts/paperfit_portrait.py refresh --main <main_tex>
  1. 提示用户继续用:
    • /show-status
    • /check-visual
    • /fix-layout

输出结果

  • 恢复的备份文件路径
  • 当前主文件路径
  • 是否同时恢复了 data/state.json
  • 是否已刷新画像

调度

  • 不调用 Agent
  • 直接基于 data/backups/data/state.json 执行恢复
Changes

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.

  1. 6d ago First seen · 66 lines · 0 tokens per session scan A 87d971c3fd43

Subscribe to this mod's changes

paperfit-undo is a command published in the GitHub repository OpenRaiser/PaperFit (331 stars, last pushed 2mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 557 tokens. 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-30.