SLOPSHOPPER

qsm-essentials

The method every session can draw on: how to look at work before building it, the method skills for design, testing, debugging, refactoring, modelling…

rowsguardagents
A shopper browsing a rack in a slop shop
README

qsm-essentials

The core method for an agent working beside a senior programmer: ten skills and four agents for design, testing, debugging, delegation and more.

Why it exists

Without a shared method, every session relearns how this person works: it builds before it understands, settles design by default, forgets what an earlier session decided, and either does everything itself or hands everything away. qsm-essentials is that method: the thinking of a senior programmer about a real problem, written as skills and bounded agents an agent applies, not as a summary a plain model already knows. It takes the stance that a skill earns its place only when the agent works measurably better with it than without. It refuses to hold anything specific to a language, a framework, a project or a machine, and refuses to restate what a plain model does well. When the harness ships this method itself, or a plain model matches it, this plugin has no reason to exist.

What you get

KindNameWhat it does
SkilldebuggingFinds the root cause of a bug or a flaky test before any fix is tried
Skilldistributed-systemsService boundaries, sync or async, data ownership, failure across a network
Skilldomain-modelingEntities, values, aggregates and where a business rule lives
SkillrefactoringChanges structure without changing behaviour, in steps that each stay working
Skillrun-and-verifyStarts the project and proves a change works before anyone says it does
Skillsoftware-architecturePicks an architecture style, weighs trade-offs, records the decision
Skillsoftware-designCuts modules, shapes interfaces and types, decides where complexity lives
Skillsoftware-testingDecides if a change needs a test and picks the cheapest one that runs the real path
SkillsubagentsWrites the task for an agent, splits work, accepts what comes back
SkillwritingCommit messages, tickets, review replies, READMEs, error messages
AgentresearcherAnswers where, what and how over a code tree, with file and line citations
AgentrunnerRuns one noisy command, keeps the log, returns a short briefing
AgentimplementerBuilds one bounded task in its own worktree and proves it end to end
Agentweb-researchAnswers one question from the web in at most five rounds, with sources

Install

claude plugin install qsm-essentials@qsm-marketplace

Install adds the skills and agents only. It has no binary and no dependency.

The web-research agent is the default for the web-research role. A plug-in that ships its own agent of that name replaces it, and the role is that agent's; the core one is the one to use when no plug-in does.

Use

Skills fire on the kind of ask, so there is nothing to call.

  • ask: "why does this test fail only on CI?" loads debugging.
  • ask: "should this be its own service?" loads distributed-systems.
  • ask: "write the commit message for this" loads writing.
  • ask: "hand these three tasks to agents" loads subagents, which then picks implementer, researcher or runner for each.

Caveats

  • No language idioms and no project or machine facts. Those live in other plug-ins.
  • The core names no other plug-in. A tool the skills mention, such as a code index or web search, is used by role when one is installed.
  • Every agent must name its model: a hook refuses an Agent call, a workflow agent or a plugin's spawn without one (a fork excepted), puts the tier in front of the description ([sonnet] researcher: …), and draws the tier in colour before the Agent row in the transcript.
