Skip to content

Commit 2b19b60

Browse files
author
Test User
committed
docs: document Claude Code 2.1.0 schema changes
- skills.md: context, agent, user-invocable, hooks fields - commands.md: hooks field for command-scoped lifecycle hooks - settings.md: language, respectGitignore, once, new hook types - schema-constraints.md: new rules for all v2.1.0 fields
1 parent 6760c8a commit 2b19b60

4 files changed

Lines changed: 305 additions & 8 deletions

File tree

docs/rules/commands.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,36 @@ cclint observation (documentation best practice)
279279

280280
---
281281

282+
## New Frontmatter Fields (v2.1.0+)
283+
284+
Claude Code 2.1.0 introduced the `hooks` field for commands:
285+
286+
| Field | Type | Description |
287+
|-------|------|-------------|
288+
| `hooks` | object | Lifecycle hooks scoped to command execution |
289+
290+
### Example with Hooks
291+
292+
```yaml
293+
---
294+
name: my-command
295+
description: Example command with hooks
296+
hooks:
297+
PreToolUse:
298+
- matcher: "Write"
299+
hooks:
300+
- type: command
301+
command: echo "Before write"
302+
once: true
303+
Stop:
304+
- hooks:
305+
- type: command
306+
command: echo "Command finished"
307+
---
308+
```
309+
310+
---
311+
282312
## Summary
283313

284314
| Rule Range | Category | Count |

docs/rules/schema-constraints.md

Lines changed: 191 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,119 @@ Command model field must be one of the predefined Claude Code model identifiers.
302302

303303
---
304304

305+
### Rule 117a: Command Hooks Field (v2.1.0+)
306+
307+
**Severity:** info
308+
**Component:** command
309+
**Category:** schema
310+
311+
**Description:**
312+
Commands can define lifecycle hooks (PreToolUse, PostToolUse, Stop) scoped to the command's execution.
313+
314+
**Constraint:**
315+
```
316+
hooks?: {
317+
[string]: [...#CommandHook]
318+
}
319+
```
320+
321+
**Valid Values:**
322+
Object with event names mapping to arrays of hook definitions.
323+
324+
**Source:** Claude Code 2.1.0 changelog - hooks support for commands
325+
326+
---
327+
328+
## Skill Schema Constraints (v2.1.0+)
329+
330+
### Rule 117b: Skill Context Field
331+
332+
**Severity:** info
333+
**Component:** skill
334+
**Category:** schema
335+
336+
**Description:**
337+
Skills can run in a forked sub-agent context using `context: fork`.
338+
339+
**Constraint:**
340+
```
341+
context?: "fork"
342+
```
343+
344+
**Valid Values:**
345+
- `fork` - Run skill in forked sub-agent context
346+
- Omitted - Run in main context (default)
347+
348+
**Source:** Claude Code 2.1.0 changelog - context: fork for skills
349+
350+
---
351+
352+
### Rule 117c: Skill Agent Field
353+
354+
**Severity:** info
355+
**Component:** skill
356+
**Category:** schema
357+
358+
**Description:**
359+
Skills can specify an agent type for execution.
360+
361+
**Constraint:**
362+
```
363+
agent?: string
364+
```
365+
366+
**Valid Values:**
367+
Any valid agent type name (e.g., "refactor-specialist", "go-specialist").
368+
369+
**Source:** Claude Code 2.1.0 changelog - agent field for skills
370+
371+
---
372+
373+
### Rule 117d: Skill User-Invocable Field
374+
375+
**Severity:** info
376+
**Component:** skill
377+
**Category:** schema
378+
379+
**Description:**
380+
Skills in `/skills/` directories are visible in the slash command menu by default. Use `user-invocable: false` to opt out.
381+
382+
**Constraint:**
383+
```
384+
"user-invocable"?: bool
385+
```
386+
387+
**Valid Values:**
388+
- `true` or omitted - Skill appears in slash command menu (default for /skills/ dirs)
389+
- `false` - Skill hidden from slash command menu
390+
391+
**Source:** Claude Code 2.1.0 changelog - user-invocable field for skills
392+
393+
---
394+
395+
### Rule 117e: Skill Hooks Field
396+
397+
**Severity:** info
398+
**Component:** skill
399+
**Category:** schema
400+
401+
**Description:**
402+
Skills can define lifecycle hooks scoped to the skill's execution.
403+
404+
**Constraint:**
405+
```
406+
hooks?: {
407+
[string]: [...#SkillHook]
408+
}
409+
```
410+
411+
**Valid Values:**
412+
Object with event names (PreToolUse, PostToolUse, Stop) mapping to hook arrays.
413+
414+
**Source:** Claude Code 2.1.0 changelog - hooks support for skills
415+
416+
---
417+
305418
## Settings Schema Constraints (Rules 118-121)
306419

