Token导航 LogoToken导航

Agent Skill · 前端设计

code-refiner(代码精炼器)

code-refiner 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

code-refiner 是前端设计类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为需要联网;许可证信息还不明确,第三方扫描已通过,按安装量在前端设计类的 10,216 个 Skill 里排第 6,045。

总安装 563周安装 23GitHub Stars 217下载 180核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:code-refiner(代码精炼器)
来源仓库:https://github.com/mathews-tom/praxis-skills
仓库路径:skills/code-refiner
安装命令:
npx skills add https://github.com/mathews-tom/praxis-skills --skill code-refiner
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/mathews-tom/praxis-skills --skill code-refiner

这个 Skill 是做什么的

前端设计类 Skill 关注页面结构、视觉规范和组件写法,输出通常是可运行的界面代码。

code-refiner 是多轮次结构化精炼工具,将复杂冗长代码转化为简洁惯用且易维护的实现方式。适用于 verbose 逻辑、深层嵌套或 tangled 控制流的场景,强调行为等价与认知负荷降低。每轮精炼必须通过三测试:输出一致、理解加速与维护增益,确保变更安全可信。

使用前应确认有权限修改与测试运行能力,并建议在特性分支操作以避免干扰主干稳定性。适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

来源仓库内路径:skills/code-refiner

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/mathews-tom/praxis-skills --skill code-refiner;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要需要联网,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

code-refiner 怎么安装?

在终端执行 npx skills add https://github.com/mathews-tom/praxis-skills --skill code-refiner。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

code-refiner 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

code-refiner 需要什么权限?

权限级别是需要联网。该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

code-refiner 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

code-refiner 用的人多吗?

公开数据是累计安装 563 次,近一周安装 23 次,下载 180 次,GitHub 217 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

code-refiner 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理前端设计类任务、又不想每次都手写提示词的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

前端设计类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
frontend-design

前端设计 · Codex、Claude

8,823,360126,072只读MIT通过
vercel-composition-patterns

Vercel 组合模式 · Codex、Claude

3,858,81625,893需要联网MIT通过
vercel-react-native-skills

Vercel React native skills 前端 · Codex、Claude

2,468,66425,878只读MIT通过
adapt

adapt 搜索 · Codex、Claude

2,027,04023,125操作浏览器未明确通过
bolder

bolder 分析 · Codex、Claude

2,004,28823,130只读未明确通过
code-refiner

代码精炼器 · 本页

563217需要联网未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Code Refiner

A structured, multi-pass code refinement skill that transforms complex, verbose, or tangled code into clean, idiomatic, maintainable implementations — without changing what the code does.

Philosophy

The goal is not fewer lines. The goal is code that a tired engineer at 2am can read, understand, and safely modify. Every change must pass three tests:

  1. Behavioral equivalence — identical inputs produce identical outputs, side effects, and errors
  2. Cognitive load reduction — a reader unfamiliar with the code understands it faster after the change
  3. Maintenance leverage — the change makes future modifications easier, not harder

When clarity and brevity conflict, clarity wins. When idiom and explicitness conflict, consider the team's experience level. When DRY and locality conflict, prefer locality for code read more than modified.

Prerequisites

  • git — used in Phase 1 for scope detection (git diff) when the user doesn't specify target files
  • Python 3.10+ — required to run scripts/complexity_report.py for quantitative complexity metrics

Workflow

Follow this sequence. Each phase builds on the previous one. Do not skip phases, but adapt depth to the scope of the request (a single function gets a lighter pass than a full module).

Phase 1: Reconnaissance

Before touching anything, build a mental model:

  1. Identify scope — What files/functions are in play? If the user hasn't specified, check recent git modifications: git diff --name-only HEAD~5 or git diff --staged --name-only
  2. Detect language and ecosystem — Read file extensions, imports, config files (package.json, pyproject.toml, go.mod, Cargo.toml). Load the appropriate language reference from references/ if needed for idiom-specific guidance
  3. Read project conventions — Check for CLAUDE.md,.editorconfig, linter configs (eslint, ruff, golangci-lint, clippy). These override generic idiom preferences
  4. Understand test coverage — Locate test files. If tests exist, note the test runner so you can verify behavioral equivalence after changes
  5. Baseline complexity snapshot — For each target function/method, mentally note:

