codingBy HowDoIUseAI Team

How to train your AI agent to learn new skills (the right way)

Learn the practical steps to teach your AI agent custom skills for browser automation, data processing, and task-specific workflows using Claude Code and OpenClaw.

Your AI agent is only as good as the skills you teach it. While ChatGPT and Claude can chat all day, they can't actually do much beyond text generation. But train them with custom skills, and suddenly they're automating your browser, processing spreadsheets, and handling complex workflows while you sleep.

The problem? Most people think training AI agents means feeding them more data or writing better prompts. That's like teaching someone to drive by showing them pictures of cars. Real agent training means building executable skills – code modules that turn your agent from a chatbot into a digital employee.

What makes AI agent skills different from regular prompting?

Think of regular prompts as giving directions to a tourist. You can describe the subway system all you want, but they still need to figure out how to buy tickets, navigate transfers, and avoid getting lost.

Agent skills are different. They're like installing a GPS with subway integration – your agent doesn't just know about the system, it can actually use it.

Claude's Agent Skills system lets you package domain expertise and organizational knowledge into reusable modules. Instead of explaining how to format a PowerPoint slide every time, you create a skill that handles the entire presentation workflow.

Claude automatically uses skills when relevant to your request, so you don't need to remember which skill does what. Ask for a sales report, and if you've trained a spreadsheet analysis skill, it gets invoked automatically.

How do you set up Claude Code for skill development?

The VS Code extension provides a native graphical interface for Claude Code, integrated directly into your IDE. This is the recommended way to use Claude Code.

Start with the basic setup:

  1. Install the Claude Code extension: Press Cmd+Shift+X (Mac) or Ctrl+Shift+X (Windows/Linux) to open the Extensions view, search for "Claude Code", and click Install

  2. Get Claude Code CLI: The extension includes the CLI, but you can also install it globally:

    npm install -g @anthropic-ai/claude-code
    
  3. Connect to your project: Open the integrated terminal (Ctrl+ on Windows/Linux or Cmd+ on Mac) and run claude

The key insight here: The first time you run the claude command from inside VS Code's integrated terminal, it figures out where it is and automatically asks you to install the extension. It's a pretty slick setup that gets you going with almost no effort.

You can access Claude Code directly or use the official documentation for deeper configuration options.

What types of skills can you build?

Pre-built Agent Skills are available for immediate use: PowerPoint (pptx), Excel (xlsx), Word (docx), and PDF (pdf). But the real power comes from custom skills.

Browser automation skills are among the most practical. Imagine training your agent to:

  • Navigate LinkedIn and send connection requests
  • Monitor competitor pricing on e-commerce sites
  • Fill out repetitive forms across multiple websites
  • Extract data from web dashboards

Data processing skills handle the boring stuff:

  • Parse CSV files and generate summary reports
  • Clean messy datasets with consistent formatting rules
  • Create charts and visualizations from raw numbers
  • Merge data from multiple sources into master sheets

Communication skills keep your workflows connected:

  • Draft emails based on meeting notes
  • Schedule follow-ups automatically
  • Post updates to Slack channels
  • Generate status reports from project management tools

The pattern here: Custom Skills let you package domain expertise and organizational knowledge. Instead of re-explaining your company's formatting standards every time, build a skill that enforces them automatically.

How do you create a custom skill from scratch?

Subagents are defined in Markdown files with YAML frontmatter. The structure is straightforward – frontmatter for configuration, body for instructions.

Here's the basic template:

---
name: linkedin-messenger
description: Sends connection requests on LinkedIn
tools: Read, Write, Bash
model: sonnet
---

You are a LinkedIn automation specialist. When invoked, you:

1. Navigate to LinkedIn connections page
2. Search for target profiles based on criteria
3. Send personalized connection requests
4. Track sent requests in a local file

Always ask for confirmation before sending messages.

The magic happens in the instructions. Unlike prompts that describe what you want, skill instructions define how to do it:

Be specific about the workflow:

  • What files to read/write
  • Which commands to run
  • How to handle errors
  • When to ask for permission

Include concrete examples: Instead of "personalize the message," provide: "Use this template: 'Hi [Name], I noticed we both work in [Industry]. Would love to connect and exchange insights about [Shared Interest].'"

Define boundaries:

  • Maximum number of requests per session
  • Required confirmation steps
  • Fallback actions when things fail

The key difference from regular prompting: The body becomes the system prompt that guides the subagent's behavior. Subagents receive only this system prompt (plus basic environment details like working directory), not the full Claude Code system prompt.

What's the difference between Claude Skills and OpenClaw automation?

Claude Code focuses on development workflows – it's built for programmers who want an AI pair programmer. OpenClaw takes a different approach: it's designed for broader life automation.

OpenClaw operates as an autonomous agent that can execute tasks through messaging platforms such as WhatsApp, Telegram, and Signal. It answers you on the channels you already use (WhatsApp, Telegram, Slack, Discord, Google Chat, Signal, iMessage, Microsoft Teams, WebChat).

Claude Code strengths:

  • Deep IDE integration
  • Built-in development tools (Git, terminal access)
  • Code-focused workflows
  • Visual diff comparisons

