Settings

Language

Claude Code Skills Tutorial: Setup, Invocation, and Cost

T
TokenLab
·February 26, 2026·11 min read·Updated July 26, 2026·2006 views
#claude-code#skills#developer-tools#tutorial#productivity
Claude Code Skills Tutorial: Setup, Invocation, and Cost

Questions this answers

  • How much does Claude Code skills cost through an API?
  • When should developers use Claude Code skills instead of a direct provider account?
  • How does TokenLab help compare Claude Code skills with related models?

Claude Code skills are Markdown files with YAML frontmatter that inject team-specific rules, conventions, and command templates into an agent's context window. This tutorial covers how to set up a skill file, invoke it from the CLI, pass it arguments, and estimate the token cost of running it against Claude Sonnet 5. Pricing figures below come from Anthropic's published rate card and TokenLab's live model catalog, both cited with source and observed date.


Key Takeaways

  • Skills live in .claude/skills/ (project-local) or ~/.claude/skills/ (global) and are auto-detected by the Claude Code CLI.
  • Invocation happens two ways: explicit slash-command syntax or natural-language reference inside a prompt.
  • Runtime argument passing is not fully specified in the evidence available for this article. Treat the patterns below as common conventions, not a confirmed CLI spec, and verify against Anthropic's current documentation before scripting automation around them.
  • Claude Sonnet 5 introductory pricing runs through August 31, 2026, at $2.00/MTok input and $10.00/MTok output. Standard pricing of $3.00/$15.00 per MTok begins September 1, 2026 (source: Claude Platform pricing, observed 2026-07-08).
  • TokenLab's live catalog currently prices anthropic/claude-sonnet-5 at the introductory rate ($2.00/$10.00 per MTok). These are two different sources; do not assume TokenLab pricing tracks the provider's future standard rate automatically.

Source Snapshot

Source What it covers Observed at
Claude Platform pricing (platform.claude.com/docs/en/about-claude/pricing) Official Anthropic rate card for Claude Sonnet 5, Opus 4.8, Fable 5, batch pricing 2026-07-08
TokenLab live model/pricing evidence snapshot Per-token catalog prices for models routed through TokenLab 2026-07-07
TokenLab current model SSOT List of current-generation model names valid for this content cycle 2026-07-07, expires 2026-07-14

Because the SSOT window is short-lived, re-check current model names against the TokenLab model directory before publishing automation that hardcodes a model ID.


Claude Pricing: Official Anthropic Rates

Every skill file you inject adds to your input token count, since skills are appended to the system prompt before the conversation begins. Long skill files with extensive code examples increase your bill on every request, not just the first one, unless you cache them.

Model Input (per MTok) Output (per MTok) Cache hit (per MTok) Context window Source Observed at
Claude Sonnet 5 (intro, through Aug 31, 2026) $2.00 $10.00 $0.20 1,000,000 Claude Platform pricing 2026-07-08
Claude Sonnet 5 (standard, from Sept 1, 2026) $3.00 $15.00 $0.30 1,000,000 Claude Platform pricing 2026-07-08
Claude Opus 4.8 $5.00 $25.00 $0.50 1,000,000 Claude Platform pricing 2026-07-08
Claude Fable 5 $10.00 $50.00 $1.00 1,000,000 Claude Platform pricing 2026-07-08

Batch pricing cuts Claude Sonnet 5 to $1.00/MTok input and $5.00/MTok output through August 31, 2026, per the same source. Batch mode trades immediacy for cost, so it fits scheduled skill runs (nightly test suites, doc regeneration) better than interactive coding sessions.

To see how these rates stack up against other providers on the same task, review the pricing comparison guide.


Get Verified Pricing Before You Build

Skill-heavy workflows can silently multiply your token spend across hundreds of invocations per week. Before you commit a large skill library to your repo, run a cost estimate against your actual skill file sizes and expected call volume. TokenLab's model directory surfaces live per-token pricing across providers so you can compare Claude Sonnet 5 against alternatives like DeepSeek V4 Pro or Kimi K2.7 Code before locking in a model pin.


How to Build a Custom Skill

A skill is a Markdown file with YAML frontmatter, saved in a directory Claude Code scans automatically.

Directory Structure

Claude Code checks two locations:

  1. Project-local: .claude/skills/ inside your project root, committed to Git so the whole team shares it.
  2. Global: ~/.claude/skills/ for rules applied across every project on your machine.
mkdir -p .claude/skills

If this command fails with a permission error, check that you have write access to the project root; if it fails with "no such file or directory," confirm you are running it from inside an initialized project, not a detached shell.