Source 4 files
hooks/register.tsx 64 lines
1// qsm-essentials' function-hooks module: every agent names its model, and the transcript shows it;
2// no Bash call sends a job to the background with `&`; an rm inside the session's own scratchpad
3// runs without a prompt. The rules are lib/agent-model.ts, lib/bash-background.ts and
4// lib/scratchpad-rm.ts; the hooks only refuse, allow, tag and draw.
5import type { On } from "claude-code";
6import { NO_MODEL, TIER_COLOR, tagged, tierOf } from "../lib/agent-model.ts";
7import { backgroundDenial } from "../lib/bash-background.ts";
8import { removesOnlyScratchpad } from "../lib/scratchpad-rm.ts";
9
10export function register(on: On): void {
11  on("tool.call", { tool: "Bash" }, (_$, e, next) => {
12    const denial = backgroundDenial(e.command);
13    return denial === null ? next(e) : { deny: denial };
14  });
15
16  // An agent cleans up after itself: its own scratchpad is the one place it may remove without a
17  // prompt, so a proof directory never outlives the run. Anything else takes the normal decision.
18  on("tool.check", { tool: "Bash" }, async ($, e, next) => {
19    const command: unknown =
20      typeof e.input === "object" && e.input !== null ? Reflect.get(e.input, "command") : null;
21    if (typeof command !== "string") {
22      return next(e);
23    }
24    const sessionId = await $.session.id();
25    return removesOnlyScratchpad({ command, sessionId })
26      ? { decision: "allow", reason: "qsm-essentials: an rm inside this session's scratchpad" }
27      : next(e);
28  });
29
30  on("agent.spawn", (_$, e, next) => {
31    if (e.fork) {
32      return next(e);
33    }
34    if (e.model === undefined || e.model === "") {
35      return { deny: NO_MODEL };
36    }
37    // A workflow agent's content cannot be rewritten; the engine would log the attempt.
38    return e.workflow === undefined
39      ? next({ ...e, description: tagged(e.description, e.model) })
40      : next(e);
41  });
42
43  on("ui.render", { component: "ToolUse" }, async ($, e, next) => {
44    const { input } = e.props;
45    const model =
46      e.props.tool === "Agent" && typeof input === "object" && input !== null && "model" in input
47        ? input.model
48        : undefined;
49    if (typeof model !== "string") {
50      return next(e);
51    }
52    const tier = tierOf(model);
53    const { Box, Text } = $.ui.resolve(e);
54    return (
55      <Box flexDirection="row">
56        <Text color={TIER_COLOR[tier] ?? "gray"} weight="semibold">
57          {tier}{" "}
58        </Text>
59        {await next(e)}
60      </Box>
61    );
62  });
63}
64
lib/agent-model.ts 25 lines
1// Every agent names its model: the tier of a model alias or id, the refusal for a spawn that names
2// none, and the colour the transcript draws each tier in.
3
4const TIERS = ["haiku", "sonnet", "opus", "fable"] as const;
5
6export const TIER_COLOR: Readonly<Record<string, string>> = {
7  haiku: "green",
8  sonnet: "cyan",
9  opus: "magenta",
10  fable: "yellow",
11};
12
13export const NO_MODEL =
14  "Name the model on every agent (haiku, sonnet, opus or fable): an agent left without one inherits the session's model.";
15
16/** The tier word of a model alias or id (`claude-sonnet-5-5` is sonnet), else the model itself. */
17export function tierOf(model: string): string {
18  return TIERS.find((tier) => model.includes(tier)) ?? model;
19}
20
21/** The description with the tier in front, unless it already opens with a bracket. */
22export function tagged(description: string, model: string): string {
23  return description.startsWith("[") ? description : `[${tierOf(model)}] ${description}`;
24}
25
lib/bash-background.ts 22 lines
1// Whether one Bash call sends a command to the background with `&`: the call returns, its shell
2// exits, and the children are orphaned. A function of the command line alone.
3
4const BACKGROUND_DENIAL =
5  "qsm-essentials: `&` inside one Bash call is blocked, because the call returns and its children are orphaned. Run the command with run_in_background on the Bash call, or as separate agent calls. For more, load the qsm-essentials:subagents skill.";
6
7/** Quoted text and comments, removed so an `&` inside them is not read as a job. */
8function unquoted(command: string): string {
9  return command
10    .replaceAll(/'[^']*'/g, "''")
11    .replaceAll(/"(?:\\.|[^"\\])*"/g, '""')
12    .replaceAll(/(^|\s)#[^\n]*/g, "$1");
13}
14
15/** A lone `&`: not `&&`, not a redirection such as `2>&1`, `&>` or `>&2`, not `|&`. */
16const LONE_AMPERSAND = /(?<![&<>|\\])&(?![&>])/;
17
18/** The denial for a command that backgrounds a job, or null. */
19export function backgroundDenial(command: string): string | null {
20  return LONE_AMPERSAND.test(unquoted(command)) ? BACKGROUND_DENIAL : null;
21}
22
lib/scratchpad-rm.ts 45 lines
1// Whether a Bash command only removes things inside this session's scratchpad, so it may run without
2// a permission prompt. A function of the command line and the session id alone: anything it cannot
3// read for certain is left to the normal permission decision.
4
5/** The words that remove. */
6const REMOVERS: ReadonlySet<string> = new Set(["rm", "rmdir"]);
7
8/** Anything the shell would expand, chain, quote or redirect: the line is not read for certain. */
9const SHELL_SYNTAX = /[;&|<>`$(){}\\'"\n~]/;
10
11/** A `.` or `..` segment anywhere in a path. */
12const DOT_SEGMENT = /(?:^|\/)\.{1,2}(?:\/|$)/;
13
14/** The session id as the scratchpad path names it: the transcript file's name, a UUID. */
15const SESSION_ID = /^[\w-]+$/;
16
17/** Inside this session's scratchpad, /tmp/claude-<uid>/<project>/<session id>/scratchpad/, with a
18 * glob only in the last segment, so what the shell expands it to stays inside. */
19function scratchpadPattern(sessionId: string): RegExp {
20  return new RegExp(`^/tmp/claude-\\d+/[^/]+/${sessionId}/scratchpad/(?:[^/*?[]+/)*[^/]+$`);
21}
22
23/** True when the line is one rm or rmdir whose every target is inside the session's scratchpad. */
24export function removesOnlyScratchpad(call: { command: string; sessionId: string }): boolean {
25  const { command, sessionId } = call;
26  if (!SESSION_ID.test(sessionId) || SHELL_SYNTAX.test(command)) {
27    return false;
28  }
29  const [verb, ...words] = command.match(/\S+/g) ?? [];
30  if (verb === undefined || !REMOVERS.has(verb)) {
31    return false;
32  }
33  // After `--` every word is a target, a `-name` file included.
34  const end = words.indexOf("--");
35  const targets =
36    end === -1
37      ? words.filter((word) => !word.startsWith("-"))
38      : [...words.slice(0, end).filter((word) => !word.startsWith("-")), ...words.slice(end + 1)];
39  const inside = scratchpadPattern(sessionId);
40  return (
41    targets.length > 0 &&
42    targets.every((target) => inside.test(target) && !DOT_SEGMENT.test(target))
43  );
44}
45