Simplifying Control Flow
Flatten nested conditionals with early returns or table-driven methods - keep nesting depth under 3 levels
Install
npx skills add obra/clank --skill Simplifying Control Flowgit clone --depth 1 https://github.com/obra/clank.git /tmp/clank
mkdir -p ~/.claude/skills
cp -r /tmp/clank/skills/coding/simplifying-control-flow ~/.claude/skills/Simplifying-Control-FlowPersonal skills live in ~/.claude/skills. Use .claude/skills in a project folder to share a skill with your team.
From the SKILL.md
# Simplifying Control Flow
## Overview
Nested conditionals are hard to understand and error-prone. Flatten them.
**Core principle:** Nesting depth < 3 levels. Use early returns, table-driven methods, or extracted conditions.
## Baseline Violation
**Agents create nested if/else for multi-condition logic:**
❌ **Nested (baseline):**
```python
def calculate_discount(order_amount, is_vip):
if is_vip:
if order_amount > 1000:
return 0.20
elif order_amount > 500:
return 0.15
else:
if order_amount > 1000:
return 0.10
elif order_amount > 500:
return 0.05
return 0.0
```
**Problems:** Duplicated logic, hard to see all tiers, adding tier requires finding nesting spot.
## Three Techniques
### 1. Flatten with Combined Conditions
✅ **All at same level:**
```python
def calculate_discount(order_amount, is_vip):
if is_vip and order_amount > 1000: return 0.20
if is_vip and order_amount > 500: return 0.15
if order_amount > 1000: return 0.10
if order_amount > 500: return 0.05
return 0.0
```
### 2. Table-Driven (Best for Data)
✅ **Business rules as data:**Details
- Skill name
Simplifying Control Flow- Repository
- obra/clank
- Path
skills/coding/simplifying-control-flow/SKILL.md- Repo updated
- 9 October 2025
FAQ
What does the Simplifying Control Flow skill do?
Flatten nested conditionals with early returns or table-driven methods - keep nesting depth under 3 levels
How do I install the Simplifying Control Flow skill?
skills CLI (Claude Code, Cursor, Codex and more): npx skills add obra/clank --skill Simplifying Control Flow. Skills go in ~/.claude/skills (personal) or .claude/skills (project), and Claude loads them automatically when a task matches the description.
Is Simplifying Control Flow popular?
It lives in obra/clank, which has 43 GitHub stars and 26 forks.
Related skills
Gardening Skills Wiki
43obra/clank
Maintain skills wiki health - check links, naming, cross-references, and coverage
Remembering Conversations
43obra/clank
Search previous Claude Code conversations for facts, patterns, decisions, and context using semantic or text search
Brainstorming Ideas Into Designs
43obra/clank
Interactive idea refinement using Socratic method to develop fully-formed designs
Single Purpose Variables
43obra/clank
Use each variable for exactly one purpose - no hybrid coupling or hidden meanings
Sams Architecture
38sam-dumont/claude-skills
Automatically triggered when designing system architecture, planning new projects, creating implementation plans, conducting architecture reviews, or auditing existing codebases for consistency. Applies when discussing: system design, technology choices, architectural patterns, infrastructure decisions, API design, testing strategies, CI/CD pipelines, security architecture, or code organization. Works for Python web APIs, infrastructure/DevOps, Garmin/embedded systems, and frontend projects. Distinguishes between personal projects (strict standards) and client work (adaptive approach).
Stay in Lane
62ElliotJLT/Claude-Skill-Potions
Before making changes, verifies they match what was actually requested. Activates when about to modify files, add features, or refactor code. Catches scope creep before it happens - no "while I'm here" improvements.
Browse the most popular Claude skills, all software development skills, or write your own with the skills generator.