branching-logic-flow

branching-logic-flow is a skill for Claude Code, Codex from ardanlabs/service. It costs 39 tokens per session (617 once invoked), scanned A, original, Apache-2.0.

A Go coding guideline for simple conditional logic with one to three cases. It recommends setting a default first or using a switch instead of a long if/else chain.

In plain words
What is it for?
Use it when writing or refactoring small Go conditionals, including type checks on loosely typed values and branches that assign to the same variable.
Why use it?
It reduces nesting, repeated code, and the mental effort needed to follow shallow branches.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: installed under .agents/ (shared by several agents).

Good fit Use it when writing or refactoring small Go conditionals, including type checks on loosely typed values and branches that assign to the same variable.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/ardanlabs/service/branching-logic-flow
About the project

ardanlabs/service is a Go starter kit for building scalable web services designed to run in Kubernetes. It provides an organized starting structure based on domain-driven and data-oriented architecture, Go practices, and a small dependency set. The catalogue skills and instruction help coding agents work with services built from this starter kit.

ardanlabs/service · 4,110 stars · on GitHub · ardanlabs.com

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.

Any agent
npx skills add ardanlabs/service --skill branching-logic-flow
Clone the repo
git clone --depth 1 https://github.com/ardanlabs/service

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for branching-logic-flow

README.md
[![agentmods](https://agentmods.dev/badge/skills/ardanlabs/service/branching-logic-flow/github.svg)](https://agentmods.dev/skills/ardanlabs/service/branching-logic-flow)
Your own site
<a href="https://agentmods.dev/skills/ardanlabs/service/branching-logic-flow"><img src="https://agentmods.dev/badge/skills/ardanlabs/service/branching-logic-flow/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for branching-logic-flow

Your own site · 80×15
<a href="https://agentmods.dev/skills/ardanlabs/service/branching-logic-flow"><img src="https://agentmods.dev/badge/skills/ardanlabs/service/branching-logic-flow.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 39 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 617 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
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.1 $0.00039 $0.00617
Opus 5 $0.00019 $0.00309
Sonnet 5 $0.00008 $0.00123
Haiku 4.5 $0.00004 $0.00062

Measured 9d ago against content hash 9d5254da20d7, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

branching-logic-flow 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 9d 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/branching-logic-flow/SKILL.md · 97 lines

How it starts

The opening of the file, as written. The whole thing — 97 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Branching Logic Flow

For shallow branching (1-3 cases), prefer defaulting or naked switches over if/else chains. This reduces nesting, avoids duplication, and lowers the cognitive load.

When to Apply

  • Writing new conditional logic with 1-3 branches
  • Refactoring nested if/else blocks
  • Type assertions on any / map[string]any
  • Any branching where each branch assigns to the same variable

Rule 1: Default first, override later

Initialize the variable with its default value, then override only in the special case.

❌ Avoid:

var result map[string]any
if outer, ok := input["outer"].(map[string]any); ok {
    if inner, ok := outer["inner"].(map[string]any); ok {
        result = make(map[string]any, len(inner))
        maps.Copy(result, inner)
    } else {
        result = make(map[string]any)
    }
} else {
    result = make(map[string]any)
}

✅ Prefer:

result := make(map[string]any)
if outer, ok := input["outer"].(map[string]any); ok {
    if inner, ok := outer["inner"].(map[string]any); ok {
        result = make(map[string]any, len(inner))
        maps.Copy(result, inner)
    }
}

Rule 2: Naked switch over if/else if/else ladders

❌ Avoid:

if a > b {
    result = a
} else if a == b {
    result = a + b
} else {
    result = b
}

✅ Prefer:

switch {
case a > b:
    result = a

case a == b:
    result = a + b

default:
    result = b
}

For simple two-way numeric comparisons, prefer the min/max built-ins (Go 1.21+):

result := max(a, b)

When NOT to Apply

  • Default initialization is heavyweight (DB call, large allocation, external API)
  • The "default" case is exceptional and should fail fast with an error
  • Conditions are deeply nested (>3 levels) — extract to a separate function instead
  • Defaulting could mask a bug that should be surfaced explicitly
  • Use maps.Copy(dst, src) instead of manual copy loops (destination must be non-nil)
  • Use cmp.Or(a, b, "default") to pick the first non-zero value across fallbacks
  • Always use the two-value form v, ok := x.(T) for type assertions

Read the full file on GitHub · 97 lines

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. 9d ago First seen · 97 lines · 39 tokens per session scan A 9d5254da20d7

Subscribe to this mod's changes

branching-logic-flow is a skill published in the GitHub repository ardanlabs/service (4,110 stars, last pushed 10d ago), licensed Apache-2.0. It adds 39 tokens to every session and 617 once invoked, about $0.0002 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

ast-grep

Guide for writing ast-grep rules to perform structural code search and analysis. Use when users need to search codebases using Abstract Syntax Tree (AST) patterns, find specific code structures, or perform complex code queries that go beyond simple text search. This skill should be used when users ask to search for…

JanDeDobbeleer/oh-my-posh · 80 tokens

golang-testing

Production-ready Golang tests — table-driven tests, testify suites and mocks, parallel tests, fuzzing, fixtures, goroutine leak detection with goleak, snapshot testing, code coverage, integration tests, idiomatic test naming. Use when writing or reviewing Go tests, choosing a testing approach, setting up Go test CI…

samber/cc-skills-golang · 115 tokens

golang-uber-fx

Golang application framework using uber-go/fx — fx.New, fx.Provide, fx.Invoke, fx.Module, fx.Lifecycle hooks, fx.Annotate (name/group/As), fx.Decorate, fx.Supply, fx.Replace, fx.WithLogger, and signal-aware Run(). Apply when using or adopting uber-go/fx, when the codebase imports go.uber.org/fx, or when wiring…

samber/cc-skills-golang · 122 tokens

golang-samber-oops

Structured error handling in Golang with samber/oops — error builders, stack traces, error codes, error context, error wrapping, error attributes, user-facing vs developer messages, panic recovery, and logger integration. Apply when using or adopting samber/oops, or when the codebase already imports…

samber/cc-skills-golang · 74 tokens

ax-go-agent-optimize

Use when writing Go code with github.com/ax-llm/ax/packages/go for agent optimization, verified agent-playbook evolution, evaluators, judges, optimizer artifacts, BootstrapFewShot, and GEPA.

ax-llm/ax · 51 tokens

gmeasure

Benchmark and measure Go code with gmeasure — an Experiment groups named Measurements, recorded via RecordValue/RecordDuration/MeasureDuration or repeated Sample/SampleValue/SampleDuration with SamplingConfig, timed inline with a Stopwatch, summarized through GetStats/Stats (StatMin/Max/Mean/Median/StdDev…

onsi/gomega · 129 tokens