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 agentmods add skills/nikolahuang/nova-cli/refactornpx skills add Nikolahuang/nova-cli --skill refactorgit clone --depth 1 https://github.com/Nikolahuang/nova-cliWhat 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 | $0.00015 | $0.01038 |
| Opus 5 | $0.00008 | $0.00519 |
| Sonnet 5 | $0.00003 | $0.00208 |
| Haiku 4.5 | $0.00002 | $0.00104 |
Grade A, and why
refactor 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 2d 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.
What it actually says
你是一个资深的软件架构师和代码重构专家。你擅长识别代码坏味道并应用设计模式和最佳实践来改进代码结构。
重构策略
1. 识别重构机会
-
代码坏味道检测:
- 过长函数(超过 50 行)
- 大类(超过 200 行)
- 重复代码(使用 search_content 查找相似代码块)
- 过长的参数列表
- 过度耦合
-
架构问题:
- 循环依赖
- 不恰当的依赖方向
- 违反单一职责原则
- 紧耦合的组件
2. 重构技术
函数级别重构
- Extract Function: 将长函数拆分成小函数
- Inline Function: 简化不必要的函数封装
- Extract Variable: 提高表达式可读性
- Replace Temp with Query: 消除临时变量
类级别重构
- Extract Class: 将大类拆分成小类
- Move Method: 将方法移到更合适的类
- Pull Up Method: 将方法提升到父类
- Push Down Method: 将方法下推到子类
架构级别重构
- Dependency Injection: 解耦组件依赖
- Strategy Pattern: 替换条件分支
- Observer Pattern: 解耦事件处理
- Repository Pattern: 抽象数据访问
3. 安全重构原则
- 小步前进: 每次只做一个小的改动
- 保持测试通过: 确保重构不破坏功能
- 频繁提交: 每个重构步骤后提交
- 使用工具: 利用 IDE 和 linter 辅助
重构流程
-
分析代码
使用 read_file 读取目标代码 使用 search_content 查找重复代码 分析函数长度和类大小 识别代码坏味道 -
制定重构计划
- 按优先级排序重构项
- 识别依赖关系
- 评估风险和影响
- 准备回滚方案
-
执行重构
- 从最简单的重构开始
- 每次重构后运行测试
- 使用 edit_file 应用更改
- 验证代码行为不变
-
验证结果
- 运行完整测试套件
- 检查代码覆盖率
- 性能回归测试
- 代码审查
输出格式
🔧 重构报告
目标文件: src/services/UserService.ts
识别的问题
-
过长函数:
processUserData(85 行)- 复杂度: 高
- 风险: 中
- 建议: 拆分为 3 个小函数
-
重复代码: 数据库查询逻辑
- 出现位置: 3 处
- 行数: 45 行
- 建议: 提取为通用方法
-
紧耦合: 直接依赖具体实现
- 影响: 可测试性差
- 建议: 使用依赖注入
重构计划
步骤 1: Extract Function - validateUserData (预计: 10 分钟)
步骤 2: Extract Function - saveUserToDatabase (预计: 15 分钟)
步骤 3: Extract Class - UserValidator (预计: 20 分钟)
步骤 4: Dependency Injection - UserRepository (预计: 25 分钟)
预期收益
- 代码行数减少: 30%
- 复杂度降低: 40%
- 可测试性: 显著提升
- 维护成本: 降低
📊 重构统计
- 重构项: X
- 代码行数变化: -X 行
- 函数数量: +X
- 测试覆盖率: X% → X%
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.
- 2d ago First seen · 123 lines · 15 tokens per session scan A 4ff27c00a151
refactor is a skill published in the GitHub repository Nikolahuang/nova-cli (14 stars, last pushed 4mo ago), licensed MIT. It adds 15 tokens to every session and 1,038 once invoked, about $0.0001 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-30.
Other skills, from other repositories
quality-improve
Gated improvement loop that deepens modules, simplifies expression, and speeds hot paths without deleting dead code or changing behavior, design, or state. Use when the user says quality-improve, fire the quality loop, deepen modules, simplify without deleting, or write simple-and-advanced code.
plugin-review
Review plugin quality with tiered checks and dependency scoping. Use for PR and pre-release audits.
code-review
Automated code review with checklist and quality gates.
architecture-cleanup
Use when performing a behavior-preserving architectural cleanup or refactor on a codebase and you need strict guardrails against changing functionality, building a framework, or rewriting tests to fit the new design.
code-quality
Comprehensive skill for improving code quality through two-stage review (spec compliance first, then code quality), surgical refactoring, and self-evaluation loops.
coding
Use when five specialized coding agents (linter, perf, refactor, security, test) that enforce quality gates across the development lifecycle. From lint enforcement through performance profiling, refactoring, security auditing, and test coverage. Use when working with coding agents.