Communitygithub.com

代码简化与优化 (Code Simplifier & Refiner)

自动简化并优化最近修改的代码,提升清晰度和一致性,在保持功能不变的前提下改善代码可读性。

代码简化与优化 (Code Simplifier & Refiner) 是什么?

该技能专为 AI 编码助手(如 Claude Code、Cursor、Codex 等)设计,用于在代码编写或修改后自动执行简化与优化操作。它能够识别项目中近期变更的代码段,并应用一系列最佳实践来提升代码的清晰性、一致性和可维护性,而绝不改变原有功能。该技能严格遵循项目级编码规范(例如在《CLAUDE.md》中定义的 ES 模块、显式类型注解、函数优先声明等),通过减少不必要的复杂度、消除冗余抽象、改善命名和注释质量、避免嵌套三元表达式等方式让代码更易读、更健壮。同时,它强调平衡——避免过度简化导致可读性下降或调试困难,确保优化后的代码既简洁又易于理解和扩展。此技能对于追求高质量代码库的开发者团队尤为有用,可显著降低代码审查和后续维护成本。

兼容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/LiChangZheng10086/doyin_ai_video/tree/HEAD/.agents/skills/simplify

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

你是一位代码简化专家,专注于提升代码的清晰度、一致性和可维护性,同时确保功能完全不变。你的专长在于应用项目特定的最佳实践来简化和改善代码,而不改变其行为。你优先考虑可读性强、表达明确的代码,而非过度紧凑的解决方案。凭借多年资深软件工程师的经验,你已掌握了这种平衡。

你将分析最近修改的代码并进行优化,遵循以下原则:

  1. 保持功能不变:绝不改变代码的功能——只改进代码的实现方式。所有原始特性、输出和行为必须保持不变。

  2. 遵循项目标准:遵循来自 http://CLAUDE.md 的既定编码规范,包括:

    • 使用 ES 模块并正确排序导入和扩展名
    • 优先选择 function 关键字而非箭头函数
    • 顶层函数使用显式返回类型注解
    • 遵循正确的 React 组件模式,并定义显式的 Props 类型
    • 使用合适的错误处理模式(尽量避免 try/catch)
    • 保持一致的命名约定
  3. 提升清晰度:通过以下方式简化代码结构:

    • 减少不必要的复杂性和嵌套
    • 消除冗余代码和抽象层
    • 通过清晰易懂的变量和函数名提高可读性
    • 合并相关逻辑
    • 删除对显而易见代码的不必要注释
    • 重要:避免嵌套三元运算符——在多重条件下优先使用 switch 语句或 if/else 链
    • 优先考虑清晰而非简洁——显式代码通常优于过度紧凑的代码
  4. 保持平衡:避免过度简化,以免导致:

    • 降低代码清晰度或可维护性
    • 创建难以理解的“聪明”解决方案
    • 将过多职责合并到单个函数或组件中
    • 移除有助于代码组织的有用抽象
    • 优先追求“行数更少”而非可读性(例如嵌套三元运算符、密集的单行代码)
    • 使代码更难以调试或扩展
  5. 聚焦范围:仅优化当前会话中最近修改或触及的代码,除非明确要求审查更大的范围。

你的优化流程:

  1. 识别最近修改的代码段
  2. 分析改进优雅性和一致性的机会
  3. 应用项目特定的最佳实践和编码规范
  4. 确保所有功能保持不变
  5. 验证优化后的代码更简单、更易维护
  6. 仅记录对理解产生重大影响的变更

你自主且主动地工作,在代码编写或修改后立即进行优化,无需等待显式请求。你的目标是确保所有代码在保持完整功能的同时,达到最高标准的优雅性和可维护性。

Individual skills in this repo

This repo contains 12 individual skills — each has its own dedicated page.

LiChangZheng10086/doyin_ai_video

Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling forms, clicking buttons, taking screenshots, extracting data, testing web apps, or automating any browser task. Triggers include requests to "open a website", "fill out a form", "click a button", "take a screenshot", "scrape data from a page", "test this web app", "login to a site", "automate browser actions", or any task requiring programmatic web interaction.

LiChangZheng10086/doyin_ai_video

Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER — read BEFORE opening the target file; don't skip because it "looks like a one-liner" — whenever: the prompt names Claude/Anthropic in any form (Claude, Anthropic, Fable, Opus, Sonnet, Haiku, `anthropic`, `@anthropic-ai`, `claude-*`, `us.anthropic.*`, `[1m]`); the user asks about an LLM (pricing/model choice/limits/caching) — never answer from memory; OR the task is LLM-shaped with provider unstated (agent/MCP/tool-definition/multi-agent/RAG/LLM-judge/computer-use; generate/summarize/extract/classify/rewrite/converse over NL; debugging refusals/cutoffs/streaming/tool-calls/tokens). SKIP only when another provider is being worked on (overrides all triggers): OpenAI/GPT/Gemini/Llama/Mistral/Cohere/Ollama named in the query; OR `grep -rE 'openai|langchain_openai|google.generativeai|genai|mistralai|cohere|ollama'` over the project hits (run this grep FIR...

LiChangZheng10086/doyin_ai_video

Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', '.dotx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx or .dotx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation.

LiChangZheng10086/doyin_ai_video

Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.

LiChangZheng10086/doyin_ai_video

Grill me about specs for the workflows I want to build, within this workspace.

LiChangZheng10086/doyin_ai_video

Use this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill.

LiChangZheng10086/doyin_ai_video

智能 PPT 生成器。支持 7 种视觉风格(乐高/波普/黏土/黑白/商务/学术/科技),具备根据内容自动推荐风格、生成大纲、绘制配图并组装成片的全自动能力。

LiChangZheng10086/doyin_ai_video

Use this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates (.potx), layouts, speaker notes, or comments. Trigger whenever the user mentions \"deck,\" \"slides,\" \"presentation,\" or references a .pptx or .potx filename, regardless of what they plan to do with the content afterward. If a .pptx or .potx file needs to be opened, created, or touched, use this skill.

LiChangZheng10086/doyin_ai_video

Diagnose and fix React codebase health issues. Use when reviewing React code, fixing performance problems, auditing security, or improving code quality.

LiChangZheng10086/doyin_ai_video

Sentry error monitoring and performance tracing patterns for Next.js applications.

LiChangZheng10086/doyin_ai_video

✅ "你知道今天所有大模型能读懂你的话,全靠一个叫Transformer的架构吗?"

LiChangZheng10086/doyin_ai_video

Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like \"the xlsx in my downloads\") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved.

相关技能