- Nesting depth (max indentation levels) - Number of branches (if/else/match/switch arms) - Number of early returns vs single-exit - Parameter count - Lines of code - Number of responsibilities (does it do more than one thing?)

Phase 2: Structural Analysis

Identify what's actually wrong before reaching for solutions. Categorize issues by severity:

Critical (always fix):

  • Dead code (unreachable branches, unused variables/imports)
  • Redundant operations (double-checking the same condition, re-computing cached values)
  • Logic that can be replaced by a stdlib/language built-in
  • Mutation of shared state that could be avoided

High (fix unless there's a clear reason not to):

  • Functions with >3 levels of nesting
  • Functions with >5 parameters
  • God functions (>40 lines or >3 responsibilities)
  • Repeated code blocks (3+ occurrences of similar logic)
  • Inverted or confusing boolean logic
  • Stringly-typed enumerations

Medium (fix when it improves clarity without adding risk):

  • Unclear variable/function names
  • Missing or misleading type annotations
  • Unnecessary intermediate variables
  • Over-abstraction (wrappers that add no value)
  • Comments that restate the code instead of explaining *why*

Low (fix only in a dedicated cleanup pass):

  • Inconsistent formatting (defer to linter)
  • Import ordering
  • Trailing whitespace, line length

Phase 3: Refactoring Execution

Apply changes using these tactics, ordered by impact-to-risk ratio:

3a. Eliminate Dead Weight

Remove before restructuring. Less code = less to think about.

  • Delete unused imports, variables, functions
  • Remove unreachable branches (but verify they're truly unreachable)
  • Strip comments that restate the obvious (keep comments that explain *why*)
  • Remove no-op wrapper functions that just forward calls
3b. Flatten Structure

Reduce nesting and cognitive load:

  • Guard clauses: Convert deep if nesting to early returns
  • Extract conditions: Name complex boolean expressions (is_valid_order =...)
  • Decompose loops: If a loop does filter + transform + accumulate, break it apart (or use language-appropriate constructs: list comprehensions, iterators, streams)
  • Invert conditionals: When the else branch is the "happy path", flip it
3c. Consolidate and Name

Make the code's intent visible:

  • Extract functions for repeated logic or distinct responsibilities

- Name by *what it accomplishes*, not *how it works* - Functions should do one thing at one level of abstraction

  • Replace magic values with named constants
  • Rename for intent: data → user_records, process → validate_and_enqueue
  • Group related parameters into a config/options struct when count > 3
3d. Leverage Language Idioms

Apply language-specific patterns (consult references/<language>.md for details):

  • Python: comprehensions, context managers, dataclasses, structural pattern matching
  • Go: table-driven tests, error wrapping, functional options, interface satisfaction
  • TypeScript: discriminated unions, branded types, const assertions, satisfies
  • Rust: iterator chains, ? operator, From/Into, newtype pattern
3e. Tighten Types

Types are documentation that the compiler checks:

  • Add return type annotations to public functions
  • Replace stringly-typed parameters with enums/unions
  • Narrow any/interface{} to specific types where possible
  • Use branded/newtype patterns for identifiers that shouldn't be confused

Phase 4: Verification

Never skip this phase. Simplification that breaks behavior is not simplification.

  1. Run existing tests — If a test suite exists, run it. Report pass/fail.
  2. Run linter/type checker — If configured, run it. Fix new violations your changes introduced.
  3. Manual trace — For each refactored function, mentally trace one happy-path and one error-path input through the old and new code. Confirm identical behavior.
  4. Side effect audit — If the original code had side effects (I/O, mutation, logging), verify the new code preserves them in the same order and conditions.

If tests fail or behavior diverges: revert the specific change, don't try to fix the test.

Phase 5: Report

Present changes as a structured summary. This is important — the developer needs to understand and trust what changed before committing.

For each file modified, provide:

## <filename>

### Changes
- [Critical] Removed unreachable error branch in `parse_config` (dead code after L42 guard)
- [High] Extracted `validate_credentials()` from 60-line `handle_login()` (was 3 responsibilities)
- [Medium] Renamed `d` → `document`, `proc` → `process_batch`

### Complexity Delta
- `handle_login`: 4 levels nesting → 2, 8 branches → 5
- `parse_config`: removed 12 lines of dead code

### Risk Assessment
- Low risk: all changes are structural, no logic modifications
- Tests: 47/47 passing

Adjust verbosity to scope. Single-function cleanup gets a one-liner. Multi-file refactor gets the full report.

Behavioral Constraints

These are hard rules. Do not violate them regardless of how much cleaner the code would look:

  1. Never change observable behavior — This includes error messages, log output, return values, side effect ordering, and exception types
  2. Never remove error handling — Even if it looks redundant. Defensive code often exists for a reason you can't see from the code alone
  3. Never introduce new dependencies — Simplification adds nothing to the dependency tree
  4. Never refactor code outside the specified scope — Unless the user explicitly asks for a broader pass. Resist the urge to "fix one more thing"
  5. Preserve public API surfaces — Function signatures, export names, and type definitions visible to consumers do not change without explicit user approval
  6. Respect existing tests — If a test asserts specific behavior, that behavior is a requirement, even if it seems wrong. Flag it in the report, don't change it

Configuring Scope and Aggressiveness

The user may specify different modes. If they don't, default to standard.

ModeScopeSeverity ThresholdTest Requirement
quickSingle file or functionCritical + High onlyTests recommended
standardRecent git changesCritical + High + MediumTests required if they exist
deepEntire module/packageAll severitiesTests mandatory
surgicalUser-specified lines/functionsAll severitiesManual trace sufficient

The user can specify mode by saying things like "just do a quick pass" or "deep clean this module".

When NOT to Refine

Push back (politely) if:

  • The code has no tests and the user wants a deep refactor → suggest writing tests first
  • The code is auto-generated (protobuf, OpenAPI, ORM models) → suggest modifying the generator
  • The request is really a feature change disguised as "cleanup" → clarify intent
  • The code is in a hot path and "simplification" would introduce allocation/copies → flag the tradeoff

Language References

For language-specific idiom guidance, read the appropriate reference file:

  • references/python.md — Python-specific patterns, anti-patterns, and stdlib alternatives
  • references/go.md — Go idioms, error handling patterns, and interface design
  • references/typescript.md — TypeScript/JavaScript patterns, type narrowing, and module design
  • references/rust.md — Rust idioms, ownership patterns, and iterator usage

Only load the reference file for the language(s) in the current scope. These provide detailed pattern catalogs that supplement the general methodology above.

Rationalizations

RationalizationReality
"It's readable enough""Enough" is not a standard — if the next developer needs to re-read a function 3 times, it's not readable
"Refactoring risks regressions"Not refactoring risks accumulating debt — run the test suite before and after, that's what tests are for
"This is how the codebase has always done it"Consistency with a bad pattern is still bad — improve incrementally, don't preserve anti-patterns
"The performance might get worse"Benchmark before and after — most readability refactors have zero performance impact; premature optimization is the root of all evil
"It's not broken, don't fix it"Refining isn't fixing — it's making working code maintainable, testable, and understandable for the next person
"I'll refactor the whole module later"Incremental refinement works; big-bang rewrites fail — improve what you touch now

Red Flags

  • Changing behavior while claiming "just a refactor" — refining must preserve all existing behavior
  • Touching code outside the declared scope without justification
  • Removing error handling or validation during simplification
  • Introducing new abstractions for one-time operations
  • Refactoring without running the test suite before and after
  • Making style changes to code that wasn't part of the original task

Verification

  • All existing tests pass before and after refinement
  • No behavioral changes — output/side-effects identical for all inputs
  • Changes stay within declared scope — no drive-by edits to unrelated code
  • Cyclomatic complexity reduced or unchanged — never increased
  • No new abstractions introduced for single-use cases
  • Linter and type checker pass: ruff check + mypy --strict or tsc --noEmit + eslint

平台分布

Codex

35.9%
按下载量换算65

Claude

31.9%
按下载量换算57

Cursor

18.72%
按下载量换算34

Gemini CLI

9.76%
按下载量换算18

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills