Choose an Extension
Do not turn every customization into a plugin. Use a Tool Plugin for a new action, a Skill for a method the model should follow, a Hook for predictable policy at a fixed event, and AGENTS.md for durable project-wide constraints. The wrong choice mixes knowledge, permission, and executable code in one layer.
| Goal | Mechanism | Layer changed | Executes code |
|---|---|---|---|
| Add an action the model can call | Tool Plugin | Agent action space | Yes, inside the main process |
| Teach the model a specialized workflow | Skill | Agent method and context | Not by itself; its guidance may request tools |
| Run deterministic logic at lifecycle events | Hook | Runtime control and policy | Yes, as a command subprocess |
| Supply durable project constraints | AGENTS.md |
Startup context and behavior | No, prompt context only |
Before choosing, ask whether the requirement is a new action, method knowledge, enforced event policy, or durable project guidance. Only the first category should default to a tool plugin.
Discovery
Section titled “Discovery”Scan locations (once at startup)
Section titled “Scan locations (once at startup)”~/.agents/skills/<skill-name>/SKILL.md # user<workspace>/skills/<skill-name>/SKILL.md # project (bundled)<workspace>/.agents/skills/<skill-name>/SKILL.md # project (local)Direct subdirectories are scanned in that order; each candidate must be <skill-name>/SKILL.md.
Override order
Section titled “Override order”Same-named skills override in user → bundled → local order, so locally installed project skills win. skills/ is for repository-bundled, publicly distributable skills; .agents/skills/ is for locally installed project skills.
Format validation
Section titled “Format validation”| Rule | Requirement |
|---|---|
| frontmatter | must start with a parseable YAML frontmatter block |
name |
^[a-z0-9][a-z0-9-]{0,63}$ and must match the directory name |
description |
non-empty string, ≤ 1024 characters |
| size | SKILL.md ≤ 1MB |
| paths | no symlink escape from the scan root; must be a regular file |
Optional frontmatter fields: license, compatibility, metadata, allowed-tools.
Invalid entries are skipped; --verbose prints each failure reason (scope, path, reason). A failure affects neither other skills nor startup.
Context injection
Section titled “Context injection”- The startup context (system prompt) contains only each active skill’s name and description (
formatSkillCatalog). - When a task matches, the model calls
activate_skillto load the full instructions and the skill’s absolute root; resources such asreferences/andscripts/are read with ordinary tools as needed. - With no active skill,
activate_skillreturnsskill.not_found. - Skills are discovered at startup only: file changes require a CodeN restart.
Related references
Section titled “Related references”Agent Hooks Events
Section titled “Agent Hooks Events”Event overview
Section titled “Event overview”| Event | Timing | Controllable | Payload highlights |
|---|---|---|---|
SessionStart |
session startup or resume | no | source: startup | resume |
UserPromptSubmit |
after the user submits input | yes (block) | prompt |
PreToolUse |
before a tool executes | yes | toolName, callId, input, risk |
PermissionRequest |
before human authorization is needed | yes | toolName, callId, input, risk, reason: policy | hook |
PostToolUse |
after a tool succeeds | no | toolName, input, result, durationMs |
PostToolUseFailure |
after a tool fails | no | toolName, input, errorType, error, durationMs |
Notification |
when the user’s attention is needed | no | notificationType: permission_prompt | attention_required, title, message |
Stop |
when the model stops calling tools | yes (demand more work) | answer, toolsExecuted, stopHookActive |
SessionEnd |
when the session ends | no | reason: completed | failed | cancelled | eof | quit |
Control semantics
Section titled “Control semantics”- Controllable set:
UserPromptSubmit,PreToolUse,PermissionRequest,Stop. - Exit code
2on a controllable event counts as an explicit block (blocked); blocks onUserPromptSubmitandStopusedecision/reasoninstdoutJSON, whilePreToolUseandPermissionRequestusepermissionDecision/decision. - Exit code
0with empty stdout is a no-op; other failures (non-zero, timeout, output/input over limit, invalid JSON) count as hook failures with a warning and never block.
Relationships
Section titled “Relationships”PreToolUseruns before any permission decision;PermissionRequestruns only when the policy layer needs a human.Notificationfires forpermission_promptandattention_required(turn failure) scenarios.- A
Stopblock injects feedback asking the model to continue, still bounded bymaxSteps; a repeated block setsstopHookActive.