Skip to content
v0.2.0MIT

Rigorous agent workflows for AMD GPU kernel development (aiter, FlyDSL, Triton, HIP/MFMA on gfx942 and gfx950) and Jira-ticket-driven work. A fork of pstack.

mstack

mstack is a Cursor plugin for AMD GPU kernel development and Jira-ticket-driven work. It targets aiter, FlyDSL, Triton, and HIP/MFMA kernels on MI300X (gfx942) and MI355X (gfx950).

It is a fork of pstack (see Upstream). It keeps pstack's process: go deep first, write less code, verify against the real artifact. It adds the kernel domain and a ticket lifecycle.

mstack ends in a deliverable, not always a PR. A ticket can end in a PR, a Jira comment draft, or both. A human approves every Jira post.

mstack routes kernel work through skill functions. A playbook names a skill function, such as lever.menu or isa.diff. One file, skill-functions.md, binds each skill function to the matching skill in your skills dir, the skills resource. python3 scripts/check.py checks that file against the installed skills.

install

/add-plugin mstack

the plugin ships two hooks (hooks/hooks.json). the sessionStart hook syncs the skills that the pr.review and pr.validate skill functions bind to. it syncs each one to the latest origin of its repo. it runs in the background, so a session never waits on it. the stop hook acts only in a chat that froze a hillclimb harness with scripts/climb-gate.py freeze. it sends the turn back to the agent, at most 3 times in a row, in two cases. one case is a frozen file that changed in a worktree of the climb. the other is a current best with no bench artifact that has correctness passed at its HEAD. the current best is S* (the best lever subset) once it is registered, and B (the baseline commit) before that. climb-gate.py pause lets one stop pass, and it takes a reason.

get started

two steps:

  1. run /setup-mstack, pick a reasoning budget, and choose which models you want. it then maps this machine (gpu hosts, your containers, PR tool, jira sites, gpu lock) into ~/.cursor/mstack/env.md. it also looks up your local resources and optional modules by what they contain, and asks only for what it did not find. see local resources and optional modules.
  2. use /ateam-mode whenever you're doing anything that requires rigor.

new here? the mstack guide walks you through a first real task, from setup and prompting through verification and overnight runs. stuck, or unsure which skill fits? ask /ateam-help.

that's it. the other skills are situational; the mode skill uses them for you as needed. out of the box the mode splits work by model strength. code delegates (feature, refactoring, bug fix, perf, hillclimb) go to sonnet 5.5, while the hardest changes, prose, and judgment go to opus 5.5. each list role defaults to two entries, opus 5.5 and sonnet 5.5. /setup-mstack changes any of it.

local resources and optional modules

setup looks first and asks second. it finds each thing by what it contains, never by its name or location. it asks only when it finds nothing, finds several, or cannot verify what it found.

/setup-mstack env
   │
   ▼
read-only search of your home  (bounded depth, time limit, no .git internals)
   │
   ├── one match ────────► recorded, listed in the report
   ├── several matches ──► asks which one
   ├── no match ─────────► required: asks     optional: asks once, may skip
   └── check fails ──────► shows the failing test, asks again
   │
   ▼
~/.cursor/mstack/env.md   (outside the plugin, an update never overwrites it)
resourcewhat it enablesrequiredhow setup finds itwithout it
reposgpu runs, worktrees, prs, sha recordsfor a gpu run, a worktree, or a pra git checkout whose remote url ends in ROCm/aiter, ROCm/FlyDSL, or triton-lang/triton. several checkouts of one repo: it asks whichgpu runs and prs stop
skillsevery skill function. the domain skills dirfor a skill function$MSTACK_SKILLS_DIR, else a folder that cursor loads user skills from and that holds */SKILL.md with valid frontmatter. if several folders qualify, the one that resolves the most skill function bindings. link each skill from its repo so it stays currentskill functions stop
ticketsticket folders for jira workfor ticket workfolders that hold ticket-raw.md, ticket-description.md, or ticket-description.txt. the root is their common parentticket work stops
refscited peaks, rooflines, numericsnomarkdown in your repos' docs, outside the kb, that covers peaks, roofline, or numerics. setup proposes the topicspeaks come from public sources
kbcited notes, and kb.capture for lessons. any name, any layoutnoa directory whose root index links to subfolders that have their own index files, with notes that carry name and description frontmatter. setup maps its folders to roles, and asks only about a role it cannot matchno cited notes, no kb.capture
wavescopethe trace annotation loop. an independent checkout with a node clinoa checkout whose remote url ends in /WaveScope, or a directory that holds src/cli/att.js, and the cli runstrace findings go in the reply or the ticket folder

