Token导航 LogoToken导航

Agent Skill · 研究检索

optimize-code(优化代码)

optimize-code 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

optimize-code 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为需要联网;许可证信息还不明确,第三方扫描已通过,按安装量在研究检索类的 73,675 个 Skill 里排第 71,596。

总安装 194周安装 8GitHub Stars 公开资料未说明下载 63核验 2026-05-01

安装说明

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

安装方式

通过对话安装

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

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

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/jihunkim0/jk-skills --skill optimize-code

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中快速定位候选结果。适用于关键词搜索、任务场景匹配和来源线索筛选等研究检索场景。通过 npx skills add 命令从指定 GitHub 仓库安装并使用。安装前需确认权限范围、维护状态及是否触发联网或文件操作。

optimize-code 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

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

上手步骤

4 步
  1. 1

    确认自己的宿主工具

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

  2. 2

    拿到安装命令

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

  3. 3

    安装后重启宿主

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

  4. 4

    按最小权限试用

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

常见问题

6 条

optimize-code 怎么安装?

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

optimize-code 支持哪些 AI 工具?

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

optimize-code 需要什么权限?

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

optimize-code 是免费的吗?

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

optimize-code 用的人多吗?

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

optimize-code 安全吗?

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

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

值得选的地方

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

先想清楚的地方

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

适不适合你

更适合

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

不太适合

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

研究检索类 Skill 对比

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

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
optimize-code

优化代码 · 本页

194—需要联网未明确通过

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

SKILL.md 原文

Optimize Code — Deep Audit & Lean Refactor

Rigorous, test-grounded codebase audit and refactoring. Eliminate dead code, redundancies, duplication, and unjustified abstractions. Enforce modular architecture and test coverage. Every change validated by tests.

Phase 0: Clean Slate Check (mandatory, before anything else)

Before any optimization work begins, verify the working tree is clean. This is your rollback safety net.

git status --porcelain

If there are any tracked changes (modified/staged) or untracked files:

  1. Show the user the full git status output
  2. Assess the situation and make a recommendation:

- If changes look like completed work (coherent set of related changes, tests pass) → recommend Commit everything - If changes look like work-in-progress (partial implementations, mixed concerns, failing tests) → recommend Stash changes - If the tree is heavily dirty (many untracked files, merge conflicts, unclear state) → recommend Abort

  1. Ask the user (via ask_user) with your recommendation highlighted, presenting all three options:

- Commit everything — commit all changes now as a checkpoint before optimization begins - Stash changes — git stash push -u -m "pre-optimize-code stash" to save work-in-progress - Abort — stop and let the user clean up manually first

  1. Do NOT proceed until the working tree is clean or the user has explicitly chosen an option

Why: Every atomic commit in the optimization relies on being able to git revert or git bisect back to a known-good state. A dirty tree destroys that guarantee.

Core Principles

  1. Ruminate before acting. Read every file, trace every dependency, build the full mental model before changing anything. The most dangerous deletion is the one you didn't fully understand.
  2. Tests are the contract. They must pass before, during, and after every change. If your refactoring breaks a test, the refactoring is wrong.
  3. Prove, don't guess. Never delete based on a hunch. Prove it's dead with grep -rn. Trace callers, exports, imports, usage chains.
  4. Lean over clever. Fewer lines serving the same purpose wins. Kill abstractions that don't earn their keep.
  5. Aggressively modularize. Any file over 300 lines is a mandatory split target. Prefer many small, focused files over few large ones with mixed concerns.
  6. Aggressively refactor. Check for repeated patterns, refactor.
  7. Aggressively simplify. Look for ways to simplify.
  8. Test what you build. New helpers, utilities, or shared functions created during refactoring must have corresponding tests. Flag integration test gaps found during audit.
  9. Atomic commits. Each commit = one self-contained refactoring that passes all tests.
  10. Respect planned extensibility. Before deleting "unused" abstractions, check for TODO, PLANNED, FUTURE, HACK, or FIXME comments nearby. These may indicate intentional extension points — flag them for user review rather than deleting outright.

Phase 1: Recent Changes Review (mandatory, after clean slate)

