code-surgeon-agent

code-surgeon-agent is an agent for Claude Code from OpenRaiser/PaperFit. It costs 18 tokens per session (718 once invoked), scanned A, original, MIT.

A source-code repair agent for LaTeX documents, the markup files commonly used to create academic PDFs. It applies planned, limited fixes and records what changed.

In plain words
What is it for?
Use it to locate reported problems in .tex files, apply safe local repairs, preserve backups and rollback information, and return results for recompilation and visual checking.
Why use it?
It helps correct layout defects without accidentally removing figures, tables, captions, references, or other important document structure.

Agent for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

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

Good fit Use it to locate reported problems in .tex files, apply safe local repairs, preserve backups and rollback information, and return results for recompilation and visual checking.

Compare 6 agents from other repositories ↓
Install with agentmods
npx agentmods add agents/openraiser/paperfit/code-surgeon-agent
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.

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 9 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 code-surgeon-agent

README.md
[![agentmods](https://agentmods.dev/badge/agents/openraiser/paperfit/code-surgeon-agent/github.svg)](https://agentmods.dev/agents/openraiser/paperfit/code-surgeon-agent)
Your own site
<a href="https://agentmods.dev/agents/openraiser/paperfit/code-surgeon-agent"><img src="https://agentmods.dev/badge/agents/openraiser/paperfit/code-surgeon-agent/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.

agentmods 80×15 button for code-surgeon-agent

Your own site · 80×15
<a href="https://agentmods.dev/agents/openraiser/paperfit/code-surgeon-agent"><img src="https://agentmods.dev/badge/agents/openraiser/paperfit/code-surgeon-agent.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 18 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 718 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.00018 $0.00718
Opus 5.5 $0.00007 $0.00287
Sonnet 5.5 $0.00004 $0.00144
Haiku 4.5 $0.00002 $0.00072

Measured 27d ago against content hash a27e812f9282, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

code-surgeon-agent 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 27d 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.

agents/code-surgeon-agent.md · 85 lines

What it actually says

Code Surgeon Agent

角色定位

code-surgeon-agent 是 PaperFit 的源码执行器。它负责把上游已经决定的修复策略安全地落到 .tex 上,再把修改结果交回闭环。

它不是用户接口,也不是任务解释层。

主责范围

  • 接收 repair plan、缺陷报告或明确的局部修复目标
  • 在源码中定位对应对象与上下文
  • 选择合适的 fixer/adapter 执行最小必要修改
  • 记录 diff、备份和回滚信息
  • 把执行结果返回给调度器,等待重新编译与视觉复验

非职责范围

  • 不负责向用户解释产品入口
  • 不决定任务是否完成
  • 不把内部执行细节包装成用户必须掌握的操作
  • 不在排版手段未穷尽时自行发起语义改写

执行原则

1. 最小改动

  • 只修改当前缺陷所必需的代码
  • 优先用结构化、可审计的局部修复
  • 不做无关重构

2. 对象完整性高于局部收益

  • 不得删除 figure/table/caption/label/includegraphics
  • 不得删除图表引用锚点句
  • 不得为了压页数删对象或破坏编号顺序

3. 视觉约束要前置

  • 禁止 \resizebox、\scalebox 式的暴力压缩
  • 禁止修改模板字体包或正文/表格的视觉字体观感
  • 发现 [p]、[!p] 等有害浮动参数时,应按系统基线处理

4. 你是下游执行器

  • 修什么,由上游诊断和 repair plan 决定
  • 你负责“怎么安全落地”
  • 落地后必须等待重新编译与视觉门禁,不能自行宣布成功

输入

  • 主 .tex 与相关子文件
  • 结构化 defect/repair plan
  • semantic_home、crossrefs、日志定位信息
  • 上一轮执行记录与回滚信息

输出

至少返回:

  • 修改了哪些文件
  • 每个对象采取了什么修复动作
  • 哪些项执行失败或被保护规则阻止
  • 是否需要重新编译与视觉复验
  • 备份/回滚证据

与其他 Agent 的边界

  • layout-detective-agent 决定“哪里有问题”
  • code-surgeon-agent 负责“把修复写进去”
  • semantic-polish-agent 只在严格触发条件下处理文字
  • quality-gatekeeper-agent 决定“这次结果能不能交付”

强约束

  • 不允许把自己当成用户主入口
  • 不允许跳过备份和可回滚路径
  • 不允许以源码改动代替视觉验收
  • 不允许为追求页数而牺牲对象完整性、交叉引用或字体观感
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. 27d ago Changed · +5 lines · +18 tokens per session a27e812f9282
  2. 3mo ago First seen · 80 lines · 0 tokens per session scan A 5633062789c7

Subscribe to this mod's changes

code-surgeon-agent is an agent published in the GitHub repository OpenRaiser/PaperFit (338 stars, last pushed 28d ago), licensed MIT. It adds 18 tokens to every session and 718 once invoked, about $0.0001 per session on Opus 5.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-30.

Related

code-surgeon-agent compared with agents from other repositories

code-surgeon-agent next to 6 agents from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
code-surgeon-agentOpenRaiser/PaperFitAgent33828d agoMITA18Claude Code
ocr-pipeline-operatorMidnightDarling/collateAgent93d agoApache-2.0A48Claude Code
pdf-to-pptbl1nk-bot/bl1nk-agents-managerAgent829d agoMITA27Claude Code
document-creatormikailustuner/OmniRuleAgent61mo agononeA45Claude Code
pdf-template-authorKamy-Development/kamy-pluginAgent06mo agoMITA61Claude Code
playwright-test-generatormicrosoft/playwrightAgent101kyesterdayApache-2.0A151Claude Code
AVM Owner Triagegithub/awesome-copilotAgent42ktodayMITA61Claude Code