Documentation
¶
Overview ¶
Package claude provides Claude Code integration types and utilities.
It provides configuration types for reading/writing Claude Code's settings.local.json (permissions) and embedded skill definitions.
Hook logic has been moved to the internal/cli/system package as native Go subcommands, deployed via the ctx Claude Code plugin.
Embedded assets:
- skills/*/SKILL.md: Agent skill definitions for Claude Code
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SkillContent ¶ added in v0.3.0
SkillContent returns the content of a skill's SKILL.md file by name.
Parameters:
- name: Skill directory name as returned by Skills (e.g., "ctx-status")
Returns:
- []byte: Raw bytes of the SKILL.md file
- error: Non-nil if the skill does not exist or cannot be read
func Skills ¶ added in v0.3.0
Skills returns the list of embedded skill directory names.
These are Agent Skills (https://agentskills.io) following the specification with SKILL.md files containing frontmatter (name, description) and autonomy-focused instructions. They can be installed to .claude/skills/ via "ctx init".
Returns:
- []string: Names of available skill directories (e.g., "ctx-status", "ctx-reflect")
- error: Non-nil if the skills directory cannot be read
Types ¶
type Hook ¶
Hook represents a single hook command to execute.
Fields:
- Type: Hook type, typically "command"
- Command: Shell command or script path to execute
type HookConfig ¶
type HookConfig struct {
PreToolUse []HookMatcher `json:"PreToolUse,omitempty"`
PostToolUse []HookMatcher `json:"PostToolUse,omitempty"`
UserPromptSubmit []HookMatcher `json:"UserPromptSubmit,omitempty"`
SessionEnd []HookMatcher `json:"SessionEnd,omitempty"`
}
HookConfig represents the hooks section of Claude Code's settings.local.json.
Hooks are shell commands that Claude Code executes at specific lifecycle events. See https://docs.anthropic.com/en/docs/claude-code/hooks for details.
Fields:
- PreToolUse: Matchers that run before each tool invocation
- PostToolUse: Matchers that run after a successful tool invocation
- UserPromptSubmit: Matchers that run when the user submits a prompt
- SessionEnd: Matchers that run when a session ends
type HookMatcher ¶
HookMatcher associates a regex pattern with hooks to execute.
For PreToolUse hooks, the Matcher pattern matches against the tool name (e.g., "Bash", "Read"). Use ".*" to match all tools.
Fields:
- Matcher: Regex pattern to match; empty string matches all
- Hooks: Commands to execute when the pattern matches
type HookType ¶ added in v0.3.0
type HookType string
HookType is the type identifier for a hook (e.g., "command").
type Matcher ¶ added in v0.3.0
type Matcher string
Matcher is a regex pattern for matching tool names in hooks.
type PermissionsConfig ¶ added in v0.1.2
type PermissionsConfig struct {
Allow []string `json:"allow,omitempty"`
}
PermissionsConfig represents the permissions section of Claude Code's settings.local.json.
Fields:
- Allow: List of tool patterns that are pre-approved (e.g., "Bash(ctx status:*)")
type Settings ¶
type Settings struct {
Hooks HookConfig `json:"hooks,omitempty"`
Permissions PermissionsConfig `json:"permissions,omitempty"`
}
Settings represents the full Claude Code settings.local.json structure.
This is used when reading or writing project-level Claude Code configuration.
Fields:
- Hooks: Hook configuration for lifecycle events
- Permissions: Tool permission configuration