/cc-authoring:claude-workflow-authoring-gotchasfrom cc-authoring
Four gotchas that bite when authoring Claude Code Workflow scripts (the `Workflow` tool's `.js` files with `export const meta`). Use when: (1) Workflow tool call fails immediately with `Invalid workflow script: meta must be a pure literal: non-literal node type in meta: BinaryExpression`; (2) the script's `args` field arrives as `undefined`/`null`/JSON-string even though the caller passed an object; (3) you're starting a new Workflow script and want to skip the trial-and-error round on these traps; (4) the workflow returns ready/green but agents resolved a DIFFERENT file than the one passed via args — a literal "undefined" in a prompt made them self-heal onto a substitute source. Covers the pure-literal-meta requirement (no string concat, no template literals, no variable references inside the `meta` literal), the args delivery contract (normalize for object / JSON-string / undefined shapes), informative-error patterns for missing required args (multi-line throw including the expected Workflow tool invocation), and the silent wrong-ground-truth cascade that unnormalized args cause downstream.
Trending skills
7-day visitors to each skill page
Ships in cc-authoring. 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.
Authoring Workflow scripts has four small traps that the Workflow tool's error messages don't fully explain. Each takes a failed invocation round-trip to discover. They compound: fixing one surfaces the next.
meta must be a pure literal: non-literal node type in meta: BinaryExpression (or TemplateLiteral, or Identifier).args.<field> is required even though the caller passed args: {<field>: "value"} in the tool call.meta must be a pure literalThe Workflow runtime parses the meta block via AST and rejects anything
that isn't a literal value. Forbidden node types include BinaryExpression
(string concat), TemplateLiteral with substitutions, Identifier
(variable reference), and CallExpression (function call).
// BAD — BinaryExpression
description: 'Foo ' + 'bar',
// BAD — TemplateLiteral with substitutions
description: `Foo ${something}`,
// BAD — variable reference (Identifier)
description: DESCRIPTION_CONST,
// BAD — function call
description: makeDescription(),
Allowed: a single string literal (any length), object literals, array
literals, number/boolean literals. If the string is long, keep it on a
single line — long lines are fine. Do NOT break it across multiple
quoted pieces and concatenate; that produces a BinaryExpression.
args delivery contractPer the Workflow tool docs, args is passed verbatim. Empirically
observed shapes in the wild:
undefined — caller forgot the args: key, or some other delivery
failure mode.Robust pattern at the top of every parametrized script:
let opts = args
if (typeof opts === 'string') {
try { opts = JSON.parse(opts) } catch { opts = {} }
}
opts = opts || {}
When opts.X is undefined, throw a multi-line error that includes:
Got args=${JSON.stringify(args)} — surfaces what the runtime actually delivered.args=undefined likely means the caller forgot the args: key.if (!opts.workingDir || typeof opts.workingDir !== 'string') {
throw new Error(
`args.workingDir is required (absolute path).
Got args=${JSON.stringify(args)}. If args is undefined the caller likely forgot the \`args:\` key.
Expected tool invocation:
Workflow({
scriptPath: "<this-file>",
args: { workingDir: "/abs/path" }
})`,
)
}
Observed 2026-07-11. When an unnormalized args.x interpolates as the
literal string "undefined" into an agent prompt (e.g. "read the CV
source file at: undefined"), capable agents do NOT fail — they self-heal
by searching the filesystem for a plausible substitute (here: an outdated
resume PDF found on disk instead of the intended master markdown). Every
downstream verifier then validates faithfully against the substituted
source, producing a confident all-green verdict on wrong ground truth.
The workflow returns ready: true; only cross-checking the verifier
NOTES against what the orchestrator knows (source-path mismatch,
contradicting facts) exposes it.
Mitigations:
args at all.if (!opts.cvPath) throw new Error('cvPath missing — args arrived as ' + typeof args)
— a thrown workflow is cheaper than a confidently wrong one.ready: true.Invalid workflow script: meta must be a pure literal no longer appears.args in three shapes via unit tests using the harness from the claude-workflow-tdd-harness skill. All three should reach the first agent call (or throw the informative error in the undefined case).undefined — none should reach an agent.Reference implementation:
nautilus-competition/plugins/nautilus-competition/workflows/competition-single-team-driver.js
meta (single-line strings, no concat, no template literals, no variable references).opts = args, JSON-parse if string, opts || {}) plus informative throws that surface the actual args shape and show the expected tool invocation.Do not copy that file verbatim — copy the pattern.
args=undefined delivery failure observed in this session was never
explained empirically — a retry with the same JSON shape went through.
Defensive normalization + informative throws are the durable fix;
diagnosing the upstream delivery bug is a separate investigation.claude-workflow-tdd-harness to lock the
gotchas in as tests instead of trial-and-error against the live
Workflow tool.[[claude-workflow-tdd-harness]] — testing pattern that
catches these traps locally before any live Workflow call.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub cajias/claude-skills --plugin cc-authoring16 skills in this plugin
/apm-marketplace-authoring-gotchasEight APM-marketplace-authoring gotchas discovered during real
migrations from hand-authored .claude-plugin/marketplace.json to
APM-managed and from CC-native plugin authoring.
Use when: (1) running APM's packaging step (with or without
`--dry-run`) or its marketplace-check command in a repo with an
`apm.yml`; (2) wiring CI for an APM
marketplace; (3) the CI staleness check (repack, then `git diff
--quiet`) fails despite a clean local; (4) prettier reformats
`marketplace.json` after APM's packer writes it; (5) APM exit code 1 on
local-path-only marketplaces; (6) confused by `packages:` in apm.yml
vs `plugins:` in marketplace.json; (7) commitlint rejects a commit
with `footer-leading-blank` despite no apparent footer; (8) `apm
compile -t claude` exits 0 with zero output and no compiled plugin
appears; (9) husky+lint-staged pre-commit blocks the FIRST marketplace
commit with markdownlint `MD040/fenced-code-language` errors on a
SKILL.md file copied verbatim from `~/.claude/skills/`. The gotchas
form a chain — fixing one usually surfaces the next.
/apm-plugin-distribution-pathsCanonical authoring layout for an APM (microsoft/apm)
package, plus the decision matrix for whether you need a `marketplace:` block.
Use when: (1) you've run `apm init` and are unsure where SKILL.md / agent .md
/ command .md files belong (answer: under `.apm/`, NOT at repo root); (2)
you've authored CC-native files at `commands/agents/skills/` at repo root and
wonder if that's "right" (it works as fallback layout #3 "Claude plugin", but
it's not the canonical authoring path); (3) you're trying to choose between
the three layouts APM recognizes (one-skill repo, multi-primitive `.apm/`,
Claude plugin); (4) `apm targets` fails with "No such command" in CLI 0.12.1
(subcommand doesn't exist); (5) `apm validate` fails with "No such command"
in CLI 0.12.1 (use APM's packaging command in dry-run mode instead); (6) wondering whether
`apm compile -t claude` will generate output for a hand-authored CC-native
plugin (it won't; it's a no-op for layout #3); (7) wondering if you need a
`marketplace:` block in apm.yml (you don't, for a single-plugin repo).
Covers the canonical `.apm/` source layout, the source-to-plugin remap
table, the three-layout choice, and the four distribution paths.
/autoresearch-is-code-metric-optimizerThe `/autoresearch:autoresearch` Claude Code skill is a CODE-METRIC
OPTIMIZER (modify → verify → keep/discard loop). Use when: (1) you are
about to invoke `/autoresearch:autoresearch` to do literature / web
research (it does NOT fetch papers, search the web, or synthesize cited
reports — use `/deep-research` for that); (2) you have a measurable
target (test pass rate, perf delta, p&l, win rate, composite metric)
AND code-or-config that can be modified to hit it — that IS the right
use case, including non-traditional optimization targets like trading
strategy backtest results; (3) you're confused about when to reach for
the BASE skill vs the sub-skills `:reason` (adversarial debate) or
`:probe` (8-persona interrogation) — the base skill is for iterative
optimization with a clear verify function; the sub-skills are for
qualitative investigation when there is no verify function.
/cc-hooks-main-vs-subagentHow a Claude Code PreToolUse/PostToolUse hook can tell whether a tool call
came from the MAIN conversation thread or from a SUBAGENT (Task/Agent tool),
plus the gotchas of testing hooks via headless `claude -p`. Use when:
(1) building a hook that should apply only to the main thread (e.g.
orchestrator-only enforcement that denies Edit/Write in main but allows
subagents) or only to subagents; (2) wondering if hook input contains an
is_subagent / agent indicator — it does, but it's undocumented;
(3) a hook behaves differently than expected under `claude -p` because
CLAUDE_CODE_ENTRYPOINT is sdk-cli there and `env CLAUDE_CODE_ENTRYPOINT=cli`
does NOT survive (the CLI overwrites it); (4) a headless hook test shows
"Claude requested permissions ... but you haven't granted it yet" instead of
the hook's deny reason — the permission gate fires before the hook surfaces;
(5) you need to force the interactive code path in a headless test (use a
--settings file with an env block).
/cc-mid-session-registry-stalenessFix for two Claude Code mid-session staleness traps that fail Workflow runs
instantly (<15ms). Use when: (1) a Workflow agent() call fails with
"agent type '<name>' not found" listing only plugin/built-in agents, even
though .claude/agents/<name>.md exists with valid frontmatter — the agent
registry only loads .claude/agents/ at session START, so agent files created
mid-session are not resolvable via agentType/subagent_type until restart;
(2) re-invoking a saved workflow via Workflow({name}) runs STALE code after
you edited .claude/workflows/<name>.js — name resolution serves a cached
snapshot, so mid-session edits never reach it. Both failures look like your
code is wrong when it's actually registry caching. Fixes: launch via
Workflow({scriptPath: <live file path>}) to bypass the name cache, and
design workflow scripts with a registry-independent persona fallback
(prompt the agent to Read its own .claude/agents/<name>.md and adopt the
role) toggled by an arg like useAgentTypes:false.
/cc-plugin-cache-multi-version-not-recordedFix for Claude Code startup warning `Plugin "<name>" not cached at (not
recorded) — run /plugins to refresh`. Use when: (1) Claude Code prints a
`plugin-cache-miss` warning whose installPath is the literal string
`(not recorded)`; (2) `claude plugin list` shows the plugin as installed
with a valid version, AND
`~/.claude/plugins/installed_plugins.json` has a real `installPath` for
it, yet the warning still fires every session; (3) running `/plugins` or
reinstalling the plugin doesn't clear the warning; (4) the plugin's
cache directory at
`~/.claude/plugins/cache/<marketplace>/<plugin>/` contains TWO (or more)
version subdirectories — typically an old SHA-prefix dir and the
current one — left over from an in-place marketplace SHA bump.
Root cause: the Claude Code cache resolver (`fk8` in the binary) skips
any cache parent whose subdir count `!== 1`, returns null, and the
install-record fallback emits the warning with the hardcoded sentinel
`installPath: "(not recorded)"`. The phrase is NOT a missing config
field — it's a literal string in the error branch. Fix: delete every
stale version subdir under that plugin so exactly one remains (the one
recorded in `installed_plugins.json`).