control-structure-optimization

提供系统化的检查清单,用于优化控制结构(循环、条件语句、控制流),以创建自解释、可维护的代码。用于编写新的控制逻辑、重构现有代码或进行代码审查,以降低复杂性并提高可读性。

仓库最近推送
GitHub Stars
140
Forks
36
Issues / PRs
1

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "control-structure-optimization":https://skillpi.com/zh/skills/deepskill-741ca6f3e4c2c44acdbc96f9a5a8889666a4a1ff7e5c982e3f0cb28129ab5c02。安装前核对上游来源和版本:https://github.com/kitchen-engineer42/pdf2skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

github.com

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

提供系统化的检查清单,用于优化控制结构(循环、条件语句、控制流),以创建自解释、可维护的代码。用于编写新的控制逻辑、重构现有代码或进行代码审查,以降低复杂性并提高可读性。

0 下载

介绍来源: third_party · kitchen-engineer42 · 0.0.1 参考来源

SkillPi 解读

能完成的任务
翻译待完成,请参阅来源文档。
实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
Frontmatter
name: control-structure-optimization
description: Provides a systematic checklist for optimizing control structures (loops, conditionals, control flow) to create self-documenting, maintainable code. Use this skill when writing new control logic, refactoring existing code, or conducting code reviews to minimize complexity and improve readability.

Control Structure Optimization

Use this checklist to evaluate and improve control structures in your code. Apply these principles when writing or reviewing any control flow logic including loops, conditional statements, and branching logic.

Optimization Checklist

1. Nominal Path Clarity

  • Identify the nominal (normal execution) path through the code
  • Ensure this path is immediately obvious to readers
  • Place the most common case first in conditional structures
  • Avoid burying the happy path inside nested conditions

2. Statement Grouping

  • Group related statements together logically
  • Use blank lines or comments to visually separate logical groups
  • Ensure statements that work together are adjacent
  • Maintain consistent ordering of related operations

3. Routine Encapsulation

  • Identify independent statement groups that perform a cohesive function
  • Extract these groups into their own routines/functions
  • Give each routine a descriptive name that explains its purpose
  • Keep routines focused on a single responsibility

4. Normal Case Priority

  • Structure conditionals to handle the normal case in the if branch
  • Reserve else branches for exceptional or error cases
  • This makes the code read like a description of normal behavior
  • Avoid double negatives in conditions

5. Structural Simplicity

  • Choose the simplest control structure that accomplishes the goal
  • Avoid unnecessary branching or complex conditionals
  • Prefer linear flow over deeply nested structures
  • Eliminate redundant checks

6. Single-Function Loops

  • Ensure each loop performs only one well-defined function
  • If a loop does multiple things, consider splitting it
  • Give loops a clear, single purpose that can be easily described
  • Avoid loops that mix iteration with unrelated operations

7. Nesting Minimization

  • Reduce nesting depth wherever possible
  • Use guard clauses (early returns) to eliminate nesting
  • Consider extracting nested blocks into separate functions
  • Aim for maximum nesting depth of 3-4 levels

8. Boolean Expression Simplification

  • Introduce boolean variables to clarify complex conditions
  • Create boolean functions for repeated or complex checks
  • Use decision tables for complex multi-condition logic
  • Replace nested conditionals with boolean algebra when appropriate

Application Process

  1. Review the control structure - Identify all loops, conditionals, and branching logic
  2. Apply each checklist item - Systematically evaluate the code against all 8 points
  3. Refactor as needed - Make improvements to address any issues found
  4. Verify the changes - Ensure the refactored code maintains the same behavior
  5. Document rationale - Add comments if the optimization isn't immediately obvious

当前收录版本

0.0.1

核对来源版本 ↗

安全与评测信息

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值75/100

亮点

  • 提供系统化的控制结构优化检查清单,具有明确的工程实践价值
  • 适用于代码编写、重构和审查等多个开发场景,受众较广
触发精准85/100

亮点

  • 触发词覆盖合理,包含'优化控制结构'、'代码审查'等关键词
  • 使用场景描述清晰,边界明确,不易与其他Skill重叠
结构规范80/100

待提升项

  • 缺少显式When to Use章节标题 原报告严重程度:轻微

    虽然有实际的使用场景描述,但缺少显式的'When to Use'章节标题

    改进建议:建议在文档开头添加显式的'When to Use'章节,提升结构清晰度

  • description重复 原报告严重程度:轻微

    description在frontmatter和skill_body开头重复出现

    改进建议:建议统一description位置,避免重复内容

亮点

  • Application Process五步流程清晰完整
  • checklist八项原则覆盖全面,每项都有具体指导
执行可靠90/100

亮点

  • 基于软件工程最佳实践,工具来源明确可靠
  • 包含验证步骤和文档要求,确保优化后的代码质量
证据可验 (前四项均值)83/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

100 / 100 · skillpi-20261123-no-r3-v1

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。