← Back to Blog
Gen AI

How AI agents & Claude skills work

25 April 202616 min read
How AI agents & Claude skills work

Modern AI models have become incredibly powerful and are changing the way we solve complex problems. But raw capability alone doesn't guarantee great results. The real value of AI agents comes from how well we guide them with the right context and continuously improve their skills over time. This post explores how AI agents actually work in practice, with a focus on managing context efficiently, using progressive disclosure to share information at the right time, and following an iterative approach to build smarter, more reliable capabilities.

The Evolution and Power of Modern AI Models

Today's leading AI models, such as advanced versions of Opus and GPT, are remarkably capable. They demonstrate impressive reasoning, understanding, and generation abilities across a multitude of domains. This significant leap in performance means that many tasks previously considered beyond AI's reach are now well within their grasp. These models can generate coherent text, write complex code, understand complex instructions, and even engage in extended, multi-turn conversations.

However, raw model capability is only one part of the equation. To truly unlock their potential and direct their actions towards specific, high-quality results, providing the right context is very important. Without clear guidance, even the most advanced AI can become inefficient or produce undesirable outputs.

Understanding the AI Agent's "Brain": The Context Window

At the core of how AI models process information is the context window. This is essentially the working memory of the AI agent. Which is a limited space where all the information relevant to its current task or conversation is stored and processed. Everything the agent "knows" or refers to during an interaction must pass through this window.

The information within the context window is quantified in tokens. A token is a fundamental unit of text that an AI model processes. It can be a word, a part of a word, or even punctuation. For instance, the word "understanding" might be broken down into "under", "stand", and "ing" as separate tokens. Each piece of data, whether it's a user's prompt, an agent's instruction, or a retrieved document, consumes a certain number of tokens in the context window.

Managing these tokens efficiently is critical because:

  • Capacity Limits: Context windows have finite capacities (e.g., from tens of thousands to hundreds of thousands of tokens). Exceeding this limit means older information is discarded, or the model's ability to reason over the entire context is impaired.
  • Cost: Processing tokens incurs computational cost. More tokens mean higher operational expenses.
  • Performance: An overloaded context window can lead to "compaction," where the model struggles to effectively synthesize information, potentially leading to reduced performance and "dumber" responses.
graph TD
A[User Input] --> B(Context Window)
B --> C[System Prompt]
B --> D[Agent.md if used]
B --> E[Skills.md active skill content]
B --> F[Tools definitions]
B --> G[Relevant Codebase Snippets]
B --> H[User Conversation History]
C & D & E & F & G & H --> I(AI Model Processing)
I --> J[AI Output]

Assembling the Agent's Context: A Deep Dive

For an AI agent to perform effectively, its context window must be populated with carefully selected and organized information. Here's a breakdown of the typical components that contribute to an agent's context:

  1. System Prompt: This is a foundational set of instructions provided by the model developer, dictating the agent's general persona, rules of engagement, and overall behavioral guidelines. It's a broad directive that shapes the AI's core operating principles.
  2. Agent.md (or similar declarative files): These files are often used to provide extensive, static instructions about the agent's purpose, rules, or specific information it should always consider.
    • The Pitfall: A common mistake is to include all content from Agent.md in the context window during every single turn of a conversation. This can quickly consume a significant portion of the token limit, especially for verbose files.
    • Best Use: Agent.md is best reserved for truly proprietary and essential information that must be referenced in every interaction, making it non-negotiable for the agent's core function.
  3. Skills.md: This represents a more efficient and dynamic approach to context management, utilizing progressive disclosure.
    • Initially, only the name and a concise description of available skills are loaded into the context window. This uses minimal tokens.
    • The full "bunch of info" within a specific skill, Its detailed step-by-step instructions, parameters, or examples are only loaded when the agent's reasoning determines it needs to use that particular skill. This ensures that only relevant information consumes valuable tokens at any given moment.
  4. Tools: These are built-in functionalities or integrations that the agent can call upon to perform actions. Examples include read (to access files), write (to modify files), search (to query external knowledge bases), or API calls. The descriptions and parameters of these tools are also part of the context, enabling the agent to understand when and how to use them.
  5. Codebase: In development or project-oriented scenarios, the actual project code can serve as context. The agent can access specific files or functions within the codebase to understand the existing structure, identify areas for modification, or retrieve necessary information.
  6. User Conversation History: The ongoing dialogue with the user is a dynamic and ever-growing part of the context window. Each turn adds to the token count, which is why managing conversation length and summarizing past interactions can be crucial for long-running dialogues.