the knowledge base and wavescope are independent, optional modules. mstack works without them.

if setup missed one, answer its question with a path, or rerun /setup-mstack env. for the skills dir, you can also set $MSTACK_SKILLS_DIR. the report at the end lists every resource, its value, and how it was identified, so you can correct any of them.

pushing works over ssh or https with the credentials you already have. setup reads each repo's remote scheme, tests it read-only, and never changes a remote or stores a token.

usage

use /ateam-mode at the start of a task. it reads your request, picks from a set of playbooks, and runs the other skills as the steps need them.

just use /ateam-mode

this skill is the main shortcut. i use it whenever i need the agent to do rigorous engineering work. it comes with twenty-six playbooks:

/ateam-mode this flydsl kernel returns nan at T=4096 on gfx950. repro first, then fix and
verify.
/ateam-mode i'm going to bed. land the stack even if ci flakes. i want everything merged by
morning.

the twenty-six playbooks

playbookfor
investigationa read-only question. how does x work, why was y built this way, are we sure.
bug fixreproduce a defect, root-cause it, and fix with runtime evidence.
perftrace a measured slowness and improve it against a baseline.
kernel hillclimbsustained improvement of one metric against a target, mostly a gpu kernel: correctness-gated harness, isa resource pre-check before any benchmark, benchmarks queued on one locked gpu, levers named from the lever.menu skill function, one commit per accepted win. other metrics use its non-kernel section.
bound probebefore a redesign, measure the ceiling cheaply (analytic bound, copy roofline, remove-one-piece diagnostic, staged copy, in-model share) and decide go, no-go, or re-target. a probe proves a ceiling, never a speedup.
repro auditverify someone else's claim, number, or bug report on the real gpu: pin the environment, reproduce as stated, vary one axis, and give each claim a verdict.
runtime forensicsdiagnose a live symptom (a hang, wrong results, nan, a slowdown, a gpu stuck busy, or a host-side leak) from instrumentation.
trace forensicsdiagnose a captured profiling artifact (an att trace, rocprofv3 output, isa or ir dumps, or a host-side profile).
featurenew or changed behavior, built from a named data shape.
refactoringa behavior-preserving change to structure or shape.
prototypea throwaway sketch to make a design or behavioral decision cheaply, or to settle an empirical fork by observing it.
authoring a skillwriting or editing a SKILL.md.
evaltest how a skill or prompt change affects agent behavior, blinded.
pr reviewadvisory review of an aiter, flydsl, or triton pr: one rule set and its gates run in the pr's own repo, gpu base-vs-head evidence, the repo's conventions, a review group on several models, and a draft you approve before it posts with line comments.
babysitdrive a pr or a stack to merge-ready: conflicts, review threads, ci.
shippingindependently verify a green stack, then land the contiguous verified run bottom-up through the resolved PR tool.
autonomous rundrive a long task to completion without stopping.
autopilot-fullrun independent prs to merged with one owner per pr and a root fan-out verdict on each round, from the code-ready head on.
autopilot-stackbuild and verify one linear base-branch stack for the operator to review and land.
session pickupresume or take over a prior agent's in-flight work.
pause safelysuspend in-flight work cleanly so it can be resumed later.
multi-phase planwork that spans phases or stacked PRs.
worktree cleanupreclaim disk by pruning merged or abandoned worktrees, safety-gated.
ticketwork that starts from a jira key. loads the ticket into its ticket folder with /ticket-init, sets a checkable predicate, routes to the matching playbook, and ends in deliver.
deliverclassify the output as code, finding, or both. code goes to opening a pr. a finding becomes a jira comment draft the human approves. invoked at the end of every other playbook.
opening a propen a draft pr from small ordered commits with a conventional commits title and a briefing-style body. invoked by deliver for code output.

