Official agent skill

Docs Sandpack

by reactjs in reactjs/ar.react.dev

A skill your agent uses when adding interactive code examples to React docs.

OfficialCC-BY-4.0Auto-check passed

Install Docs Sandpack

skills CLI
$ npx skills add reactjs/ar.react.dev --skill docs-sandpack -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install reactjs/ar.react.dev docs-sandpack --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/reactjs/ar.react.dev.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.claude/skills/docs-sandpack .claude/skills/docs-sandpack && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
docs-sandpack
GitHub stars
164
Token cost
~2.7k tokens
SKILL.md length
386 words
Files
1
Skills in repo
10
Repo updated
First seen
Licence
CC-BY-4.0

At a glance

A skill your agent uses when adding interactive code examples to React docs.

  • Adding interactive code examples to React docs
  • SKILL.md covers Quick Start Template, File Naming, Line Highlighting and Code References (numbered…, plus 10 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Docs Sandpack is an agent skill from reactjs/ar.react.dev, published by the product's own GitHub organization. Use when adding interactive code examples to React docs.

Its SKILL.md is about 2.7k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It works with React. The repository describes itself as: React documentation website in Arabic 📘⚛️ — وثائق React باللغة العربية. The licence is CC-BY-4.0.

When your agent uses it

  • Adding interactive code examples to React docs

Example prompts

  • “/docs-sandpack”

What it can do on your machine

Read from SKILL.md and the folder at commit 2da48d6. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are javascript, mdx, css and json).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Docs Sandpack loads about 2.7k tokens when it runs. Until then it costs about 18 tokens; SKILL.md has 386 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~18
When it runs · the whole SKILL.md, loaded when a task matches
~2.7k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from reactjs/ar.react.dev at commit 2da48d6, republished under its CC-BY-4.0 licence (© reactjs). 386 words, ~2,683 tokens.

