Skip to content

feat(sdk): add readme, agents.md, and claude skill with docs links to app templates#1303

Open
ryanbonial wants to merge 2 commits into
mainfrom
SDK-1744/improve-sdk-templates
Open

feat(sdk): add readme, agents.md, and claude skill with docs links to app templates#1303
ryanbonial wants to merge 2 commits into
mainfrom
SDK-1744/improve-sdk-templates

Conversation

@ryanbonial

@ryanbonial ryanbonial commented Jun 12, 2026

Copy link
Copy Markdown
Member

Description

Running npx sanity init --template app-quickstart (or app-sanity-ui) currently scaffolds a bare hello-world app with no README, no agent guidance, and an example component that gives no pointers to the App SDK docs. Users, and the LLM agents many of them start these apps with, are left to guess what to do next.

This PR adds lightweight orientation to both app templates without adding boilerplate code:

  • README.md in each template root: what an SDK app is, the dev/build/deploy commands, where project and dataset config lives, and docs links (with ?utm_source=readme, matching the existing studio template READMEs).
  • AGENTS.md in each template root: guidance for coding agents picking up a fresh scaffold. Covers what the project is, key files, commands, the SDK concepts agents commonly get wrong (document handles, Suspense, hooks inside SanityApp), and a pointer to the Sanity MCP server's get_sanity_rules tool with the app-sdk rule.
  • .claude/skills/sanity-app-sdk/SKILL.md in each template: an on-demand skill with the hook-picking guide, document handle and editing patterns with code examples, and docs links. The sanity-ui variant also covers Sanity UI usage.
  • Updated ExampleComponent in both templates: replaces the generic "create a component" hint with a concrete next step (useDocuments) and links to the App SDK docs, the API reference, and the SDK Explorer. Also fixes a stale src/App.tsx|jsx mention (app templates are TypeScript-only).

The docs are careful to describe the dev flow accurately: npm run dev starts a local server, but the app only renders inside the Sanity Dashboard. The CLI prints a Dashboard URL, and viewing it requires a signed-in Sanity account.

Solves SDK-1744: https://linear.app/sanity/issue/SDK-1744/improve-sdk-app-templates-with-docs-links-readme-and-agent-guidance

What to review

  • All changes are template files under packages/@sanity/cli/templates/app-quickstart/ and packages/@sanity/cli/templates/app-sanity-ui/. No CLI code changes: bootstrapLocalTemplate.ts copies template directories verbatim (including dotfolders), and the package's npm files field already ships ./templates.
  • Check the factual claims in the new docs against CLI behavior (commands, port 3333, SANITY_APP_ env prefix, Dashboard dev flow) and the SDK guidance against @sanity/sdk-react (handles, Suspense, useEditDocument).
  • To see the result end to end, build the CLI and scaffold locally: pnpm build:cli, then run sanity init --template app-quickstart and confirm the README, AGENTS.md, and .claude/ folder land in the output directory.

Testing

No new automated tests. The added files are static template content copied verbatim during scaffolding; the init unit tests mock bootstrapTemplate and the e2e tests assert specific files exist, so nothing breaks. The factual claims in the docs were verified against the CLI source (dev server flow, generated package.json scripts, sanity.cli.ts generation, Vite env prefix) and the SDK source (hook signatures and Suspense behavior), and all linked docs URLs were checked to resolve.


Note

Low Risk
Static template and documentation-only changes; no runtime or CLI behavior modifications.

Overview
Adds onboarding and agent guidance to the app-quickstart and app-sanity-ui CLI scaffolds so new SDK apps ship with orientation instead of a bare hello-world.

Each template now includes a README (commands, config locations, docs links with ?utm_source=readme), AGENTS.md (project shape, dev/Dashboard flow, common SDK pitfalls like handles, Suspense, and useEditDocument), and a .claude/skills/sanity-app-sdk/SKILL.md hook/editing cheat sheet (Sanity UI notes on the UI template). The example components steer users toward useDocuments as the next step, add links to App SDK docs, API reference, and SDK Explorer, and drop the stale App.tsx|jsx wording.

A changeset records a minor bump for @sanity/cli; template files are copied verbatim at init—no bootstrap logic changes.

Reviewed by Cursor Bugbot for commit 40cde12. Bugbot is set up for automated code reviews on this repo. Configure here.

@ryanbonial ryanbonial requested a review from a team as a code owner June 12, 2026 22:20
@ryanbonial ryanbonial requested review from binoy14 and removed request for a team June 12, 2026 22:20
@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

📦 Bundle Stats — @sanity/cli

Compared against main (8985b42f)

@sanity/cli

Metric Value vs main (8985b42)
Internal (raw) 2.1 KB -
Internal (gzip) 799 B -
Bundled (raw) 11.13 MB -
Bundled (gzip) 2.10 MB -
Import time 884ms -4ms, -0.4%

bin:sanity

Metric Value vs main (8985b42)
Internal (raw) 782 B -
Internal (gzip) 423 B -
Bundled (raw) 9.87 MB -
Bundled (gzip) 1.77 MB -
Import time 1.96s -57ms, -2.8%

🗺️ View treemap · Artifacts

Details
  • Import time regressions over 10% are flagged with ⚠️
  • Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.

📦 Bundle Stats — @sanity/cli-core

Compared against main (8985b42f)

Metric Value vs main (8985b42)
Internal (raw) 98.2 KB -
Internal (gzip) 23.3 KB -
Bundled (raw) 21.70 MB -
Bundled (gzip) 3.45 MB -
Import time 784ms -13ms, -1.6%

🗺️ View treemap · Artifacts

Details
  • Import time regressions over 10% are flagged with ⚠️
  • Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.

📦 Bundle Stats — create-sanity

Compared against main (8985b42f)

Metric Value vs main (8985b42)
Internal (raw) 908 B -
Internal (gzip) 483 B -
Bundled (raw) 931 B -
Bundled (gzip) 491 B -
Import time ❌ ChildProcess denied: node -
Details
  • Import time regressions over 10% are flagged with ⚠️
  • Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.

@github-actions

Copy link
Copy Markdown
Contributor

Coverage Delta

No covered files changed in this PR.

Overall Coverage

Metric Coverage
Statements 87.0% (- 0.5%)
Branches 77.1% (- 0.5%)
Functions 85.1% (- 1.4%)
Lines 87.4% (- 0.5%)

@ryanbonial ryanbonial requested a review from cngonzalez June 15, 2026 16:00

@cngonzalez cngonzalez left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

One nit about suspense, otherwise LGTM

<SanityApp config={sanityConfigs}>
<YourComponent />
</SanityApp>`}</pre>
const {data} = useDocuments({documentType: 'yourType'})`}</pre>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This might be a good opportunity to enforce / encourage Suspense usage (we've been getting dinged on it a bit in AILF runs. I know it's mentioned in the skill too but might be nice!)

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.

2 participants