Skip to content

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

Open
ryanbonial wants to merge 4 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 4 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 content only; no runtime or CLI logic changes.

Overview
Adds onboarding and agent-oriented docs to the app-quickstart and app-sanity-ui CLI scaffolds so new SDK apps are not a bare hello-world with no next steps.

Each template now ships a README.md (commands, config locations, docs links with utm_source=readme), AGENTS.md (project shape, dev/Dashboard flow, common SDK pitfalls: handles, Suspense, useEditDocument, MCP get_sanity_rules), and .claude/skills/sanity-app-sdk/SKILL.md (hook guide and examples; sanity-ui variant adds Sanity UI notes). The @sanity/cli minor changeset records the release.

ExampleComponent in both templates is updated to point at useDocuments + <Suspense> instead of generic “add a component” hints, adds links to App SDK docs / API reference / SDK Explorer, and fixes the stale App.tsx|jsx wording (templates are TS-only). Quickstart also gets minor .example-links styling.

Reviewed by Cursor Bugbot for commit 914e334. 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 (8d5dd54c)

@sanity/cli

Metric Value vs main (8d5dd54)
Internal (raw) 2.7 KB -
Internal (gzip) 1.0 KB -
Bundled (raw) 11.16 MB -
Bundled (gzip) 2.10 MB -
Import time 777ms +2ms, +0.3%

bin:sanity

Metric Value vs main (8d5dd54)
Internal (raw) 782 B -
Internal (gzip) 423 B -
Bundled (raw) 9.87 MB -
Bundled (gzip) 1.78 MB -
Import time 2.05s +6ms, +0.3%

🗺️ 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 (8d5dd54c)

Metric Value vs main (8d5dd54)
Internal (raw) 106.7 KB -
Internal (gzip) 26.7 KB -
Bundled (raw) 21.72 MB -
Bundled (gzip) 3.46 MB -
Import time 689ms +2ms, +0.3%

🗺️ 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 (8d5dd54c)

Metric Value vs main (8d5dd54)
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

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Coverage Delta

No covered files changed in this PR.

Overall Coverage

Metric Coverage
Statements 74.4% (±0%)
Branches 64.3% (±0%)
Functions 68.9% (- 0.1%)
Lines 75.0% (±0%)

@ryanbonial ryanbonial requested a review from cngonzalez June 15, 2026 16:00
cngonzalez
cngonzalez previously approved these changes Jun 16, 2026

@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!)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good call. Added

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