Skill File Syntax and Frontmatter

Create verify-and-test.md inside .claude/skills/. The frontmatter below pins the model to claude-sonnet-5, declares required environment variables, and sets skill metadata. Field names shown here follow common Claude Code frontmatter conventions; verify the exact accepted keys and their behavior against Anthropic's current Claude Code CLI reference before relying on this in a production pipeline, since the reference page was not part of the evidence set for this article.

---
name: verify-and-test
description: Reviews code changes, writes a Vitest unit test, and runs the test suite.
model: anthropic/claude-sonnet-5
env:
  - VITEST_ENV
  - DATABASE_URL
---

# Verify and Test Skill

You are an expert software engineer. Your task is to review the code changes, write a comprehensive unit test, and run the test suite.

## Instructions

1. Review Code: Analyze the modified files. Ensure they do not use deprecated APIs.
2. Write Unit Test: Create a test file in the `tests/` directory. Use Vitest.
3. Run Tests: Execute `npm run test` to verify that all tests pass.
4. Report: Provide a summary of the test results and any issues found.

## Examples

If the user asks you to verify a new utility function:
- Look for `src/utils/math.ts`.
- Create `tests/math.test.ts`.
- Run `npm run test`.

If you are choosing between coding models for this kind of workflow, the best AI models for coding in 2026 guide compares Claude Sonnet 5 against Kimi K2.7 Code, DeepSeek V4 Pro, and Gemini 3.5 Flash on price and context window.


How to Run Claude Code Skills

Explicit Invocation

claude /skill verify-and-test

This forces Claude Code to load the skill's instructions and execute the workflow directly, without waiting for the model to infer intent.

Natural Language Invocation

claude "Run the verify-and-test skill on my latest git changes"

Claude Code matches the request text to your skill name and loads the associated instructions.

Passing Arguments at Runtime

This is a common point of confusion: can you pass a value like a file path or a flag to a skill at invocation time, or must every parameter be hardcoded in the Markdown file or exported as an environment variable?

Two patterns are commonly used in practice:

  • Environment variables declared in frontmatter (as in the env block above), exported in your shell before running claude. This works for stable, session-level configuration like a database URL.
  • Natural-language arguments passed inline in the prompt, for example claude "Run verify-and-test on src/utils/math.ts only", relying on the model to parse the target from the sentence rather than a formal CLI flag.

Neither pattern is confirmed here as an officially documented, structured argument-passing mechanism (such as a $ARGUMENTS template variable). This evidence set does not include the CLI/skills reference page needed to confirm exact templating syntax. Verify against Anthropic's current documentation before building automation that depends on structured argument injection, and add a fallback: if the skill misinterprets a natural-language argument, fall back to explicit environment variables or a dedicated flag once you confirm the supported syntax.

Troubleshooting Invocation

  • If claude /skill <name> returns "skill not found," confirm the file lives in .claude/skills/ or ~/.claude/skills/ and that the filename (minus .md) matches the name field in frontmatter.
  • If the CLI hangs or times out, check network connectivity to the Anthropic API and retry once; persistent timeouts usually indicate an API-side outage rather than a skill file problem.
  • If the model ignores instructions in the skill, check whether the skill file exceeds the effective context budget once combined with your existing system prompt and conversation history; trim examples rather than adding retries.

Managing Token Costs and Model Selection

  • Keep skills concise. Avoid pasting entire codebases as examples; use short, representative snippets.
  • Use prompt caching. Skills injected into the system prompt are strong caching candidates. At standard pricing, Claude Sonnet 5 cache hits cost $0.30/MTok versus $3.00/MTok for a fresh input token, an 90% discount on that portion of the request (source: Claude Platform pricing, observed 2026-07-08).
  • Route simpler tasks to lower-cost models where the skill does not require Claude-specific behavior. Compare provider reliability and latency in the OpenRouter comparison guide.

TokenLab Live Catalog Pricing (Coding-Relevant Models)

These figures come directly from TokenLab's live model/pricing evidence snapshot, not inferred from provider rate cards. Note that claude-sonnet-5 here reflects the introductory rate; Anthropic's own published standard rate for September 2026 is listed separately in the pricing table above.

