Skip to main content

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 Documentation

Core 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 → Calls load_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
  • skillId uses an enum field, ensuring selection only from registered Skills, guaranteeing accuracy
  • resourcePath is 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

Required Fields:
  • name - Skill name (lowercase letters, numbers, underscores)
  • description - Skill functionality and usage scenarios, helps AI determine when to use
Metadata Notes:
  • 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 type Map are 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:
Configuration Reference:
  • 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 directory agentscope-code-execution-* is created lazily and cleaned up on JVM exit
  • uploadDir: Upload location for Skill resource files; defaults to workDir/skills
  • File Filtering: Controls which resource files are allowed to upload. Defaults to scripts/, assets/ folders and .py, .js, .sh extensions. Adjust with includeFolders()/includeExtensions(), or fully customize with fileFilter() (the two approaches are mutually exclusive)
  • Custom Shell: withShell(customShellTool) accepts a custom tool whose baseDir is automatically overridden with workDir while preserving its security policy
Custom Configuration:

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.
If the repository contains a 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.
Resource structure: Place multiple skill subdirectories under src/main/resources/skills/, each containing a SKILL.md.
Note: JarSkillRepositoryAdapter is deprecated. Use ClasspathSkillRepository instead.

Nacos Repository (Read-Only)

Pulls or subscribes to Skills from Nacos via a pre-built AiService (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-in load_skill_through_path usage 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 to name, description, and skill-id; the default is to expose all metadata fields
When code execution is enabled, the section appended after </available_skills> can also be customized via .codeExecutionInstruction():
  • codeExecutionInstruction: Template for the code execution section; every %s placeholder will be replaced with the uploadDir absolute path. Passing null or blank uses the built-in default.
Passing null or a blank string for instruction or codeExecutionInstruction uses the built-in default. Example:

Performance Optimization Recommendations

  1. Control SKILL.md Size: Keep under 5k tokens, recommended 1.5-2k tokens
  2. Organize Resources Properly: Place detailed documentation in references/ rather than SKILL.md
  3. Regularly Clean Versions: Use clearSkillOldVersions() to clean up old versions no longer needed
  4. Avoid Duplicate Registration: Leverage duplicate registration protection mechanism; same Skill object with multiple Tools won’t create duplicate versions