/selamy-skills:single-responsibilityfrom selamy-skills
Use when a class, function, module, or file is hard to reason about. A unit you cannot describe in one sentence holds too many responsibilities; decompose it into single-responsibility units that collaborate through clear interfaces.
Ships in selamy-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
A unit of code — a class, function, module, or file — should have one responsibility: one reason to change, one job you can state in a single sentence. When a unit is hard to reason about, that difficulty is the signal that it has accreted several responsibilities. The fix is not to comment it or split it arbitrarily; it is to separate the concerns into distinct single-responsibility units that collaborate through clear interfaces.
This is the long-established Single Responsibility Principle / separation of concerns, applied as an enforceable code-design habit.
After decomposing, each unit should satisfy all three:
Concrete signals that a unit owns too much:
parameter-design,
complexity-budgets).complexity-budgets,
early-return-over-else).One signal is a hint; several together mean decompose now.
small-focused-changes).A function that validates, transforms, persists, and notifies — four reasons to change in one body:
# before: one function, four responsibilities, hard to test in isolation
def handle_signup(raw):
if "@" not in raw["email"] or len(raw["password"]) < 8:
raise ValueError("invalid")
user = {"email": raw["email"].lower(), "hash": bcrypt(raw["password"])}
db.execute("INSERT INTO users ...", user)
smtp.send(user["email"], render_welcome(user))
return user
# after: each unit has one job; handle_signup is a coordinator that delegates
def handle_signup(raw, validator, store, mailer):
fields = validator.validate(raw) # validation: one reason to change
user = store.create(fields) # persistence: one reason to change
mailer.send_welcome(user) # notification: one reason to change
return user
Each collaborator (validator, store, mailer) is now usable and testable
on its own, swappable behind its interface, and handle_signup reads as the
story of a signup.
A class that has grown an "and":
// before: "manages orders AND prices them AND talks to the gateway"
class OrderManager {
price(order: Order): Money { /* tax + discount rules */ }
charge(order: Order): Receipt { /* payment-gateway calls */ }
save(order: Order): void { /* persistence */ }
}
// after: one responsibility each; a coordinator composes them
class Pricer { price(order: Order): Money { /* ... */ } }
class Payments { charge(order: Order, total: Money): Receipt { /* ... */ } }
class OrderStore { save(order: Order): void { /* ... */ } }
class Checkout {
constructor(
private readonly pricer: Pricer,
private readonly payments: Payments,
private readonly orders: OrderStore,
) {}
place(order: Order): Receipt {
const total = this.pricer.price(order);
const receipt = this.payments.charge(order, total);
this.orders.save(order);
return receipt;
}
}
interface-over-conditionals covers the behavioral-variant
case specifically).Cross-link: composes with small-focused-changes (decompose the change,
this decomposes the unit), complexity-budgets (enforceable size/branching
signals), parameter-design (too many params signals too many jobs),
early-return-over-else (flatten before you split), interface-over-conditionals
and map-dispatch-over-conditionals (decompose behavioral variation behind an
interface), and technical-integrity (decompose for truth, not to hit a quota).
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub selamy-labs/agent-skills --plugin selamy-skills111 skills in this plugin
/adaptive-estimationUse when tracking a slowly-varying latent quantity from noisy measurements with quantifiable uncertainty — a drifting metric, capacity, latency trend, or confidence. Prefer a Kalman-style adaptive estimator over fixed moving averages or static thresholds./adaptive-loop-budgetingUse when an autonomous loop needs explicit limits on attempts, time, cost, tool calls, verification depth, or risk, and a clear stop, continue, yield, or escalate decision./adopt-and-deleteUse when adopting a shared module, library, chart, or service, or doing any consolidation, migration, or refactor that supersedes existing code. The change that adds the replacement must REMOVE what it replaced, in the same atomic change.Other plugins' skills for the same job