frontend-code-optimization

A focused review method for improving the structure of frontend code when a system has grown difficult to maintain.

In plain words
What is it for?
Use it for frontend maintainability audits, component and logic refactoring, prop-drilling changes, state ownership problems, or choosing one small restructuring task.
Why use it?
It helps find duplicated state, overly broad component inputs, misplaced business logic, and unnecessary abstractions without splitting files just because they are long.

Skill for Claude CodeCodex

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 skills/peiiii/nextclaw/frontend-code-optimization
Any agent
npx skills add Peiiii/nextclaw --skill frontend-code-optimization
Clone the repo
git clone --depth 1 https://github.com/Peiiii/nextclaw

Made for: Claude Code, Codex.

Per session 66 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 586 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 $0.00066 $0.00586
Opus 5 $0.00033 $0.00293
Sonnet 5 $0.00013 $0.00117
Haiku 4.5 $0.00007 $0.00059

Measured 2d ago against content hash 96617604a455, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

frontend-code-optimization 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.

.agents/skills/frontend-code-optimization/SKILL.md · 41 lines

What it actually says

前端代码优化

定位

这是显式前端治理任务的诊断入口,不是所有前端改动的生命周期 owner。本 skill 只识别最高收益的结构问题并选择一个当前专项 owner;阶段推进、验证、Review 和交付由当前生命周期负责。

诊断顺序

  1. 找出用户可见行为和稳定业务事实。
  2. 判断当前对象是展示组件、业务容器、adapter、manager/store/presenter 还是生命周期 owner。
  3. 查重复状态、重复 action、宽 props、组件内业务编排、effect 状态迁移和重复 UI 骨架。
  4. 按收益排序:事实双写/错误 owner > 业务透传 > 生命周期不安全 > 重复实现 > 单纯文件偏长。
  5. 每次只选择一个可验证 vertical slice,不同时启动所有前端专项治理。

专项选择

  • 状态归属、MVP、store/manager/presenter、prop drilling:mvp-view-logic-decoupling
  • React key、动态组件、streaming DOM、焦点/选区/iframe/editor 连续性:react-rendering-lifecycle-safety
  • 样式 owner、响应式、基础组件可移植性:frontend-style-encapsulation
  • 操作语义、状态反馈、键盘可达性、tooltip/menu:frontend-interaction-quality
  • 文件和 feature root 变化:file-organization-governance

同一判断只加载一个上述专项;完成该 slice 后再决定是否需要下一项。

实施原则

  • 先删重复计算、重复状态、重复入口和无语义中间组件。
  • 业务状态与动作收敛到最近 owner,展示组件只接展示合同。
  • 不因文件长机械拆分;按变化原因、生命周期、不变量和真实复用拆分。
  • 不用新 ViewModel/Presenter/Manager 包装混乱;新 owner 必须减少参数面或删除旧职责。
  • 必要的清晰增长允许存在,不为行数门槛扩大无关重构。

输出

审计时给出 findings、证据、正确 owner、优先级和最小 slice。实施时只汇报当前 slice、主要验证和是否出现新的结构风险,不自动加载主观 review 或完整治理全家桶。

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. 2d ago First seen · 41 lines · 66 tokens per session scan A 96617604a455

Subscribe to this mod's changes

frontend-code-optimization is a skill published in the GitHub repository Peiiii/nextclaw (253 stars, last pushed 2d ago), licensed MIT. It adds 66 tokens to every session and 586 once invoked, about $0.0003 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.

Related

Other skills, from other repositories

ha-mac-control

Hope Agent native macOS desktop control — the standard maccontrol status / diagnostics / apps / dock / spaces / snapshot / visual / windows / menu / clipboard / dialog loop, target-first action rules, no-blind-coordinate policy, and recovery for stale AX/window/menu/dialog state. Load whenever using maccontrol, or…

shiwenwen/hope-agent · 139 tokens

ha-skill-creator

Create, edit, improve, or audit Hope Agent skills. Use when the user wants to: (1) create a new skill from scratch, (2) edit or improve an existing skill, (3) review or clean up a SKILL.md file, (4) run evaluations to test skill effectiveness, (5) optimize skill descriptions for better trigger accuracy. Trigger…

shiwenwen/hope-agent · 106 tokens

ha-browser

Hope Agent browser automation — the standard status → tabs → snapshot → act loop, stale-ref recovery rules, and what to do when login / 2FA / captcha / camera-prompt / dialog blocks progress. Load this skill whenever you reach for the browser tool. Trigger on: user asks the agent to open / control / click / scrape /…

shiwenwen/hope-agent · 140 tokens

ha-logs

Self-service diagnostics — query Hope Agent's local SQLite databases (logs / sessions / background jobs) directly via the exec tool to investigate problems, analyze usage, and locate root causes. Trigger on: user reports something broken / failing / slow / stuck / not responding ('X 不工作', 'X 报错', 'X 卡住', '为什么 X 失败'…

shiwenwen/hope-agent · 183 tokens

ha-pet-import

Safely import, select, switch, or enable a compatible desktop pet in Hope Agent. Resolve packages from any origin, including local folders, zip archives, pet.json plus a sprite, PNG/WebP atlases, chat attachments, repository or cloud files, direct HTTPS artifact URLs, and download pages. Use whenever a user asks to…

shiwenwen/hope-agent · 109 tokens

feishu

Use when the user mentions 飞书 / Feishu / Lark workspace operations: docx (云文档) read/write, bitable (多维表格) records / views / dashboards, drive (云盘) upload/download, wiki (知识库) link resolution, approval (审批) instance create/cancel/query, calendar (日历) event create/list/update + attendees, contact (联系人) user/department…

shiwenwen/hope-agent · 189 tokens