307420
### Rule 118: Hook Event Structure
@@ -369,20 +482,24 @@ Any string pattern that matches hook trigger conditions (glob patterns, regex, e
369482
**Category:** schema
370483

371484
**Description:**
372-
Hook commands must specify type as "command". This is currently the only supported hook type.
485+
Hook commands must specify one of the valid hook types. As of Claude Code 2.1.0, three types are supported.
373486

374487
**Constraint:**
375488
```
489+
#HookType: "command" | "prompt" | "agent"
490+
376491
#HookCommand: {
377-
type: "command"
492+
type: #HookType
378493
...
379494
}
380495
```
381496

382497
**Valid Values:**
383-
- `command` (only valid value)
498+
- `command` - Execute a shell command
499+
- `prompt` - Modify Claude's prompt (plugins, v2.1.0+)
500+
- `agent` - Invoke an agent (plugins, v2.1.0+)
384501

385-
**Source:** [Anthropic Docs - Hooks](https://code.claude.com/docs/en/hooks) - hook type values (command, prompt)
502+
**Source:** [Anthropic Docs - Hooks](https://code.claude.com/docs/en/hooks) - hook type values
386503

387504
---
388505

@@ -411,6 +528,76 @@ Any non-empty string representing a shell command.
411528

412529
---
413530

531+
### Rule 121a: Hook Once Field (v2.1.0+)
532+
533+
**Severity:** error
534+
**Component:** settings
535+
**Category:** schema
536+
537+
**Description:**
538+
Hook commands can specify `once: true` to run only once per session.
539+
540+
**Constraint:**
541+
```
542+
#HookCommand: {
543+
type: #HookType
544+
command: string
545+
timeout?: int
546+
once?: bool
547+
}
548+
```
549+
550+
**Valid Values:**
551+
- `true` - Run hook only once per session
552+
- `false` or omitted - Run hook every time it triggers
553+
554+
**Source:** Claude Code 2.1.0 changelog - once field for hooks
555+
556+
---
557+
558+
### Rule 121b: Settings Language Field (v2.1.0+)
559+
560+
**Severity:** info
561+
**Component:** settings
562+
**Category:** schema
563+
564+
**Description:**
565+
Configure Claude's response language.
566+
567+
**Constraint:**
568+
```
569+
language?: string
570+
```
571+
572+
**Valid Values:**
573+
Any language name string (e.g., "japanese", "spanish", "french").
574+
575+
**Source:** Claude Code 2.1.0 changelog - language setting
576+
577+
---
578+
579+
### Rule 121c: Settings respectGitignore Field (v2.1.0+)
580+
581+
**Severity:** info
582+
**Component:** settings
583+
**Category:** schema
584+
585+
**Description:**
586+
Per-project control over @-mention file picker behavior.
587+
588+
**Constraint:**
589+
```
590+
respectGitignore?: bool
591+
```
592+
593+
**Valid Values:**
594+
- `true` - Hide gitignored files from @-mention picker
595+
- `false` - Show all files in @-mention picker
596+
597+
**Source:** Claude Code 2.1.0 changelog - respectGitignore setting
598+
599+
---
600+
414601
## CLAUDE.md Schema Constraints (Rules 122-124)
415602

416603
### Rule 122: Section Structure

docs/rules/settings.md

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,15 +205,15 @@ The `type` field contains a JSON string value.
205205
**Category:** structural
206206

207207
**Description:**
208-
Hook type must be either "command" (executes a shell command) or "prompt" (modifies Claude's prompt). No other values are valid.
208+
Hook type must be one of the valid types. As of Claude Code 2.1.0, plugins can use "prompt" and "agent" types in addition to "command".
209209

210210
**Pass Criteria:**
211-
The `type` field value is exactly "command" or "prompt".
211+
The `type` field value is exactly "command", "prompt", or "agent".
212212

213213
**Fail Message:**
214-
`Event '[eventName]' hook [index] inner hook [innerIndex]: invalid type '[hookType]'. Valid types: command, prompt`
214+
`Event '[eventName]' hook [index] inner hook [innerIndex]: invalid type '[hookType]'. Valid types: command, prompt, agent`
215215

216-
**Source:** [Anthropic Docs - Hooks](https://code.claude.com/docs/en/hooks) - "Hook type must be either 'command' (executes a shell command) or 'prompt' (modifies Claude's prompt)"
216+
**Source:** [Anthropic Docs - Hooks](https://code.claude.com/docs/en/hooks) - Hook type values (command, prompt, agent)
217217

218218
---
219219

@@ -523,6 +523,54 @@ Command does not redirect to `/dev/` paths, or redirection is verified to be int
523523

524524
---
525525

526+
## New Settings Fields (v2.1.0+)
527+
528+
Claude Code 2.1.0 introduced new settings.json fields:
529+
530+
| Field | Type | Description |
531+
|-------|------|-------------|
532+
| `language` | string | Configure Claude's response language (e.g., "japanese") |
533+
| `respectGitignore` | bool | Control @-mention file picker behavior |
534+
535+
### New Hook Fields
536+
537+
| Field | Type | Description |
538+
|-------|------|-------------|
539+
| `once` | bool | Run hook only once per session |
540+
541+
### New Hook Types (Plugins)
542+
543+
| Type | Description |
544+
|------|-------------|
545+
| `command` | Execute a shell command (original) |
546+
| `prompt` | Modify Claude's prompt (plugins, v2.1.0+) |
547+
| `agent` | Invoke an agent (plugins, v2.1.0+) |
548+
549+
### Example settings.json
550+
551+
```json
552+
{
553+
"language": "japanese",
554+
"respectGitignore": true,
555+
"hooks": {
556+
"SessionStart": [
557+
{
558+
"matcher": "",
559+
"hooks": [
560+
{
561+
"type": "command",
562+
"command": "echo 'Session started'",
563+
"once": true
564+
}
565+
]
566+
}
567+
]
568+
}
569+
}
570+
```
571+
572+
---
573+
526574
## Summary
527575

528576
Settings linting enforces:

docs/rules/skills.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,38 @@ Document contains at least one of:
289289

290290
---
291291

292+
## New Frontmatter Fields (v2.1.0+)
293+
294+
Claude Code 2.1.0 introduced several new optional frontmatter fields for skills:
295+
296+
| Field | Type | Description |
297+
|-------|------|-------------|
298+
| `context` | `"fork"` | Run skill in forked sub-agent context |
299+
| `agent` | string | Agent type for execution (e.g., "refactor-specialist") |
300+
| `user-invocable` | bool | Show in slash command menu (default: true for /skills/) |
301+
| `hooks` | object | Lifecycle hooks scoped to skill execution |
302+
303+
### Example with New Fields
304+
305+
```yaml
306+
---
307+
name: my-skill
308+
description: Example skill with v2.1.0 fields
309+
context: fork
310+
agent: refactor-specialist
311+
user-invocable: true
312+
hooks:
313+
PreToolUse:
314+
- matcher: "Bash"
315+
hooks:
316+
- type: command
317+
command: echo "Before bash"
318+
once: true
319+
---
320+
```
321+
322+
---
323+
292324
## Best Practices
293325

294326
### Skill Structure

0 commit comments

Comments
 (0)