OpenClaw strengths:

  • Functions as a local gateway that provides AI models with direct access to read and write files, run scripts, and control browsers through a secure sandbox
  • Maintains persistent memory and user preferences by storing data as local Markdown documents, allowing for deep personalization
  • Works across any app or platform
  • Browser automation for web tasks, file read/write, shell commands, cron jobs, and sandbox options for safe execution

For browser automation specifically, OpenClaw provides one tool for browser automation: browser snapshot returns a stable UI tree, browser act uses the snapshot ref IDs to click/type/drag/select.

If you're building coding skills, stick with Claude Code. For general life automation – including browser tasks, messaging, and cross-platform workflows – OpenClaw offers more flexibility.

How do you train browser automation skills effectively?

Browser automation is where most people get stuck. The web is messy, dynamic, and full of edge cases. Here's how to build skills that actually work:

Start with stable selectors: Instead of relying on CSS classes that change, use stable attributes:

// Fragile - breaks when LinkedIn updates their CSS
document.querySelector('.artdeco-button--primary')

// Better - uses semantic attributes
document.querySelector('[data-control-name="connect"]')

Build in retries and waits: Modern websites load content dynamically. Your skills need to handle this:

async function waitForElement(selector, timeout = 5000) {
  const start = Date.now();
  while (Date.now() - start < timeout) {
    const element = document.querySelector(selector);
    if (element) return element;
    await new Promise(resolve => setTimeout(resolve, 100));
  }
  throw new Error(`Element ${selector} not found after ${timeout}ms`);
}

Handle different page states: LinkedIn's interface changes based on your connection status, account type, and current page. Build skills that check context first:

Before sending a connection request:
1. Verify we're on the correct profile page
2. Check if we're already connected
3. Confirm the "Connect" button is clickable
4. Handle premium account limitations

OpenClaw supports optional multi-profile support (openclaw, work, remote). This browser is not your daily driver. It is a safe, isolated surface for agent automation and verification.

What are the common mistakes that break skill training?

Overly generic instructions: "Navigate to the website and do the needful" isn't a skill – it's wishful thinking. Your agent needs step-by-step procedures.

No error handling: Websites go down, elements move, and logins expire. Skills that don't handle failures will break constantly:

Error handling workflow:
1. If login page appears → authenticate and retry
2. If rate limited → wait and exponentially back off  
3. If element not found → capture screenshot and report
4. If network error → retry up to 3 times

Ignoring permissions: Claude Code asks permission for everything. You type a prompt, it starts working, you go check Slack, come back five minutes later, and it's just sitting there asking "Can I edit this file?"

The solution: Every time I open Claude Code, I run claude --dangerously-skip-permissions. It's not as dangerous as it sounds — think of it as Cursor's old yolo mode.

Not testing incrementally: Build skills in small pieces. Test each step before moving to the next. A skill that "does everything" is a skill that breaks everything.

Forgetting about rate limits: Social platforms have aggressive rate limiting. Build in delays and respect platform limits:

LinkedIn automation limits:
- Maximum 100 connection requests per week
- 5-second delay between actions
- Monitor for "slow down" warnings

How do you test and refine your skills?

This guide walks through building a code review agent from scratch. By the end, you'll have something that can analyze a codebase, find bugs and security issues, and return structured feedback. More importantly, you'll understand how the SDK works so you can build whatever you actually need.

Start with safe, reversible actions: Before your skill starts sending LinkedIn messages, have it generate a preview file first. Test the logic without consequences.

Use staging environments: Set up test accounts on platforms where possible. LinkedIn, for example, lets you create separate accounts for testing automation.

Log everything: Your skills should create detailed logs:

Skill execution log:
- 10:30 AM: Started LinkedIn connection workflow
- 10:31 AM: Found 15 potential connections
- 10:32 AM: Sent request to John Smith (Software Engineer at TechCorp)
- 10:33 AM: Rate limit detected, waiting 30 seconds
- 10:34 AM: Completed 5/15 connections, stopping due to daily limit

Build feedback loops: In Claude Code, Claude often operates in a specific feedback loop: gather context -> take action -> verify work -> repeat. This offers a useful way to think about other agents, and the capabilities they should be given.

Your skills should follow the same pattern:

  1. Gather context (check current page state)
  2. Take action (click, type, navigate)
  3. Verify work (confirm expected result)
  4. Report back (log success/failure)

The Claude Agent SDK provides built-in tools for this workflow, including session management and error handling.

Which tools complement agent skill development?

MCP (Model Context Protocol): Connect custom tools, databases, and APIs via the open Model Context Protocol, an Anthropic-backed standard with official TypeScript SDKs and a growing ecosystem. This lets your skills integrate with external services without writing custom API code.

Browser dev tools: Essential for building reliable selectors. Use the Elements panel to inspect DOM structure and the Console to test JavaScript snippets before building them into skills.

Playwright: For advanced browser automation. OpenClaw returns an AI snapshot with numeric refs when Playwright is installed, making element selection more reliable.

Local testing environments: Docker containers or virtual machines let you test skills without affecting your main system. Particularly important for skills that modify files or system settings.

The key insight: agent skills aren't just better prompts – they're executable code modules that extend your AI's capabilities. The difference between describing how to ride a bike and actually riding one.

Build incrementally, test thoroughly, and remember that the best skills solve specific, repeatable problems. Your future self will thank you when your agent handles the boring stuff while you focus on work that actually matters.