Feature Agent.md Skills.md (Progressive Disclosure)
Context Loading All content loaded every turn. Only name and description initially; full content on demand.
Token Usage High, can quickly exhaust limits. Low initially, efficient and targeted.
Flexibility Static, best for unchanging core instructions. Dynamic, adaptable to task-specific needs.
Best For Global, non-negotiable directives/information. Task-specific workflows, step-by-step guides.
Performance Risk of "compaction" with large files. Optimized for performance by reducing noise in context.

The Power of Progressive Disclosure with AI Skills

The concept of progressive disclosure is a cornerstone of efficient AI agent design. Instead of burdening the agent with all possible information from the outset, it provides context only when it becomes genuinely relevant. This is particularly effective with Skills.md.

Consider a scenario where an AI agent has multiple skills, such as "Generate Marketing Copy," "Debug Code," and "Schedule Meeting." With progressive disclosure:

  1. The agent's context window initially contains only the names and descriptions of these skills:
    • name: Generate Marketing Copy, description: Creates engaging marketing content for various platforms.
    • name: Debug Code, description: Identifies and fixes errors in software code.
    • name: Schedule Meeting, description: Organizes meetings by checking calendars and sending invitations.
    This uses minimal tokens.
  2. When a user asks, "Please help me fix the error in my Python script," the agent's reasoning engine identifies that the "Debug Code" skill is relevant.
  3. At this point, the full content of the Debug Code skill, which might include detailed instructions on error logging, using specific debugging tools, or common Python debugging patterns is then dynamically loaded into the context window.