when invoked it:

  1. matches your task to a playbook and opens a todo list whose first items are its steps, copied in verbatim.
  2. routes to the other skills as the steps fire.
  3. writes replies diagram-first in short asd-ste100-lite sentences, with a one-line number, unit, and run count for each measurement, and an html page when a diagram alone is not enough.

the full rules and playbooks live in skills/ateam-mode/SKILL.md.

to keep /ateam-mode on across turns, pick it from the / menu and press option+enter (mac) or alt+enter (windows) instead of enter. that makes it a custom mode, which cursor offers in the agents window and the cli. it stays in context every turn, applies itself when a playbook matches or the task needs rigor, and does nothing otherwise. plain enter attaches it to one message only. say so to opt out, or exit the mode to turn it off.

/ateam-mode works well with cursor's /loop command. cursor can then work for many hours without sacrificing rigor.

skills

/ateam-mode runs most of these for you when a step needs them (how, why, architect, arena, interrogate, unslop, no-comments, technical-writing, tdd, and the principles). the table below is for when you want one directly:

/how does aiter pick between the hip and triton kernels for this gemm? where does the M threshold live?
/interrogate review this branch.

all skills

skilluse it when
/ateam-modedefault entry point for any non-trivial task.
/ateam-helpyou're new to mstack, or unsure which skill, playbook, or principle fits. finds out what you're trying to do, answers that part, and hands you a prompt to type. runs only when you type /ateam-help.
/ticket-inityou start from a jira key. writes ticket-raw.md in the ticket folder, a brief of at most 150 words, and an acceptance predicate.
/verify-gpu-kernelyou need to run, reproduce, or benchmark a kernel on the real gpu. resolves the host and container, locks one idle gpu, runs the op_test, and writes a json artifact into the ticket folder.
/howyou want a walkthrough of how a subsystem works.
/whyyou want to know why something was built this way. queries its sources in parallel: source control and prs (github), issue tracker (jira), long-form docs (confluence), chat (slack), code history, and incidents.
/recallyou're starting or resuming work and want your recent context on a topic rebuilt from your own chat history and the shared record, handed back as a tight current-state brief.
/ketchupyou want everything in this chat since your last message, in plain words, with an executive summary for each action item so you can make the call.
/blast-radiusyou have a small-looking change and want to know what else it could break, with the one fact it's safe because of proven by running code, not asserted.
/architectyou're about to write code that crosses a function boundary and want the caller's usage, types, and module shape settled first.
/arenayou want N parallel attempts at the same thing, then to grab the best parts of each.
/interrogateyou have a diff and want different models to try to break it, including a strict code-quality lens.
/automate-meyou want your own -mode skill, drafted from how you've worked.
/setup-mstackyou want to pick which models mstack uses per role, or map this machine for kernel work. /setup-mstack models writes the model rule. /setup-mstack env writes ~/.cursor/mstack/env.md.
/reflecta long task landed and you want the recipe captured as a skill edit.
/correctyou keep correcting agents for the same mistakes. mines history for mistake classes, fixes each at the highest level that works (architecture, then types, lint, and ci, then tests, with docs last), and keeps a table pairing each rule with what enforces it.
/teachyou want to understand a kernel or a kernel change: data flow, tiling, pipeline waits, and what the numbers mean. runs how + why, diagrams first, optional HTML page.
/tddyou're fixing a bug and there's a cheap local test path. write the failing test first, then the fix.
/benchmark-checklistyou ran a benchmark or measured a speedup or regression. vets the number (limiter, tuning, errors, repeat runs, end-to-end relevance) before you report or act on it.
/no-commentsstrip comments before review; spawns Comment Sicko, fixes accepted findings, offers encodings for claimed constraints.
/figure-it-outno bundled playbook fits. designs a rigorous, auditable playbook for the task.
/show-me-your-workyou want a reviewable decision trail. logs decisions to a tsv you can commit.
/create-verification-skilla kernel library has no scripted way to prove its ops. generates a repo-local verify skill with one feature file per op family for correctness, perf, and ISA resources.
/maintain-verification-skillthe verify map of a kernel library may be stale. detects op test, tolerance, arch gate, and harness drift, re-proves each feature on one locked GPU, and reports drift per op family.
/unslopyou're cleaning up writing. removes AI tells.
/broyou want the last message restated without kernel or ROCm jargon (VGPR, LDS, MFMA, occupancy, spills).
/technical-writinglayered doc standard (Diátaxis + Google developer style + STE + Global English) for docs, RFCs, readmes, PR descriptions, commit messages.