Model Provider Input (per MTok) Output (per MTok) Context window Source Observed at
claude-sonnet-5 Anthropic $2.00 $10.00 1,000,000 TokenLab live pricing snapshot 2026-07-07
claude-opus-4.8 Anthropic $5.00 $25.00 1,000,000 TokenLab live pricing snapshot 2026-07-07
deepseek-v4-pro DeepSeek $0.435 $0.87 1,048,576 TokenLab live pricing snapshot 2026-07-07
deepseek-v4-flash DeepSeek $0.09 $0.18 1,048,576 TokenLab live pricing snapshot 2026-07-07
kimi-k2.7-code Moonshot AI $0.74 $3.50 262,144 TokenLab live pricing snapshot 2026-07-07
gemini-3.5-flash Google $1.50 $9.00 1,048,576 TokenLab live pricing snapshot 2026-07-07
glm-5.2 Z.ai $0.93 $3.00 1,048,576 TokenLab live pricing snapshot 2026-07-07
gpt-5.5 OpenAI $5.00 $30.00 1,050,000 TokenLab live pricing snapshot 2026-07-07

If your pipeline generates assets beyond code, such as UI mockups or promotional media alongside a skill-driven workflow, see the best AI image models API in 2026 or best AI video models API in 2026 guides for pricing on those categories.


Best Practices

Practice Description Benefit
Version control Commit .claude/skills/ to your Git repository. Whole team runs the same coding standards.
Define inputs explicitly State what variables or files the skill expects. Reduces ambiguity and cuts down on guessed parameters.
Include negative examples Add "what not to do" sections in the Markdown. Prevents the model from repeating known past mistakes.
Test incrementally Run the skill against small diffs first. Makes debugging the skill's own instructions easier.
Cache stable skills Rely on prompt caching for skills that rarely change. Cuts repeated-input cost by roughly 90% at cache-hit pricing.

Limitations

  • This article does not link to Anthropic's dedicated Claude Code CLI or skills reference page because that URL was not present in the evidence available for this review. The only officially verified Anthropic link in this article is the pricing page cited above. Search Anthropic's current documentation site directly for exact skill file syntax and CLI flags before production use.
  • Runtime argument-passing syntax for skills (structured templating vs. natural-language parsing) is not confirmed in this evidence set. Treat the guidance above as common patterns, not a documented spec.
  • Configuration steps for running non-Anthropic models inside Claude Code are not verified in this evidence set. Claude Code is Anthropic's own CLI; if you plan to route a skill to a non-Anthropic model, confirm supported configuration in official documentation before assuming it works as shown in the frontmatter example above.
  • TokenLab catalog prices reflect a snapshot observed 2026-07-07 and may change before you read this. Re-verify current rates at the TokenLab model directory before estimating production costs.
  • No latency or throughput data for skill-augmented requests is included here; any speed claims would be unbenchmarked in this evidence set.

Frequently Asked Questions

Where should I store my Claude Code skills?

Store them locally at .claude/skills/ in your project root for project-specific rules, or globally at ~/.claude/skills/ for rules applied across every project on your machine.

Can I dynamically pass arguments to a skill at runtime?

This is not fully specified in the evidence used for this article. In practice, teams either export environment variables declared in the skill's frontmatter before invocation, or include the specific target (a file path, a flag) directly in the natural-language prompt that triggers the skill. Neither is confirmed here as a formally documented, structured argument mechanism. Verify against Anthropic's current CLI reference before automating around a specific syntax.

Can I use other models with Claude Code?

Claude Code is Anthropic's own CLI tool, and the frontmatter model field in the example above shows a common pattern for pinning a specific Claude model. Whether and how non-Anthropic models can be configured is not verified in this evidence set. If you need to compare model options for a given task regardless of which tool executes it, the TokenLab model directory lists live pricing and context windows across providers.

How do I disable a skill during a session?

Move the Markdown file out of .claude/skills/, or rename its extension so Claude Code no longer recognizes it as an active skill.

How do I pass environment variables to a skill?

Declare them under the env key in the skill's YAML frontmatter, then export those variables in your shell session before running the claude CLI command. If a required variable is missing, expect the skill to either fail with an unset-variable error or silently skip the step that depends on it, depending on how your skill's instructions handle that case; add an explicit check step in the Markdown instructions to surface missing variables rather than letting the agent guess.


Get Started with TokenLab

Finding the right model for a skill-driven workflow is a pricing and context-window decision as much as a capability one. Explore the TokenLab Code Models Category to compare current per-token pricing across Claude Sonnet 5, DeepSeek V4 Pro, Kimi K2.7 Code, and other coding-relevant models before you pin a skill to a specific model.

Sources

Price observed 2026-07-07

Share:

Related models

Recent public models

Build with the models in this guide

Compare pricing, test routes, and move from article research to a working API call.