Overview
Agent Skills are modular skill packages that extend agent capabilities. Each Skill contains instructions, metadata, and optional resources (such as scripts, reference documentation, examples, etc.), which agents will automatically use for relevant tasks. Reference: Claude Agent Skills Official DocumentationCore Features
Progressive Disclosure Mechanism
Adopts three-stage on-demand loading to optimize context: Initially loads only metadata (~100 tokens/Skill) → AI loads complete instructions when needed (<5k tokens) → On-demand access to resource files. Tools are also progressively disclosed, activated only when the Skill is in use. Workflow: User Query → AI Identifies Relevant Skill → Callsload_skill_through_path Tool to Load Content and Activate Bound Tools → On-Demand Resource Access → Task Completion
Unified Loading Tool: load_skill_through_path(skillId, resourcePath) provides a single entry point for loading skill resources
skillIduses an enum field, ensuring selection only from registered Skills, guaranteeing accuracyresourcePathis the resource path relative to the Skill root directory (e.g.,references/api-doc.md)- Returns a list of all available resource paths when the path is incorrect, helping the LLM correct errors
Adaptive Design
We have further abstracted skills so that their discovery and content loading are no longer dependent on the file system. Instead, the LLM discovers and loads skill content and resources through tools. At the same time, to maintain compatibility with the existing skill ecosystem and resources, skills are still organized according to file system structure for their content and resources. Organize your skill content and resources just like organizing a skill directory in a file system! Taking the Skill Structure as an example, this directory-structured skill is represented in our system as:Skill Structure
SKILL.md Format Specification
name- Skill name (lowercase letters, numbers, underscores)description- Skill functionality and usage scenarios, helps AI determine when to use
- Any additional YAML frontmatter fields are preserved as skill metadata, not limited to predefined fields
- Nested maps and lists are supported and keep their structure and insertion order
- Frontmatter is parsed with SnakeYAML
SafeConstructor; only top-level YAML objects of typeMapare accepted - Invalid frontmatter or frontmatter exceeding the parser limit is ignored and treated as empty metadata
Quick Start
1. Create a Skill
Method 1: Using Builder
Method 2: Create from Markdown
Method 3: Direct Construction
2. Integrate with ReActAgent
Using SkillBox
3. Use Skills
Simplified Integration
Advanced Features
Feature 1: Progressive Disclosure of Tools
Bind Tools to Skills for on-demand activation. Avoids context pollution from pre-registering all Tools, only passing relevant Tools to LLM when the Skill is actively used. Lifecycle of Progressively Disclosed Tools: Tool lifecycle remains consistent with Skill lifecycle. Once a Skill is activated, Tools remain available throughout the entire session, avoiding the call failures caused by Tool deactivation after each conversation round in the old mechanism. Example Code:Feature 2: Code Execution Capabilities
Provides an isolated code execution environment for Skills, supporting Shell commands, file read/write operations, etc. Uses Builder pattern to compose tools and configuration on demand. Basic Usage:- Tool Selection: Combine
withShell(),withRead(),withWrite()as needed — only explicitly enabled tools are registered workDir: Shared working directory for all tools. Created automatically when specified; if omitted, a temporary directoryagentscope-code-execution-*is created lazily and cleaned up on JVM exituploadDir: Upload location for Skill resource files; defaults toworkDir/skills- File Filtering: Controls which resource files are allowed to upload. Defaults to
scripts/,assets/folders and.py,.js,.shextensions. Adjust withincludeFolders()/includeExtensions(), or fully customize withfileFilter()(the two approaches are mutually exclusive) - Custom Shell:
withShell(customShellTool)accepts a custom tool whosebaseDiris automatically overridden withworkDirwhile preserving its security policy
Feature 3: Skill Persistence Storage
Why is this feature needed? Skills need to remain available after application restart, or be shared across different environments. Persistence storage supports:File System Storage
MySQL Database Storage
Git Repository (Read-Only)
Used to load Skills from a Git repository (read-only). Supports HTTPS and SSH. Update mechanism- By default, each read triggers a lightweight remote reference check; a pull runs only when the remote HEAD changes.
- You can disable auto-sync via the constructor and call
sync()manually when you want to refresh.
skills/ subdirectory, it will be used; otherwise the repo root
is used.
Classpath Repository (Read-Only)
Used to load pre-packaged Skills from classpath resources. Automatically compatible with standard JARs and Spring Boot Fat JARs.src/main/resources/skills/, each containing a SKILL.md.
Note:JarSkillRepositoryAdapteris deprecated. UseClasspathSkillRepositoryinstead.
Nacos Repository (Read-Only)
Pulls or subscribes to Skills from Nacos via a pre-builtAiService (or Nacos connection config). The Agent fetches Skills from Nacos at runtime in real time, with support for change subscription and automatic awareness. Suitable for online scenarios that need to stay in sync with Nacos.
Note: Add the agentscope-extensions-nacos-skill dependency.
Feature 4: Custom Skill Prompts
When SkillBox injects a system prompt into the Agent, it generates one XML<skill> entry per registered Skill so the LLM can decide when to load which Skill. Metadata is rendered directly from AgentSkill.getMetadata(), and <skill-id> is always appended for tool loading.
instruction: The prompt header, explaining how to use Skills (how to load them, path conventions, etc.). Defaults to a built-inload_skill_through_pathusage guide- XML metadata rendering: Scalar metadata becomes a child element, nested maps become nested XML, and lists become repeated
<item>elements - Metadata exposure control:
skillBox.setExposeAllSkillMetadata(false)limits the prompt toname,description, andskill-id; the default is to expose all metadata fields
</available_skills> can also be customized via .codeExecutionInstruction():
codeExecutionInstruction: Template for the code execution section; every%splaceholder will be replaced with theuploadDirabsolute path. Passingnullor blank uses the built-in default.
null or a blank string for instruction or codeExecutionInstruction uses the built-in default.
Example:
Performance Optimization Recommendations
- Control SKILL.md Size: Keep under 5k tokens, recommended 1.5-2k tokens
- Organize Resources Properly: Place detailed documentation in references/ rather than SKILL.md
- Regularly Clean Versions: Use
clearSkillOldVersions()to clean up old versions no longer needed - Avoid Duplicate Registration: Leverage duplicate registration protection mechanism; same Skill object with multiple Tools won’t create duplicate versions
Related Documentation
- Claude Agent Skills Official Documentation - Complete concept and architecture introduction
- Tool Usage Guide - Tool system usage methods
- Agent Configuration - Agent configuration and usage