examples

mostly i type /ateam-mode at the start of a task and let it route to a playbook. the other skills fire as the steps need them. a few i reach for directly.

all the examples

bug fix:           /ateam-mode this flydsl kernel returns nan at T=4096 on gfx950. repro first,
                   then fix and verify.
perf:              /ateam-mode close the 1.4x gap to the triton reference for this gemm on
                   gfx950. run a counter pass and tell me what limits it.
feature:           /ateam-mode add an fp8 path to this aiter op behind a dtype flag. verify it
                   against the torch reference on a locked gpu.
prototype:         /ateam-mode build two prototypes of the lds layout for this kernel so we can
                   compare. spawn an agent for each.
multi-phase:       /ateam-mode open source these skills as a plugin. nothing internal leaks, work
                   in a temp dir, show me the dependency graph first.
overnight run:     /ateam-mode i'm going to bed. get the stack green even if ci flakes. i want
                   every pr verified and ready for my review by morning.
pr review:         /ateam-mode review ROCm/aiter#123. draft it, i'll approve before it posts.
babysit:           /ateam-mode check on pr 123. anything outstanding?
figure it out:     /ateam-mode i'm stepping away. migrate every op test from the old timing helper
                   to run_perftest, keeping the reported numbers identical. i want to trust it
                   was done right when i'm back.
how:               /how does aiter pick between the hip and triton kernels for this gemm? where
                   does the M threshold live?
why:               /why does this dispatch threshold route M<=64 to the hip kernel?
architect:         design the shape dispatch for this kernel family so it never routes a shape to
                   a slower path. /architect this first.
bound probe:       /ateam-mode bound the ceiling of a fused redesign before we build it.
repro audit:       /ateam-mode reproduce the numbers claimed in this pr.
ticket:            /ateam-mode resume PROJ-123.
trace:             /ateam-mode here is an att trace of the slow kernel. where does the time go?
refactor:          /ateam-mode clean up this aiter kernel without changing its isa.
arena:             /arena take my prompt to the arena verbatim. i want to compare their proposals
                   with yours.
fan-out:           /ateam-mode check every kernel under aiter/ops/flydsl/ with the isa.diff skill function.
                   one worker per kernel. one report.
interrogate:       /interrogate review this branch.
tdd:               /tdd implement
unslop:            can we unslop and tighten the new changes?
reflect:           /reflect that took too long. capture what we learned so the next run doesn't
                   repeat it.
correct:           /correct
show-me-your-work: /show-me-your-work keep a decision trail i can review when i'm back.
automate-me:       /automate-me
help:              /ateam-help which skill should i use to review this branch?

the ateam-agent and Comment Sicko subagents

/ateam-mode runs in the chat that receives it. that chat owns the playbook, the todo list, and every subagent spawn.