Before optimizing, understand what has changed recently to build context on the codebase's trajectory. This phase is purely informational — it does not restrict optimization scope. A change in one module often reveals the need for holistic optimization across the entire codebase (e.g., a new feature may expose duplication elsewhere, a refactor in one layer may make another layer's abstractions redundant).

1a. Review recent commits

# Last 30 commits — adjust range as needed for the project's pace
git log --oneline --no-merges -30

Scan for: feature additions, refactors already done, areas of high churn, patterns in commit messages (rushed fixes, repeated touches to the same files).

1b. Review diff against main branch

# If on a branch, see what's diverged
git diff --stat origin/main..HEAD 2>/dev/null || true

1c. Identify high-churn files

# Files most frequently changed in the last 50 commits — likely candidates for cleanup
git log --pretty=format: --name-only -50 | sort | uniq -c | sort -rn | head -20

High-churn files often accumulate duplication, temporary workarounds, and dead code from rapid iteration.

1d. Build context summary

From the above, note:

  • Recent features: what was built or changed — understand intent before touching these
  • Hot spots: files touched repeatedly — prime optimization targets
  • Stale areas: modules not touched in many commits — may contain dead code
  • Ripple effects: how recent changes may have created optimization opportunities *elsewhere* in the codebase (new patterns that obsolete old ones, shared logic that can now be extracted, abstractions that no longer justify their complexity)
  • Patterns: rushed fixes, copy-paste commits, "temporary" additions that stuck around

Scope reminder: This context informs the Deep Audit but does not limit it. The audit in Phase 3 still covers the entire codebase. Recent changes often *cause* the need for holistic refactoring — a new feature may introduce duplication with existing code, a renamed concept may leave stale references across unrelated modules, or a shifted architecture may make entire layers unnecessary.

Phase 2: Baseline

Run the project's full test suite. Record: test count, pass/fail status, runner command. This baseline is sacred — it must hold after every single change. The only acceptable decrease is removing tests for deleted dead code (explicitly noted).

Phase 3: Deep Audit

Don't skim — sit with the code. Read every source file. For each, ask: *"Why does this exist? What breaks if I remove it?"*

2a. Architecture Map

  • Modules & entry points: dependency graph, intended vs. actual architecture
  • Single responsibility check: name each file's job in one sentence — if you can't, it needs splitting
  • Export/import chains: for every export, who imports it? For every import, is it used?
  • Data flow: how data moves end-to-end, where it transforms
  • Coupling hotspots: circular dependencies, God objects, modules that must change together

2b. Modularization Scan (mandatory)

find . \( -name '*.ts' -o -name '*.js' -o -name '*.tsx' -o -name '*.jsx' -o -name '*.py' -o -name '*.go' -o -name '*.rs' -o -name '*.java' -o -name '*.kt' -o -name '*.rb' -o -name '*.swift' -o -name '*.c' -o -name '*.cpp' -o -name '*.h' \) \
  | grep -v node_modules | grep -v '.test.' | grep -v __pycache__ \
  | xargs wc -l | sort -rn | awk '$1 > 300 {print}'

For each flagged file: list distinct responsibilities, propose split strategy, note dependencies. Files 250–300 lines go on the watchlist.

2c. Test Coverage & Gap Analysis

  • Map test coverage: which modules/functions have tests, which don't
  • Flag untested code paths: functions, branches, error handlers with zero test coverage
  • Flag integration test gaps: features with unit tests but no end-to-end verification
  • Flag dead tests: tests for functionality that no longer exists or that assert nothing meaningful
  • Flag missing edge cases: error handling, boundary conditions, race conditions without tests

2d. Opportunity Detection

Scan for waste, ordered by priority:

P0 — Dead code & Waste (zero risk, pure deletion): Dead files/directories, dead exports, dead imports, dead variables, orphaned scripts. Aggressively look for and remove unnecessary, temporary, and scratch files. Unless brutally justified, they must be removed. Every single file being committed must be explicitly justified.

P1 — Duplication (high impact): Near-identical functions (60%+ shared logic → extract helper), copy-pasted blocks (10+ similar lines), parallel data structures, template/prompt overlap.

P2 — Redundancy & over-abstraction (medium): Pass-through wrappers, boolean flag soup, expensive operations with cheaper alternatives, "just in case" abstraction layers.

P3 — Consolidation (maintainability): Scattered constants, co-location misses, naming mismatches (names no longer match behavior).

