Skip to content

feat(mastra): add use-mastra workflow skill#161

Merged
amondnet merged 3 commits intomainfrom
amondnet/use-mastra-skill
Apr 23, 2026
Merged

feat(mastra): add use-mastra workflow skill#161
amondnet merged 3 commits intomainfrom
amondnet/use-mastra-skill

Conversation

@amondnet
Copy link
Copy Markdown
Contributor

@amondnet amondnet commented Apr 23, 2026

Summary

Adds a hand-written use-mastra workflow skill under plugins/mastra/.agents/skills/use-mastra/ that mirrors Vercel's use-ai-sdk and 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 at node_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 existing mastra primer → References.
  • references/packages.md — table of the 10 Mastra packages confirmed (via npm pack) to ship dist/docs/SKILL.md, plus @mastra/observability flagged 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 against dist/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 from mastra-ai/skills stays byte-identical.
  • plugins/mastra/skills-lock.json — unchanged.
  • No new scripts, sync automation, marketplace entries, or submodules.

Versioning

Bumps plugins/mastra from 1.2.01.3.0 and prepends a [1.3.0] - 2026-04-23 entry to CHANGELOG.md matching the format used in #159.

Verification

  • claude plugin validate plugins/mastra/ — ✔ passes.
  • Verified via npm pack that mastra@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.1 all ship dist/docs/SKILL.md + dist/docs/references/*.md.
  • @mastra/observability@1.10.0 ships no bundled docs — flagged as remote-only in references/packages.md.
  • Existing mastra skill directory has an empty git diff --stat.

Related


Summary by cubic

Add a new use-mastra workflow skill that routes coding agents to versioned Mastra docs in node_modules and provides concise recipes and fixes. The existing mastra primer stays as-is; plugin bumped to 1.3.0.

  • New Features

    • Add plugins/mastra/.agents/skills/use-mastra/ with SKILL.md and references/agents-and-workflows.md, common-errors.md, packages.md.
    • Route agents to node_modules/<pkg>/dist/docs/ for mastra and @mastra/* (except @mastra/observability, which is remote-only).
    • Update examples to use nested memory: { thread, resource } in agent.generate() and switch the vector-query recipe to createVectorQueryTool from @mastra/rag.
  • Refactors

Written for commit 388bf88. Summary will update on new commits.

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
claude-code-plugins Ready Ready Preview, Comment Apr 23, 2026 2:24pm

Request Review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread plugins/mastra/.agents/skills/use-mastra/SKILL.md
Comment thread plugins/mastra/CHANGELOG.md Outdated
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-level threadId/resourceId instead of memory: { 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 createTool instead of createVectorQueryTool from @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
Loading

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread plugins/mastra/.agents/skills/use-mastra/references/agents-and-workflows.md Outdated
Comment thread plugins/mastra/.agents/skills/use-mastra/references/agents-and-workflows.md Outdated
@amondnet amondnet self-assigned this Apr 23, 2026
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).
- 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.
@amondnet amondnet merged commit dd0ad46 into main Apr 23, 2026
7 checks passed
@amondnet amondnet deleted the amondnet/use-mastra-skill branch April 23, 2026 14:35
@pleaeai-bot pleaeai-bot Bot mentioned this pull request Apr 23, 2026
amondnet added a commit that referenced this pull request Apr 29, 2026
#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.
@pleaeai-bot pleaeai-bot Bot mentioned this pull request Apr 29, 2026
amondnet added a commit that referenced this pull request Apr 29, 2026
* 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant