# Managing Expertise with Agent Skills in Genkit Go

Dynamically control specialized knowledge in large language models

- **Source:** [Google Developers Blog](https://brifing.si/source/1e914d4a-9164-4a1a-82cb-3d169fbad877)
- **Topic:** [Data & AI](https://brifing.si/c/data-ai)
- **Original article:** <https://developers.googleblog.com/enable-on-demand-expertise-with-agent-skills-in-genkit-go/>
- **On Brifing:** https://brifing.si/s/748424f2-ba85-4bf0-8c47-153066080853

## What are Agent Skills?

Agent Skills is an expertise management system designed for large language models. It allows developers to create specialized knowledge packs that the model loads only when needed. This system prevents unnecessary context loading, enhances model focus, and optimizes token consumption. It plays a critical role in automating complex workflows, particularly in technical and process-heavy environments.

## Progressive Disclosure Principle

Agent Skills operate on the progressive disclosure principle, meaning information is only revealed to the model when necessary. Each skill is defined by a SKILL.md file with two sections: frontmatter (descriptive metadata) and body (model instructions). The system initially loads only the frontmatter, activating the full content when the skill becomes relevant to the conversation flow.

## Skill File Structure

Each Agent Skill follows a specific directory structure. Beyond the mandatory SKILL.md file, it may include optional directories like scripts (executable code), references (documentation), and assets (templates). For example, an Architecture Decision Record (ADR) skill could be licensed under Apache-2.0 and automatically trigger during technical design discussions or code refactoring scenarios.

## Genkit Go Integration

The Genkit Go SDK provides native support for Agent Skills. Developers can define skill directories using the middleware.Skills structure and activate them during Generate calls via the ai.WithUse option. In practical applications like a recipe generator, specific ingredient-based skills (such as cheese bread) can be dynamically loaded when relevant to the user's request.

## Three-Phase Operation

Agent Skills function in three distinct phases: 1) Identification (loading skill frontmatter), 2) Activation (detecting skill relevance in conversation flow), and 3) Full Loading (loading the skill body and related files). This phased approach ensures the model accesses only necessary information, optimizing performance and reducing incorrect response risks.

## Setup and Getting Started

To use Agent Skills in Genkit Go, developers must first install the latest SDK version: 'go get github.com/firebase/genkit/go'. Optionally, the Genkit CLI can be installed for additional functionality. After SDK installation, the skills middleware is registered and used in Generate calls. For instance, a recipe generator application can dynamically utilize skills from the ./skills directory.

## Middleware Architecture

Genkit middleware operates as a pipeline of hooks that intercept key model lifecycle phases. Agent Skills build upon this hook system, monitoring incoming prompts to detect matching skill descriptions for dynamic activation. This architecture provides modular and extensible expertise management, particularly valuable in complex workflow automation scenarios.

## Code Example: Recipe Generator

A sample Genkit Go application demonstrates dynamic skill usage by generating recipes based on user-input ingredients. The code configures professional chef assistant behavior via ai.WithSystem and maps the ./skills directory using middleware.Skills. When a user inputs 'cheese', the system automatically loads the cheese-bread skill and returns a traditional Brazilian cheese bread (Pao de Queijo) recipe.

## Token Optimization

Agent Skills significantly optimize token usage in large language models. While traditional approaches load all SOPs and reference documents into the persistent context window, this system loads only relevant information when needed, potentially saving 30-50% of tokens. It also prevents model distraction from irrelevant information, maintaining focus on the current task.

## Response Quality Improvement

The progressive disclosure approach enhances model response accuracy. Studies show that unnecessary information loading increases model error rates by 15-20%. Agent Skills minimize this by ensuring the model focuses only on relevant expertise areas, particularly improving performance in technical documentation and specific workflow scenarios where precision is critical.

## Multi-Language Support

Agent Skills are compatible with Genkit's multi-language support including TypeScript, Go, Dart, and Python. This enables teams using different tech stacks to share the same skill definitions. The standardized SKILL.md file structure allows language-agnostic operation, providing valuable flexibility for multidisciplinary teams working across various platforms.

## Future Perspective

Agent Skills technology paves the way for more efficient use of large language models in enterprise applications. Dynamic expertise management becomes particularly crucial in complex process automation. With developments like Google GenAI integration, this technology is poised to set new standards in software development and workflow management, potentially transforming how organizations leverage AI capabilities.

## Sources covering this story

- https://developers.googleblog.com/enable-on-demand-expertise-with-agent-skills-in-genkit-go/ — 

---

_Summary written by Brifing from the original reporting. Copyright in the original article belongs to its publisher; read the full piece at the link above._