Download SKILL.mdSave it as .claude/skills/docs-sandpack/SKILL.md (or your agent's skills folder).
name
docs-sandpack
description
Use when adding interactive code examples to React docs.

Sandpack Patterns

Quick Start Template

Most examples are single-file. Copy this and modify:

mdx
<Sandpack>

` ` `js
import { useState } from 'react';

export default function Example() {
  const [value, setValue] = useState(0);

  return (
    <button onClick={() => setValue(value + 1)}>
      Clicked {value} times
    </button>
  );
}
` ` `

</Sandpack>

File Naming

PatternUsage
```jsMain file (no prefix)
```js src/FileName.jsSupporting files
```js src/File.js activeActive file (reference pages)
```js src/data.js hiddenHidden files
```cssCSS styles
```json package.jsonExternal dependencies

Critical: Main file must have export default.

Line Highlighting

mdx
```js {2-4}
function Example() {
  // Lines 2-4
  // will be
  // highlighted
  return null;
}

Code References (numbered callouts)

mdx
```js [[1, 4, "age"], [2, 4, "setAge"]]
// Creates numbered markers pointing to "age" and "setAge" on line 4

Expected Errors (intentionally broken examples)

mdx
```js {expectedErrors: {'react-compiler': [7]}}
// Line 7 shows as expected error

Multi-File Example

mdx
<Sandpack>

```js src/App.js
import Gallery from './Gallery.js';

export default function App() {
  return <Gallery />;
}
js
export default function Gallery() {
  return <h1>Gallery</h1>;
}
css
h1 { color: purple; }
</Sandpack>
```

External Dependencies

mdx
<Sandpack>

```js
import { useImmer } from 'use-immer';
// ...
json
{
  "dependencies": {
    "immer": "1.7.3",
    "use-immer": "0.5.1",
    "react": "latest",
    "react-dom": "latest",
    "react-scripts": "latest"
  }
}
</Sandpack>
```

Code Style in Sandpack (Required)

Sandpack examples are held to strict code style standards:

  1. Function declarations for components (not arrows)
  2. e for event parameters
  3. Single quotes in JSX
  4. const unless reassignment needed
  5. Spaces in destructuring: ({ props }) not ({props})
  6. Two-line createRoot: separate declaration and render call
  7. Multiline if statements: always use braces
Don't Create Hydration Mismatches

Sandpack examples must produce the same output on server and client:

js
// 🚫 This will cause hydration warnings
export default function App() {
  const isClient = typeof window !== 'undefined';
  return <div>{isClient ? 'Client' : 'Server'}</div>;
}
Use Ref for Non-Rendered State
js
// 🚫 Don't trigger re-renders for non-visual state
const [mounted, setMounted] = useState(false);
useEffect(() => { setMounted(true); }, []);

// ✅ Use ref instead
const mounted = useRef(false);
useEffect(() => { mounted.current = true; }, []);

forwardRef and memo Patterns

forwardRef - Use Named Function
js
// ✅ Named function for DevTools display name
const MyInput = forwardRef(function MyInput(props, ref) {
  return <input {...props} ref={ref} />;
});

// 🚫 Anonymous loses name
const MyInput = forwardRef((props, ref) => { ... });
memo - Use Named Function
js
// ✅ Preserves component name
const Greeting = memo(function Greeting({ name }) {
  return <h1>Hello, {name}</h1>;
});

Line Length

  • Prose: ~80 characters
  • Code: ~60-70 characters
  • Break long lines to avoid horizontal scrolling

Anti-Patterns

PatternProblemFix
const Comp = () => {}Not standardfunction Comp() {}
onClick={(event) => ...}Conflicts with globalonClick={(e) => ...}
useState for non-rendered valuesRe-rendersUse useRef
Reading window during renderHydration mismatchCheck in useEffect
Single-line if without bracesHarder to debugUse multiline with braces
Chained createRoot().render()Less clearTwo statements
//... without spaceInconsistent// ... with space
TabsInconsistent2 spaces
ReactDOM.renderDeprecatedUse createRoot
Fake package namesConfusingUse './your-storage-layer'
PropsWithChildrenOutdatedchildren?: ReactNode
Missing key in listsWarningsAlways include key

Additional Code Quality Rules

Always Include Keys in Lists
js
// ✅ Correct
{items.map(item => <li key={item.id}>{item.name}</li>)}

// 🚫 Wrong - missing key
{items.map(item => <li>{item.name}</li>)}
Use Realistic Import Paths
js
// ✅ Correct - descriptive path
import { fetchData } from './your-data-layer';

// 🚫 Wrong - looks like a real npm package
import { fetchData } from 'cool-data-lib';
Console.log Labels
js
// ✅ Correct - labeled for clarity
console.log('User:', user);
console.log('Component Stack:', errorInfo.componentStack);

// 🚫 Wrong - unlabeled
console.log(user);
Keep Delays Reasonable
js
// ✅ Correct - 1-1.5 seconds
setTimeout(() => setLoading(false), 1000);

// 🚫 Wrong - too long, feels sluggish
setTimeout(() => setLoading(false), 3000);
Show full SKILL.md (190 more words)Show less

Updating Line Highlights

When modifying code in examples with line highlights ({2-4}), always update the highlight line numbers to match the new code. Incorrect line numbers cause rendering crashes.

File Name Conventions

  • Capitalize file names for component files: Gallery.js not gallery.js
  • After initially explaining files are in src/, refer to files by name only: Gallery.js not src/Gallery.js

Naming Conventions in Code

Components: PascalCase

  • Profile, Avatar, TodoList, PackingList

State variables: Destructured pattern

  • const [count, setCount] = useState(0)
  • Booleans: [isOnline, setIsOnline], [isPacked, setIsPacked]
  • Status strings: 'typing', 'submitting', 'success', 'error'

Event handlers:

  • handleClick, handleSubmit, handleAddTask

Props for callbacks:

  • onClick, onChange, onAddTask, onSelect

Custom Hooks:

  • useOnlineStatus, useChatRoom, useFormInput

Reducer actions:

  • Past tense: 'added', 'changed', 'deleted'
  • Snake_case compounds: 'changed_selection', 'sent_message'

Updater functions: Single letter

  • setCount(n => n + 1)
Pedagogical Code Markers

Wrong vs right code:

js
// 🔴 Avoid: redundant state and unnecessary Effect
// ✅ Good: calculated during rendering

Console.log for lifecycle teaching:

js
console.log('✅ Connecting...');
console.log('❌ Disconnected.');
Server/Client Labeling
js
// Server Component
async function Notes() {
  const notes = await db.notes.getAll();
}

// Client Component
"use client"
export default function Expandable({children}) {
  const [expanded, setExpanded] = useState(false);
}
Bundle Size Annotations
js
import marked from 'marked'; // 35.9K (11.2K gzipped)
import sanitizeHtml from 'sanitize-html'; // 206K (63.3K gzipped)

Sandpack Example Guidelines

Package.json Rules

Include package.json when:

  • Using external npm packages (immer, remarkable, leaflet, toastify-js, etc.)
  • Demonstrating experimental/canary React features
  • Requiring specific React versions (react: beta, react: 19.0.0-rc-*)

Omit package.json when:

  • Example uses only built-in React features
  • No external dependencies needed
  • Teaching basic hooks, state, or components

Always mark package.json as hidden:

mdx
```json package.json hidden
{
  "dependencies": {
    "react": "latest",
    "react-dom": "latest",
    "react-scripts": "latest",
    "immer": "1.7.3"
  }
}

**Version conventions:**
- Use `"latest"` for stable features
- Use exact versions only when compatibility requires it
- Include minimal dependencies (just what the example needs)

### Hidden File Patterns

**Always hide these file types:**

| File Type | Reason |
|-----------|--------|
| `package.json` | Configuration not the teaching point |
| `sandbox.config.json` | Sandbox setup is boilerplate |
| `public/index.html` | HTML structure not the focus |
| `src/data.js` | When it contains sample/mock data |
| `src/api.js` | When showing API usage, not implementation |
| `src/styles.css` | When styling is not the lesson |
| `src/router.js` | Supporting infrastructure |
| `src/actions.js` | Server action implementation details |

**Rationale:**
- Reduces cognitive load
- Keeps focus on the primary concept
- Creates cleaner, more focused examples

**Example:**
```mdx
```js src/data.js hidden
export const items = [
  { id: 1, name: 'Item 1' },
  { id: 2, name: 'Item 2' },
];

### Active File Patterns

**Mark as active when:**
- File contains the primary teaching concept
- Learner should focus on this code first
- Component demonstrates the hook/pattern being taught

**Effect of the `active` marker:**
- Sets initial editor tab focus when Sandpack loads
- Signals "this is what you should study"
- Works with hidden files to create focused examples

**Most common active file:** `src/index.js` or `src/App.js`

**Example:**
```mdx
```js src/App.js active
// This file will be focused when example loads
export default function App() {
  // ...
}

### File Structure Guidelines

| Scenario | Structure | Reason |
|----------|-----------|--------|
| Basic hook usage | Single file | Simple, focused |
| Teaching imports | 2-3 files | Shows modularity |
| Context patterns | 4-5 files | Realistic structure |
| Complex state | 3+ files | Separation of concerns |

**Single File Examples (70% of cases):**
- Use for simple concepts
- 50-200 lines typical
- Best for: Counter, text inputs, basic hooks

**Multi-File Examples (30% of cases):**
- Use when teaching modularity/imports
- Use for context patterns (4-5 files)
- Use when component is reused

**File Naming:**
- Main component: `App.js` (capitalized)
- Component files: `Gallery.js`, `Button.js` (capitalized)
- Data files: `data.js` (lowercase)
- Utility files: `utils.js` (lowercase)
- Context files: `TasksContext.js` (named after what they provide)

### Code Size Limits

- Single file: **<200 lines**
- Multi-file total: **150-300 lines**
- Main component: **100-150 lines**
- Supporting files: **20-40 lines each**

### CSS Guidelines

**Always:**
- Include minimal CSS for demo interactivity
- Use semantic class names (`.panel`, `.button-primary`, `.panel-dark`)
- Support light/dark themes when showing UI concepts
- Keep CSS visible (never hidden)

**Size Guidelines:**
- Minimal (5-10 lines): Basic button styling, spacing
- Medium (15-30 lines): Panel styling, form layouts
- Complex (40+ lines): Only for layout-focused examples

© reactjs, CC-BY-4.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .claude/skills/docs-sandpack of reactjs/ar.react.dev.

Open the folder on GitHubat commit 2da48d6

Used in 3 other repositories

We found 3 copies of this SKILL.md (exact, near-identical or edited) in other folders. This page covers the copy in reactjs/ar.react.dev, which our catalogue first saw on October 7, 2026.

Compare with similar skills

Docs Sandpack next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Docs Sandpack compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Docs Sandpack this skillreactjs/ar.react.dev164—~2.7kAutomated safety check: PassCC-BY-4.0
Web Artifacts Builderanthropics/skills180k40 repos~769Automated safety check: PassApache-2.0
React Doctormakeplane/plane60k12 repos~657Automated safety check: PassAGPL-3.0
React Composition Patternsvercel-labs/openreview1.7k58 repos~721Automated safety check: PassMIT
React Router Developmentremix-run/react-router57k1 repos~1.5kAutomated safety check: PassMIT
Electron Multi-Process ArchitectureiOfficeAI/AionUi33k1 repos~1.8kAutomated safety check: PassApache-2.0

Similar skills

  • Web Artifacts Builder

    anthropics/skills

    Official

    Builds multi-component claude.ai HTML artifacts as a small React, TypeScript and Tailwind project, then bundles it into one shareable HTML file.

    180k GitHub starsUsed in 40 repos~769 tokens
    Frontend & DesignAuto-check passed
  • React Doctor

    makeplane/plane

    Scans React code for lint, accessibility, bundle size and architecture issues, reports a health score and checks that changes do not lower it.

    60k GitHub starsUsed in 12 repos~657 tokens
    Frontend & DesignAuto-check passed
  • React Composition Patterns

    vercel-labs/openreview

    Official

    Rules for structuring React components with composition instead of boolean props, covering compound components, lifted state, variants and React 19 changes.

    1.7k GitHub starsUsed in 58 repos~721 tokens
    Frontend & DesignAuto-check passed
  • React Router Development

    remix-run/react-router

    Guides work on React Router apps by first identifying whether the app uses Framework, Data or Declarative mode, then loading the matching reference and the installed package docs.

    57k GitHub starsUsed in 1 repo~1.5k tokens
    Frontend & DesignAuto-check passed
  • Tells the agent where new code belongs in an Electron multi-process project and which APIs each process may use, with rules for new bridges, services, agents and workers.

    33k GitHub starsUsed in 1 repo~1.8k tokens
    DevelopmentAuto-check passed
  • Stitch to Remotion Walkthrough Videos

    google-labs-code/stitch-skills

    Official

    Builds walkthrough videos from Stitch design projects using Remotion, with transitions, zoom effects and text overlays on each screen.

    8.4k GitHub starsUsed in 6 repos~3.2k tokens
    Media & CreativeAuto-check: notes

More from reactjs/ar.react.dev

All 10 skills in this repo
  • React Expert

    reactjs/ar.react.dev

    Official

    A skill your agent uses when researching React APIs or concepts for documentation.

    164 GitHub starsUsed in 2 repos~2.7k tokens
    Auto-check passed
  • Docs Rsc Sandpack

    reactjs/ar.react.dev

    Official

    A skill your agent uses when adding interactive RSC (React Server Components) code examples to React docs using <SandpackRSC, or when modifying the RSC sandpack infrastructure.

    164 GitHub stars~2.1k tokensUpdated 3 days ago
    Auto-check passed
  • Docs Voice

    reactjs/ar.react.dev

    Official

    A skill your agent uses when writing any React documentation.

    164 GitHub stars~1.2k tokensUpdated 3 days ago
    Auto-check passed
  • Docs Writer Blog

    reactjs/ar.react.dev

    Official

    A skill your agent uses when writing or editing files in src/content/blog/.

    164 GitHub stars~4.2k tokensUpdated 3 days ago
    Auto-check passed
  • Docs Writer Learn

    reactjs/ar.react.dev

    Official

    A skill your agent uses when writing or editing files in src/content/learn/.

    164 GitHub stars~1.8k tokensUpdated 3 days ago
    Auto-check passed
  • Write

    reactjs/ar.react.dev

    Official

    A skill your agent uses when creating new React documentation pages or updating existing ones.

    164 GitHub stars~1.6k tokensUpdated 3 days ago
    Auto-check passed

Works with

Questions about Docs Sandpack

What does Docs Sandpack do?

A skill your agent uses when adding interactive code examples to React docs. dev, published by the product's own GitHub organization. Use when adding interactive code examples to React docs.

When should I use Docs Sandpack?

Docs Sandpack fits situations like: adding interactive code examples to React docs.

How do I install Docs Sandpack in Claude Code?

Run `npx skills add reactjs/ar.react.dev --skill docs-sandpack -a claude-code`. Or copy the skill folder (.claude/skills/docs-sandpack in reactjs/ar.react.dev) into .claude/skills/docs-sandpack in your project. Claude Code loads it when a task matches its description.

How do I install Docs Sandpack in Codex?

Run `npx skills add reactjs/ar.react.dev --skill docs-sandpack -a codex`. Or copy the skill folder (.claude/skills/docs-sandpack in reactjs/ar.react.dev) into .agents/skills/docs-sandpack in your project. Codex loads it when a task matches its description.

Can I use Docs Sandpack in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add reactjs/ar.react.dev --skill docs-sandpack -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/docs-sandpack, .gemini/skills/docs-sandpack, .github/skills/docs-sandpack and .opencode/skills/docs-sandpack in your project.

What does Docs Sandpack need to run?

SKILL.md names no scripts, command-line tools or credentials: Docs Sandpack is instructions for the agent only.

Does Docs Sandpack access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Docs Sandpack safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Docs Sandpack use?

Docs Sandpack is published under the CC-BY-4.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Docs Sandpack use?

About 2.7k tokens (SKILL.md is roughly 11k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Docs Sandpack?

Skills that share tags, products or a category with Docs Sandpack: Web Artifacts Builder (anthropics/skills, 180k stars), React Doctor (makeplane/plane, 60k stars), React Composition Patterns (vercel-labs/openreview, 1.7k stars) and React Router Development (remix-run/react-router, 57k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Docs Sandpack?

reactjs (a GitHub organization, an official publisher) maintains it in reactjs/ar.react.dev, which has 164 GitHub stars. The repository holds 10 skills in this directory. The repository was last updated on October 5, 2026.

Source: reactjs/ar.react.dev on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.