This method significantly reduces token consumption (e.g., 53 tokens for a skill's name/description vs. 944 tokens for its full content), keeping the context window lean and focused, thereby improving the agent's processing efficiency and reducing operational costs.

flowchart TD
A[Start Conversation] --> B{Agent Reviews Context & Query}
B --> C[Load Skill Names & Descriptions]
C --> D{Is a Specific Skill Needed?}
D -- Yes --> E[Load Full Skill Content On Demand]
D -- No --> F[Continue with General Context]
E --> G[Agent Executes Skill]
G --> H[Provide Response/Take Action]
F --> H
H --> I[End/Next Turn]

Crafting Effective AI Skills: The Iterative Approach

It's crucial to understand that AI models are token predictors, not inherent thinkers. They don't genuinely "understand" in a human sense. Rather, they predict the most probable next token based on their training data and the provided context. This distinction is vital for effective skill creation.

A common pitfall is attempting to create or download pre-made AI skills without first establishing a proven, successful workflow. Such attempts often lead to frustration because the AI lacks the specific context of your desired process.

Instead, an effective 3-step process for AI skill creation involves:

  1. Identify the Workflow: Clearly define the precise, step-by-step process you want the AI agent to follow for a particular task. Break it down into granular actions and decision points.
  2. Iterative Teaching: Engage in a back-and-forth dialogue with the AI. Walk it through the workflow, providing detailed instructions, correcting its mistakes, and offering explicit feedback until it consistently performs the task correctly. This is akin to training a new employee. You wouldn't expect them to master complex tasks without guidance.
  3. Codify the Skill: Once the AI has successfully executed the workflow multiple times, instruct it to "review what you did..." and then create the skill based on that learned, successful experience. This ensures the skill encapsulates your specific, proven methodology.

The Importance of Contextualized Learning: AI agents need the context of successful runs within your specific workflow to truly be productive. Relying on generic, pre-built skills often leads to ineffective tools, partly due to a lack of alignment with your unique processes and also potential security risks associated with untrusted external code. Building your own skills personalizes the AI's capabilities and significantly increases its value within your operational framework.

Scaling Productivity: Begin by perfecting a single agent's capabilities for a defined set of tasks. Once that agent is proficient, you can then consider scaling by adding specialized sub-agents for more intricate or parallel tasks, rather than immediately aiming for complex multi-agent systems.

Recursively Building and Improving Skills

The journey of developing robust AI agent capabilities is not linear. It's a recursive feedback loop of definition, execution, diagnosis, and refinement.

  1. Defining a Workflow: Start by outlining the desired steps an agent needs to perform for a task.
  2. Iterative Execution: Allow the AI agent to attempt to execute this workflow. Expect initial failures or deviations.
  3. Error Identification: Actively observe where the agent fails or makes mistakes.
  4. Diagnostic Feedback: Crucially, ask the agent why it failed. "What error did you encounter? What went wrong in step 3?"
  5. Direct Instruction: Provide explicit guidance on how to correct the identified failure: "You failed here. In future, when X happens, you should do Y."
  6. Skill Update: Once the agent successfully implements the fix, instruct it to update its skill.md file to incorporate this new learning. This formalizes the correction and ensures the agent learns from its errors.
  7. Continuous Improvement: Repeating this feedback loop leads to a progressively more reliable, accurate, and skilled agent.
graph TD
A[Define Workflow] --> B{AI Agent Attempts Execution}
B --> C{Identify Failures/Mistakes}
C --> D[Diagnostic Feedback: Ask Why?]
D --> E[Direct Instruction: Fix This]
E --> F[Agent Re-attempts with Correction]
F -- Success --> G[Update Skill.md Learn from Error]
G --> B
F -- Failure --> C

AI Agents in Project Development: A New Paradigm

AI agents are rapidly becoming highly proficient at writing code. Platforms are emerging that leverage AI agents to not only write code but also to call APIs, demonstrating their capabilities in complex project development.

A significant shift is occurring in how we provide context for coding projects. For many software development tasks, an overly extensive agent.md file detailing every aspect of the tech stack (e.g., React, Next.js, Supabase) is often unnecessary. The actual codebase itself has evolved to serve as sufficient context for AI agents. Modern AI models are adept at reading and understanding code, deriving context directly from the files, folder structures, and existing logic.

This paradigm shift emphasizes:

  • Starting with a Solid Foundation: Instead of verbose documentation, the focus shifts to providing a well-structured, functional starting point.
  • The Renaissance of Templates: High-quality, opinionated project templates are predicted to experience a resurgence. A robust template provides the necessary context for an AI agent to efficiently build upon, ensuring consistency and adherence to best practices.
  • Minimal Context, Robust Skills: Successful AI-driven project building prioritizes minimal, relevant context usage combined with powerful, well-defined skills for the agent to execute specific development tasks.

For example, an AI agent tasked with adding a new feature to an existing React application doesn't need a lengthy Agent.md explaining what React is. It can infer this from the package.json, existing .jsx or .tsx files, and component structure within the codebase. Its skills would then define how to add a component, how to connect to an API, or how to write tests according to the project's established patterns.

Optimizing Context Window Management and Token Efficiency

The overall performance of an AI agent is intricately linked to how effectively its context window is managed. Overloading the context window with excessive or redundant information invariably leads to diminished model performance. The agent can become less effective, appear to "get dumb," and incur higher operational costs due to increased token usage.

Optimal Context Window Usage: For peak performance, the context window should ideally remain relatively "fresh" and focused, typically operating between 10-70% capacity. Pushing it to near 100% capacity, similar to humans trying to cram too much information at the last minute, significantly hinders effective processing and synthesis.

The "skills" architecture, particularly using skill.md files with progressive disclosure, is a primary strategy for achieving this optimal usage. By only loading the full content of a skill when it is explicitly needed, unnecessary token consumption is avoided.

Furthermore, it's vital to focus on unique information when populating the context. Leverage the model's inherent, vast general knowledge by not repeating common instructions or widely known facts (e.g., "use React," "denote money with a dollar sign," "write in JSON format"). Instead, reserve valuable context tokens for specialized details specific to your unique workflow, business logic, novel requirements, or proprietary data. This "less is more" approach ensures that the agent's context is lean, relevant, and highly effective, leading to more performant and cost-efficient AI agents.

Conclusion

Harnessing the full potential of modern AI agents extends beyond simply interacting with powerful models. It demands a sophisticated understanding of context management, token efficiency, and an iterative approach to skill development. By strategically assembling the agent's context through system prompts, targeted Agent.md usage, and dynamic Skills.md with progressive disclosure, we can optimize performance and cost. Furthermore, embracing a recursive methodology for building and refining skills ensures that AI agents learn from experience, becoming increasingly robust and tailored to specific workflows. In this evolving landscape, the ability to effectively teach, guide, and refine AI agents through precise context and well-crafted skills will be the defining factor in achieving truly transformative results.

Further Reading

  • Advanced Prompt Engineering Techniques
  • Large Language Model (LLM) Architectures
  • Designing Multi-Agent Systems
  • Optimizing Token Usage in Generative AI
  • Ethical Considerations in AI Agent Deployment