mstack also ships subagent_type: "ateam-agent" as the wrapper for delegates spawned during a run. it reads ateam-mode in full, including its inline principles index, before doing any work. substituting generalPurpose skips that read and drifts. do not spawn ateam-agent to run the playbook itself.

/ateam-mode and subagent_type: "ateam-agent" route through the same wrapper.

mstack also ships Comment Sicko, a read-only comment reviewer available as subagent_type: "comment-sicko". usually invoke it through /no-comments, not directly.

principles

twenty short skills, one principle each. ateam-mode indexes them inline and reads that index at task start. the standalone files are there so other skills can reference a principle by name, and so the index can point at the full rule for each.

all twenty principles

principlegrouprule
redesign-from-first-principlescoreRedesign as if the requirement had been a foundational assumption from day one, instead of bolting it on. Pick core types, data structures, and scaffold before logic.
attack-the-premisecoreApply when two or more fixes that share one premise have failed the same gate. Take a census of which actors hold the imbalance before the next fix, then question the premise instead of writing another fix that assumes it.
subtract-before-you-addcoreRemove dead weight, redundant validators, and stub references first. Make the smallest change that solves the problem.
minimize-reader-loadcoreCount layers between question and answer, and hidden state in the reader's head; collapse one-caller wrappers and shrink mutable scope.
outcome-oriented-executioncoreApply during planned rewrites and migrations with explicit phase boundaries. Converge on the target architecture; don't preserve smooth intermediate states with throwaway compatibility code.
exhaust-the-design-spacecoreBuild 2-3 competing prototypes and compare side by side before committing.
build-the-levercoreApply to any non-trivial work, not just bulk work: edits, migrations, analyses, checks. Build the tool that does it or proves it (codemod, script, generator, or a skill your subagents follow) instead of working by hand. The tool is the artifact a reviewer can rerun.
model-the-domainarchitectureEncode the domain in a structure instead of scattered conditionals.
migrate-callers-then-delete-legacy-apisarchitectureMigrate callers and delete the old API in the same wave instead of preserving compatibility layers.
separate-before-serializing-shared-statearchitectureEliminate the sharing first; serialize structurally only when one shared writer is a real invariant.
prove-it-worksverificationApply after completing a task, before declaring done. Verify against the real artifact (run the feature, read the actual value, inspect the diff), not a proxy, self-report, or 'it compiles.'.
fix-root-causesverificationTrace each symptom to its root cause and fix it there; reproduce first, ask why until you reach it, resist nil-check guards that silence crashes.
sequence-verifiable-unitsverificationApply to multi-step work (sweeps, migrations, runs of similar edits) and to how you stack commits and PRs. Break work into small units that each end in a verifiable state, check each before the next, and order delivery so the sequence proves itself to a reviewer.
test-behavior-not-implementationverificationApply when you write, change, or keep a test. Call the code the way its users do and assert the result they observe against a literal expected value. If the test would still pass when every imported function returns undefined, rewrite the assertion or delete the test.
explain-the-numberverificationApply before you trust, report, or act on a number you measured: a speedup, a regression, a throughput, a latency, or an eval result. Find what limits it, state a GPU kernel number as a percent of peak with the peak's source, and rule out that it measured something other than the work you think.
prove-it-reached-codegenverificationApply when you change a compile hint, flag, attribute, or kernel structure and want credit for a result. A knob is real only if the ISA or IR changed.
correctness-before-speedverificationApply before you time, report, or keep any kernel change. A perf number counts only after an allclose check and a NaN count pass on the same run.
guard-the-context-windowdelegationRoute bulk to subagents; keep summaries in the main thread, not raw payloads.
never-block-on-the-humandelegationProceed, present the result, let the human course-correct after the fact; reserve confirmation for irreversible actions.
encode-lessons-in-structuremetaEncode the rule as a lint, metadata flag, runtime check, or script instead of more text.

