adk-skill
AgentSkills parser, index, matcher, and runtime injection helpers for ADK-Rust.
Overview
adk-skill provides the core building blocks to load markdown instruction files, select relevant skills for a user query, and inject selected instructions into user prompts.
This crate is provider-agnostic and can be used through:
adk-agent(LlmAgentBuilder::with_skills*)adk-runner(Runner::with_auto_skills)- Direct API calls from custom runtimes
Supported File Conventions
Frontmatter Skill Files (.skills/**/*.md)
Each skill is a markdown file with YAML frontmatter:
name: code_search
description: Search source code quickly
tags: [code, search]
Use `rg --files` first, then `rg <pattern>`.
Rules enforced by parser:
- Opening and closing
---delimiters are required. nameis required and must be non-empty after trim.descriptionis required and must be non-empty after trim.tagsis optional and empty/whitespace tags are dropped.
Instruction Convention Files
The index loader also discovers and ingests these markdown files:
AGENTS.mdandAGENT.mdCLAUDE.mdGEMINI.mdCOPILOT.mdSKILLS.mdSOUL.md(root-level)
For these files, frontmatter is optional:
- If valid frontmatter is present, it is used.
- Otherwise the file is parsed as plain markdown instructions and converted into a skill document with convention tags (for example
agents-md,claude-md).
What The Crate Does
1. Discovery
- Scans
<root>/.skills/recursively for frontmatter skills. - Scans
<root>recursively for supported convention files. - Skips common heavy directories (
.git,target,node_modules, etc.). - Returns deterministic sorted file paths with de-duplication.
API: discover_skill_files(root)
API: discover_instruction_files(root)
2. Parsing + Validation
- Strict path (
.skills/**): parses required frontmatter as YAML with validation. - Convention path (
AGENTS.md,CLAUDE.md, etc.): parses plain markdown (or frontmatter if provided). - Returns actionable errors with file path context for strict frontmatter paths.
API: parse_skill_markdown(path, content)
API: parse_instruction_markdown(path, content)
3. Indexing
- Builds
SkillIndexfrom discovered files. - Computes:
- content hash (
SHA-256) last_modified(Unix timestamp seconds when available)- stable document id:
normalized-name + first-12-hash-chars
- content hash (
- Sorts documents deterministically by
(name, path).
API: load_skill_index(root)
4. Selection
Selection is lexical and deterministic (no embeddings yet).
Scoring weights:
name:+4.0per token hitdescription:+2.5tags:+2.0body:+1.0
Score is normalized by sqrt(body_token_count) to reduce long-body bias.
Tie-break order:
- Higher score first
- Lexicographically smaller
name - Lexicographically smaller
path
API: select_skills(index, query, policy)
SelectionPolicy defaults:
top_k = 1min_score = 1.0include_tags = []exclude_tags = []
5. Injection
Injection helpers prepend the selected skill body to user content using:
[skill:<name>]
<skill body>
[/skill]
Then original user text follows.
Behavior:
- Injection runs only when
Content.role == "user". - Query text is extracted from text parts and joined with newlines.
- Only the top match is injected.
- Injected body is truncated to
max_injected_chars.
APIs:
select_skill_prompt_block(...)apply_skill_injection(...)SkillInjector/SkillInjectorConfigSkillInjector::build_plugin(...)SkillInjector::build_plugin_manager(...)
Quick Start
Load and Match Skills
use ;
let index = load_skill_index?;
let policy = SelectionPolicy ;
let matches = select_skills;
for m in matches
# Ok::
Inject Into User Content
use Content;
use ;
let index = load_skill_index?;
let policy = SelectionPolicy ;
let mut content = new.with_text;
let matched = apply_skill_injection;
if let Some = matched
# Ok::
Build A Plugin Manager
use ;
let injector = from_root?;
let plugin_manager = injector.build_plugin_manager;
# let _ = plugin_manager;
# Ok::
Error Model
Main error type: SkillError
IoYamlInvalidFrontmatter { path, message }MissingField { path, field }InvalidSkillsRoot(path)
Type alias: SkillResult<T> = Result<T, SkillError>
Current Limits
- No embedding/vector retrieval (lexical matching only).
- No incremental file reload API yet.
- No remote catalog (
skills-ref/MCP) in this crate yet. - No script/file reference execution layer in this crate (selection + injection only).
Related Examples
From this repository:
examples/skills_llm_minimalexamples/skills_auto_discoveryexamples/skills_policy_filtersexamples/skills_runner_injectorexamples/skills_workflow_minimal
Development
License
Apache-2.0