feat(mastra): add use-mastra workflow skill#161
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new use-mastra workflow skill designed to guide agents toward version-accurate documentation within node_modules. It includes detailed recipes for agents, workflows, and RAG pipelines, along with a common errors reference and a package map. Feedback indicates that the placement of these files under .agents/skills/ violates the repository style guide, which designates that path as read-only for externally managed skills. Additionally, the changelog entry for version 1.3.0 requires formatting adjustments to match the existing project style.
There was a problem hiding this comment.
3 issues found across 6 files
Confidence score: 3/5
- There is a concrete user-impact risk in
plugins/mastra/.agents/skills/use-mastra/references/agents-and-workflows.md: the guide still shows removed top-levelthreadId/resourceIdinstead ofmemory: { thread, resource }(severity 7/10, high confidence). - The same file documents
createTool()with reversed argument order (validated input should be first, execution context second), which can lead readers to implement tools incorrectly. - The vector-query recipe currently points to
createToolinstead ofcreateVectorQueryToolfrom@mastra/rag, so example code may fail or require rework for consumers following the docs. - Pay close attention to
plugins/mastra/.agents/skills/use-mastra/references/agents-and-workflows.md- multiple API-usage examples appear outdated or incorrect and could mislead downstream implementations.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="plugins/mastra/.agents/skills/use-mastra/references/agents-and-workflows.md">
<violation number="1" location="plugins/mastra/.agents/skills/use-mastra/references/agents-and-workflows.md:23">
P2: Take the validated input as the first argument; execution context is the second argument in `createTool()`.</violation>
<violation number="2" location="plugins/mastra/.agents/skills/use-mastra/references/agents-and-workflows.md:56">
P1: Use `memory: { thread, resource }` here instead of the removed top-level `threadId`/`resourceId` fields.</violation>
<violation number="3" location="plugins/mastra/.agents/skills/use-mastra/references/agents-and-workflows.md:133">
P2: Use `createVectorQueryTool` from `@mastra/rag` here; `createTool` is the wrong helper for the vector-query recipe.</violation>
</file>
Architecture diagram
sequenceDiagram
participant User
participant AI as AI Agent (Claude Code)
participant Skill as use-mastra Skill
participant LocalFS as Local node_modules
participant Remote as mastra.ai (Remote)
User->>AI: Ask to build Agent/Workflow
AI->>Skill: NEW: Trigger on "Mastra", "@mastra/core", etc.
Note over AI,Skill: Skill redirects AI to ground knowledge in local version
AI->>LocalFS: Verify installation (ls node_modules/@mastra/core)
LocalFS-->>AI: Package exists
AI->>LocalFS: Read installed version (package.json)
LocalFS-->>AI: Version info (e.g., 1.27.0)
AI->>LocalFS: NEW: Fetch bundled docs (dist/docs/SKILL.md)
alt Bundled docs found
LocalFS-->>AI: Version-accurate API & Reference MD
else Missing or remote-only (e.g. @mastra/observability)
AI->>Remote: Fetch fallback (https://mastra.ai/llms.txt)
Remote-->>AI: Latest documentation
end
Note over AI,LocalFS: Debugging Flow (if code fails)
AI->>Skill: NEW: Check references/common-errors.md
Skill-->>AI: Symptom -> Cause -> Fix map
AI->>LocalFS: NEW: Grep error string in dist/ source
LocalFS-->>AI: Line numbers and context
AI->>User: Generate version-accurate Mastra code/fix
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Add a hand-written `use-mastra` skill under `plugins/mastra/.agents/skills/use-mastra/` that mirrors Vercel's `use-ai-sdk` workflow skill in structure and intent. Teaches coding agents to install the relevant `mastra` / `@mastra/*` package and read the docs shipped at `node_modules/<pkg>/dist/docs/SKILL.md` (and `references/*.md`) instead of relying on stale training-data APIs. Confirmed via `npm pack` that these packages ship `dist/docs/`: mastra, @mastra/core, @mastra/memory, @mastra/rag, @mastra/evals, @mastra/deployer, @mastra/server, @mastra/pg, @mastra/libsql, @mastra/mcp. Only @mastra/observability is remote-only. Keeps the existing `mastra` primer skill (v2.0.0, installed via skills.sh from `mastra-ai/skills`) untouched; `use-mastra` is the task-triggered workflow complement. Bumps plugins/mastra from 1.2.0 to 1.3.0 and logs the change in CHANGELOG.md (matching PR #159's format).
4826885 to
b8b4eb5
Compare
- Update agent.generate() calls to nested memory: { thread, resource }
API instead of the deprecated top-level threadId/resourceId fields
(agents-and-workflows.md and common-errors.md).
- Use createVectorQueryTool from @mastra/rag instead of createTool for
the vector-query recipe in agents-and-workflows.md.
Addresses cubic-dev-ai P1 + P2 suggestions on PR #161.
#164) * fix(mastra): move use-mastra skill to skills/ per repo convention The hand-written use-mastra skill was added at .agents/skills/use-mastra/ in #161, but .agents/skills/ is reserved for vendor-managed skills.sh output tracked in skills-lock.json (see CLAUDE.md). Move it to the default skills/ location and switch the plugin.json skills field to array form ["./skills/", "./.agents/skills/"] so both paths load. No skill content changed. Refs #161 * fix(better-auth): move use-better-auth skill to skills/ per repo convention The hand-written use-better-auth skill was added at .agents/skills/use-better-auth/ in #159, but .agents/skills/ is reserved for vendor-managed skills.sh output tracked in skills-lock.json (see CLAUDE.md). Move it to the default skills/ location and switch the plugin.json skills field to array form ["./skills/", "./.agents/skills/"] so both paths load. No skill content changed. Refs #159 * chore: revert manual CHANGELOG and version bumps (release-please owns them) Both CHANGELOG.md and plugin.json version are auto-managed by release-please for plugins/* (see release-please-config.json extra-files: [{ jsonpath: "$.version" }] and existing release PRs #158/#160/#163). Manual edits race with the next release PR. Skill relocations and the plugin.json `skills` array change remain intact — they're the actual fix release-please will pick up via the fix(...) commits already on this branch.
* feat(zod): add use-zod skill plugin Hand-written workflow skill for Zod schema validation, mirroring the mastra plugin pattern from #161. Single trigger-heavy SKILL.md plus three references (versions, schemas, parsing-and-errors) covering both Zod v3 and v4 with inline migration callouts. Key v3 → v4 differences surfaced: - err.format() / err.flatten() → z.treeifyError() / z.flattenError() - separate { message, errorMap } → unified { error } param - z.lazy + ZodType<T> annotation → property getters for recursion - .superRefine() (deprecated) → .check() - new in v4: z.codec, z.prettifyError, .overwrite, zod/mini No MCP server (zod has no official docs MCP server). Skills-only plugin with skills: ['./skills/']. * chore: register zod plugin in marketplace and release-please - .claude-plugin/marketplace.json: add zod entry pointing to ./plugins/zod - release-please-config.json: add plugins/zod with simple release-type and extra-files jsonpath $.version for plugin.json bumps - README.md: append Zod section after Portless mirroring existing entries * feat(zod): use ask CLI as primary source for version-accurate docs Mirrors the use-better-auth pattern: lead with `ask src zod` / `ask docs zod` to read the lockfile-pinned source (with comments and tests), demoting node_modules/zod/dist to a fallback for environments where ask isn't installed. - New 'Finding Documentation' section in SKILL.md showing the SRC=$(ask src zod) idiom for reading docs, verifying symbols, and finding canonical examples in tests - versions.md 'When in doubt' switched to ask-first verification with explicit @Version pinning examples for v4.3.6 and v3.25.76 - 'When typecheck or runtime fails' debug snippet now greps $(ask src zod)/packages/zod/src instead of node_modules/zod/dist * fix(zod): correct .superRefine vs .check guidance The v4 docs (api.mdx@v4.3.6) present .superRefine() as the standard recommended API for multi-issue refinements, with .check() as a lower-level, more verbose alternative for performance-sensitive paths. The skill had this inverted in 6 places, claiming .superRefine was deprecated. - SKILL.md: rewrite the 'training-data miswritten' bullet to describe .superRefine as recommended, .check as lower-level - SKILL.md: drop the bogus 'flagged as deprecated' debug bullet - SKILL.md: include both .superRefine and .check (low-level) in the v4 row of the version-detection table - versions.md: rewrite the multi-issue refinement cheatsheet row - versions.md: rewrite the 'New in v4' bullet for .check - schemas.md: invert the multi-issue refinement example so .superRefine leads as canonical, .check follows as lower-level - schemas.md: drop the 'avoid .superRefine in v4' bullet entirely Caught by review-documentation-analyzer in /review:code-review-loop iteration 1. * chore: apply AI code review suggestions Apply 3 of 4 review thread suggestions on PR #168: - plugin.json: author restructured to upstream-org form ('Zod' / https://github.com/colinhacks/zod) per the mastra and better-auth precedent (@gemini-code-assist) - SKILL.md: Zod 4 release year corrected from 2026 to 2025 (v4.0.1 published 2025-07-10) (@cubic-dev-ai) - versions.md: recursive-schema example fixed — replaced undefined 'Self' placeholder with a self-referencing 'Tree' variable so the snippet works as written (@cubic-dev-ai) Skipped: @cubic-dev-ai's claim that '.loose()' is not a v4 object API. Verified false against zod@v4.3.6 classic/schemas.ts:1269 ('inst.loose = () => inst.clone(...)'). The .loose() instance method exists alongside z.looseObject({...}) — both are valid.
Summary
Adds a hand-written
use-mastraworkflow skill underplugins/mastra/.agents/skills/use-mastra/that mirrors Vercel'suse-ai-sdkand follows the pattern established in #159 (use-better-auth).The skill redirects coding agents to version-accurate documentation shipped inside the
mastra/@mastra/*npm packages atnode_modules/<pkg>/dist/docs/SKILL.md+references/*.md, instead of relying on stale training-data APIs.What's new
plugins/mastra/.agents/skills/use-mastra/SKILL.md— trigger-heavy frontmatter (createWorkflow,createTool,createStep,@mastra/core,semantic recall,provider/model, etc.); sections: Prerequisites → Don't-trust-knowledge → Finding Documentation → Package Map → Building Agents & Workflows → When Typecheck Fails → Relationship to the existingmastraprimer → References.references/packages.md— table of the 10 Mastra packages confirmed (vianpm pack) to shipdist/docs/SKILL.md, plus@mastra/observabilityflagged as remote-only.references/agents-and-workflows.md— canonical recipes for agent+tools+memory, workflow+steps+.commit(), RAG pipeline; each ends with the verification command to read againstdist/docs/.references/common-errors.md— 11 symptom → cause → fix entries (ESM config, tool-registration mismatch, missing.commit(), memory without storage, semantic recall without vector/embedder, invalid model string, suspension/resume, etc.).What's not touched
plugins/mastra/.agents/skills/mastra/— the existing v2.0.0 primer installed via skills.sh frommastra-ai/skillsstays byte-identical.plugins/mastra/skills-lock.json— unchanged.Versioning
Bumps
plugins/mastrafrom1.2.0→1.3.0and prepends a[1.3.0] - 2026-04-23entry toCHANGELOG.mdmatching the format used in #159.Verification
claude plugin validate plugins/mastra/— ✔ passes.npm packthatmastra@1.6.2,@mastra/core@1.27.0,@mastra/memory@1.17.0,@mastra/rag@2.2.1,@mastra/evals@1.2.1,@mastra/deployer@1.27.0,@mastra/server@1.27.0,@mastra/pg@1.9.2,@mastra/libsql@1.9.0,@mastra/mcp@1.5.1all shipdist/docs/SKILL.md+dist/docs/references/*.md.@mastra/observability@1.10.0ships no bundled docs — flagged as remote-only inreferences/packages.md.mastraskill directory has an emptygit diff --stat.Related
use-better-authunderplugins/better-auth/.agents/skills/use-better-auth/).use-ai-sdk.Summary by cubic
Add a new
use-mastraworkflow skill that routes coding agents to versioned Mastra docs innode_modulesand provides concise recipes and fixes. The existingmastraprimer stays as-is; plugin bumped to1.3.0.New Features
plugins/mastra/.agents/skills/use-mastra/withSKILL.mdandreferences/agents-and-workflows.md,common-errors.md,packages.md.node_modules/<pkg>/dist/docs/formastraand@mastra/*(except@mastra/observability, which is remote-only).memory: { thread, resource }inagent.generate()and switch the vector-query recipe tocreateVectorQueryToolfrom@mastra/rag.Refactors
.claude/agent-memory/review-review-cubic-reviewer/*notes recording a clean cubic review pass for PR feat(mastra): add use-mastra workflow skill #161.Written for commit 388bf88. Summary will update on new commits.