pr review caveats

  • pr review needs gh 2.24 or later, signed in. the review's fetch step reads the pr through gh, and git or the github mcp cannot replace it in a script. a distro package can be too old (ubuntu 22.04 ships 2.4.0), so install a release binary if needed. sign in with gh auth login, or set GH_TOKEN to a token that can read pull requests. if you want mstack to post reviews, the token needs write access to pull requests too.
  • nda model names are optional. before a review posts, scripts/post-review.py blocks local paths and internal ticket keys. it can also block nda model names, but mstack ships no list, because a list in this repo would leak the names. to add one, prompt your agent: "add these model names to ~/.cursor/mstack/leak-patterns.txt, one case-insensitive regex per line." the file stays on your machine, and a plugin update never overwrites it.
  • the review-group steps need local cursor transcripts. scripts/review-group-gate.py reads each reviewer's reply from its own subagent transcript under the workspace's agent-transcripts/ directory, so a pr review runs in a local chat, not a cloud agent.
  • the merge gate depends on the review skill's layout. the gate re-runs the bash block under that skill's ## Step 8 heading. if upstream changes the layout of that section, the gate fails closed and reviews stop until you update mstack.
  • triton is not fully compatible yet. a triton pr gets the same rule set, gates, review group, and conventions check as aiter and flydsl, in a snapshot of your triton checkout. two gaps remain:
    • the skill bound to the pr.validate skill function does not recognize triton's repo layout, so the gpu base-vs-head check always reports INCONCLUSIVE. runtime evidence comes from the pr's own tests through the bench.run skill function, and this evidence is advisory.
    • the review rules come from aiter's review history. the triton rule families target triton kernels (tl.load masks, launch configs, accumulator precision). they do not target the compiler's c++ and mlir passes, and those passes get only the generic rules.

not shipped here

a few things ateam-mode references but doesn't bundle:

  • the kernel skills bound to its skill functions (listed in skill-functions.md) live in your skills dir (the skills resource), not in this plugin. python3 scripts/check.py checks that each one resolves. it reads the dir from $MSTACK_SKILLS_DIR, else from the skills table of ~/.cursor/mstack/env.md, and skips the check with a note when neither is set. --no-skills skips it on purpose.
  • ponytail is optional and separate. when you install it and it is on, ateam-mode passes its level to each code delegate, since a cursor subagent does not receive it from the hook. ponytail cuts code, never a playbook step or a verification gate. /ponytail off turns it off for mstack too.
  • /create-skill is a cursor built-in. cursor also ships a built-in /babysit; inside ateam-mode, the babysit playbook supersedes it for pr-status requests.

why are there no planning skills?

cursor already has a plan mode, and it works with mstack. but personally, i don't believe in planning. the best spec is code. if you do want to make a plan, /ateam-mode covers it, but it's not a default.

make it yours

ateam-mode is one engineer's style. you may not want exactly that.

type /automate-me. it mines your recent transcripts, drafts a <your-name>-mode skill from how you've worked, and routes through mstack underneath. you keep mstack as the base and end up with your own routing skill alongside ateam-mode.

models are configurable too. type /setup-mstack. it detects the models you have access to and writes a small always-applied rule mapping each role (code, judgment, the list roles) to a model. every skill reads it and falls back to sensible defaults when the rule is absent, so you override only what you want.

when a default changes, a rule written before the change still pins the old default. delete those role lines, or delete the file, then run /setup-mstack again. a rerun keeps any role whose model differs from the default.

Upstream

mstack is a fork of pstack 0.15.20 by poteto (Lauren Tan), MIT licensed. The pristine import is commit 1491916. LICENSE keeps the upstream copyright notice.

To sync with upstream:

git clone https://github.com/cursor/plugins /tmp/cursor-plugins
mkdir /tmp/mstack-import && git archive 1491916 | tar -x -C /tmp/mstack-import
diff -ru /tmp/mstack-import /tmp/cursor-plugins/pstack

Port the changes you want by hand. Upstream paths use pstack, poteto-mode, poteto-agent, poteto-help, and setup-pstack. Map them to mstack, ateam-mode, ateam-agent, ateam-help, and setup-mstack.

license

MIT