Architectural smells (flag during all scans): God files, shotgun surgery, feature envy, layer violations.

Verification Technique

# Prove a function is dead
grep -rn "functionName" --include="*.ts" --include="*.js" | grep -v "\.test\." | grep -v "^Binary"
# Prove a file is unimported
grep -rn "from.*['\"].*filename" --include="*.ts" --include="*.js"

Phase 4: Plan & Track

For each opportunity, document: what (files, functions, lines), why safe (grep evidence), how (steps), savings (lines), risk (test coverage), files touched (explicit list).

Execution Order

GroupTypeRisk
1Pure deletionsZero
2Dead function removalLow
3Deduplication + helper testsMedium
4Modularization splitsMedium
5Test gap backfillLow
6ConsolidationLow

Work sequentially through groups. Issues touching the same files must be ordered by dependency.

Phase 5: Execute

Work through items in dependency order. Iron rule: tests must pass after every change.

Pre-execution: lint & format

Before making changes, run the project's linter and formatter (if configured) to establish a clean formatting baseline. This prevents mixing refactoring changes with formatting noise in commits.

# Examples — use whatever the project has configured
npx eslint . --fix 2>/dev/null || true
npx prettier --write . 2>/dev/null || true
python -m black . 2>/dev/null || true
go fmt ./... 2>/dev/null || true
cargo fmt 2>/dev/null || true

Commit any formatting changes separately: git add -A && git commit -m "style: format before refactor"

Per-item workflow:

  1. Verify tests pass (baseline intact)
  2. Make surgical edits (edit tool, not full rewrites)
  3. Run linter/formatter on changed files
  4. Run full test suite
  5. Fail → revert, investigate, understand before retrying
  6. Commit: git add -A && git commit -m "refactor: <description>"

Test enforcement during execution:

  • New shared helpers from deduplication → write unit tests for the helper
  • Modularization splits → verify existing tests still cover split modules; add tests if coverage dropped
  • Integration test gaps from Phase 3 → create issues (follow-up PR if scope is large)
  • Track test count: note additions and removals. Removals only for deleted dead code, explicitly documented.

Phase 6: Ship

  1. Final verification: run full test suite, confirm baseline held or improved.
git diff --stat origin/main..HEAD
git diff origin/main..HEAD --numstat | awk '{add+=$1; del+=$2} END {printf "+%d -%d (net: -%d)\n", add, del, del-add}'
  1. Performance sanity check: if the project has benchmarks or performance tests, run them and compare against pre-refactor results. A refactor that passes all tests but introduces a performance regression is not safe to ship. Flag any regression >5% for user review.
  2. Summary table: commits, lines saved, tests added/removed, performance delta (if benchmarks exist).
  3. Delegate to pr-merge-cleanup skill if available — it handles PR creation, CI, merge, and cleanup. Otherwise: push branch, create PR via gh pr create, wait for CI, merge, pull main, clean up branches.

Rollback Strategy

If a subtle interaction bug is discovered several commits deep:

  1. Bisect to find the cause: git bisect start HEAD <phase0-commit> with the test suite as the bisect script
  2. Revert surgically: git revert <bad-commit> — prefer targeted reverts over resetting the branch
  3. If multiple commits interact: consider reverting to the Phase 0 clean slate commit and re-applying only the safe changes via git cherry-pick
  4. Document the failure: note what went wrong in the commit message so the same mistake isn't repeated

Anti-Patterns

  • Starting optimization with a dirty working tree (uncommitted changes)
  • Deleting code you haven't traced with grep
  • Deleting code near TODO/PLANNED/FUTURE comments without checking intent
  • Skipping test runs between changes
  • Skipping linter/formatter between changes
  • Sacrificing functionality for line count
  • Combining unrelated changes in one commit
  • Refactoring tests to make them pass (tests define the contract)
  • Creating new helpers without corresponding tests
  • Ignoring integration test gaps discovered during audit
  • Ignoring performance regression after refactoring

平台分布

Codex

35.86%
按下载量换算23

Claude

32.02%
按下载量换算20

Cursor

19.74%
按下载量换算12

Gemini CLI

10.07%
按下载量换算6

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

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

安装前确认

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

继续浏览同类 Skills