Production-ready patterns for Apify SDK and apify-client in TypeScript.

MITAuto-check passedData & Analytics

Install Apify SDK Patterns

skills CLI
$ npx skills add jeremylongshore/tons-of-skills-marketplace --skill apify-sdk-patterns -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install jeremylongshore/tons-of-skills-marketplace apify-sdk-patterns --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/jeremylongshore/tons-of-skills-marketplace.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/.curated/apify-sdk-patterns .claude/skills/apify-sdk-patterns && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
apify-sdk-patterns
GitHub stars
2.8k
Token cost
~1.4k tokens
SKILL.md length
506 words
Files
3 (incl. references)
Skills in repo
3,342
Repo updated
First seen
Licence
MIT

At a glance

Production-ready patterns for Apify SDK and apify-client in TypeScript.

  • Building Actors with Crawlee
  • SKILL.md covers Overview, Prerequisites, Instructions and Output, plus 4 more sections
  • Needs APIFY_TOKEN
  • Managing datasets/KV stores

What it does

Apify SDK Patterns is an agent skill from jeremylongshore/tons-of-skills-marketplace. Production-ready patterns for Apify SDK and apify-client in TypeScript. Use when building Actors with Crawlee, managing datasets/KV stores, or implementing robust client wrappers with retry and validation. Trigger with "apify SDK patterns", "apify best practices", "apify client wrapper", "crawlee patterns", "idiomatic apify".

Its SKILL.md is about 1.4k tokens, which your agent loads only when the skill is triggered. The skill folder holds 3 other files, including reference files (for example `references/examples.md` and `references/patterns.md`). Compatibility notes: Designed for Claude Code

It sits in Data & Analytics, covering Web scraping. It works with Apify and TypeScript. The repository describes itself as: Model-agnostic agent-skills platform with a harness-free canonical layer, verified adapters, and the ccpi package manager. Explore at tonsofskills.com. The licence is MIT.

When your agent uses it

  • Building Actors with Crawlee
  • Managing datasets/KV stores
  • Implementing robust client wrappers with retry and validation
  • With apify SDK patterns

Example prompts

  • “apify SDK patterns”
  • “apify best practices”
  • “apify client wrapper”
  • “/apify-sdk-patterns”

Requirements

  • A credential in APIFY_TOKEN
  • Compatibility (from SKILL.md): Designed for Claude Code
  • Pre-approved tools (allowed-tools): Read, Write, Edit

What it can do on your machine

Read from SKILL.md and the folder at commit 80f86df. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Read
    • Write
    • Edit

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are typescript).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • docs.apify.com
    • crawlee.dev

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names these keys or tokens, usually read from environment variables:

    • APIFY_TOKEN

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

  • Compatibility

    Designed for Claude Code

    From compatibility in the SKILL.md frontmatter.

Context cost

Apify SDK Patterns loads about 1.4k tokens when it runs, and up to ~4.5k if it reads all its reference files. Until then it costs about 87 tokens; SKILL.md has 506 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~87
When it runs · the whole SKILL.md, loaded when a task matches
~1.4k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~4.5k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from jeremylongshore/tons-of-skills-marketplace at commit 80f86df, republished under its MIT licence (© jeremylongshore). 506 words, ~1,425 tokens.

Download SKILL.mdSave it as .claude/skills/apify-sdk-patterns/SKILL.md (or your agent's skills folder). This skill also uses 2 other files; get the full folder from GitHub.
name
apify-sdk-patterns
description
Production-ready patterns for Apify SDK and apify-client in TypeScript. Use when building Actors with Crawlee, managing datasets/KV stores, or implementing robust client wrappers with retry and validation. Trigger with "apify SDK patterns", "apify best practices", "apify client wrapper", "crawlee patterns", "idiomatic apify".
allowed-tools
Read, Write, Edit
compatibility
Designed for Claude Code
version
1.5.0
license
MIT
author
Jeremy Longshore <jeremy@intentsolutions.io>
tags
saas, scraping, automation, apify

Apify SDK Patterns

Overview

Production patterns for both the apify SDK (building Actors) and apify-client (calling Actors remotely). Covers Crawlee crawler selection, data storage, proxy configuration, and typed client wrappers. This skill gives you the essential skeletons inline; the full eight-pattern catalog and two worked scenarios live in references/ for progressive drill-down.

Prerequisites

  • Install what you need: apify-client for calling Actors remotely, or apify + crawlee for building Actors. Both can coexist in one project.
  • Set APIFY_TOKEN in the environment — read it via process.env.APIFY_TOKEN, never hard-code it. This is the only credential these patterns require (Apify uses a personal API token, not OAuth).
  • TypeScript is recommended; every snippet here is typed and runs under ts-node or a compiled build.

Instructions

Use the two skeletons below to start, then reach into the reference catalog for the pattern that matches your task.

Pattern 1: Typed Client Singleton

Create one lazily-initialized, token-validated ApifyClient and reuse it everywhere. A resetClient() hook keeps it testable.

typescript
// src/apify/client.ts
import { ApifyClient } from 'apify-client';

let instance: ApifyClient | null = null;

export function getApifyClient(): ApifyClient {
  if (!instance) {
    const token = process.env.APIFY_TOKEN;
    if (!token) throw new Error('APIFY_TOKEN is required');
    instance = new ApifyClient({ token });
  }
  return instance;
}

// Reset for testing
export function resetClient(): void {
  instance = null;
}
Pattern 2: Crawlee Crawler Selection

Choose the crawler that matches the page, not the other way around:

typescript
import { CheerioCrawler, PlaywrightCrawler, PuppeteerCrawler } from 'crawlee';

// CHEERIO — Fast, lightweight, no JavaScript rendering
// Use for: static HTML, server-rendered pages, APIs
// PLAYWRIGHT — Full browser, all engines, modern API
// Use for: SPAs, JavaScript-heavy pages, complex interactions
// PUPPETEER — Chromium-only browser automation
// Use for: when you need Chromium specifically or legacy Puppeteer code
Patterns 3–8: Full catalog

The remaining six patterns are moved verbatim into patterns.md so this file stays scannable. Pick the one you need:

  • Pattern 3 — Actor lifecycle with error handling: Actor.main() wrapping input validation, conditional proxy, and a failedRequestHandler.
  • Pattern 4 — Dataset operations: push from inside an Actor; list/create/download from an external app.
  • Pattern 5 — Key-value store operations: JSON config and binary artifacts by content type.
  • Pattern 6 — Proxy configuration: datacenter vs residential vs SERP tiers.
  • Pattern 7 — Router for multi-page Actors: labeled listing/detail handlers.
  • Pattern 8 — Safe result wrapper: discriminated-union Result<T> around remote calls.

See patterns.md for the complete code of all six.

Show full SKILL.md (226 more words)Show less

Output

Applying these patterns yields:

  • A single reusable ApifyClient instance with fail-fast token validation.
  • Actors that store structured records in the default dataset (downloadable as CSV/JSON) and named config/artifacts in key-value stores.
  • Remote Actor calls that resolve to a typed Result<T> — callers branch on error instead of catching exceptions.
  • Failed requests captured as { url, error, '#isFailed': true } rows rather than aborting the crawl.

Error Handling

PatternUse CaseBenefit
Actor.main()Actor entry pointAuto init/exit + error reporting
failedRequestHandlerPer-request failuresLog failures without stopping crawl
Safe wrapperExternal callsPrevents uncaught exceptions
RouterMulti-page scrapesClean separation of page types
Proxy rotationAnti-bot sitesHigher success rate

Examples

Two runnable end-to-end scenarios live in examples.md:

  • Example A — Call a remote Actor safely from an app: composes the client singleton (Pattern 1) with the safe result wrapper (Pattern 8) to run apify/web-scraper and read its dataset without ever throwing.
  • Example B — A two-tier product scraper Actor: composes crawler selection (Pattern 2), the router (Pattern 7), and dataset writes (Pattern 4) into a listing → detail → structured-record flow.

Resources

Next Steps

Apply these patterns in apify-core-workflow-a for a complete build-and-deploy web scraping workflow, or pair them with apify-common-errors when hardening an Actor for production.

© jeremylongshore, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 2 other files (references) in skills/.curated/apify-sdk-patterns of jeremylongshore/tons-of-skills-marketplace.

  • SKILL.md
  • references/examples.md
  • references/patterns.md

Open the folder on GitHubat commit 80f86df

Compare with similar skills

Apify SDK Patterns next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Apify SDK Patterns compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Apify SDK Patterns this skilljeremylongshore/tons-of-skills-marketplace2.8k—~1.4kAutomated safety check: PassMIT
Apify Orchestrator Actor Developmentapify/awesome-skills265—~3kAutomated safety check: WarnApache-2.0
Apify Actor Developmentapify/agent-skills2.4k—~2.9kAutomated safety check: PassNone
Reddit Post Findergooseworks-ai/goose-skills1.2k1 repos~1.2kAutomated safety check: PassMIT
Apify CLIapify/apify-cli256—~1.5kAutomated safety check: PassApache-2.0
Apify Collectextrasmall0/dear-hiring-manager112—~1.1kAutomated safety check: NotesMIT

Similar skills

  • Official

    Build TypeScript Apify orchestrator Actors — coordinate a sequence of sub-Actors (optionally with an LLM step) using the apify-orchestrator library.

    265 GitHub stars~3k tokensUpdated 16 days ago
    Data & AnalyticsAuto-check: warnings
  • Apify Actor Development

    apify/agent-skills

    Official

    Creates, changes, debugs and deploys Apify Actors, including their input and output schemas, using the Apify CLI.

    2.4k GitHub stars~2.9k tokensUpdated today
    Data & AnalyticsAuto-check passed
  • Reddit Post Finder

    gooseworks-ai/goose-skills

    Scrape and search Reddit posts using Apify. An agent skill from gooseworks-ai/goose-skills.

    1.2k GitHub starsUsed in 1 repo~1.2k tokens
    Data & AnalyticsAuto-check passed
  • Apify CLI

    apify/apify-cli

    Official

    Patterns for invoking the Apify CLI (apify) from agents. An agent skill from apify/apify-cli.

    256 GitHub stars~1.5k tokensUpdated today
    Data & AnalyticsAuto-check passed
  • Apify Collect

    extrasmall0/dear-hiring-manager

    Collect fresh job-posting URLs into ~/.dear-hiring-manager/urls.txt by running an Apify job scraper — the discovery source for /batch.

    112 GitHub stars~1.1k tokensUpdated 2 mo ago
    Data & AnalyticsAuto-check: notes
  • Apify Lead Scoring Enrichment

    apify/awesome-skills

    Official

    Score and enrich a CSV of B2B leads using Apify Actors. An agent skill from apify/awesome-skills.

    265 GitHub stars~4.4k tokensUpdated 16 days ago
    Data & AnalyticsAuto-check: notes

More from jeremylongshore/tons-of-skills-marketplace

All 3,342 skills in this repo
  • Performing Security Code Review

    jeremylongshore/tons-of-skills-marketplace

    Execute this skill enables AI assistant to conduct a security-focused code review using the security-agent plugin.

    2.8k GitHub starsUsed in 2 repos~1.3k tokens
    Auto-check: notes
  • Adapting Transfer Learning Models

    jeremylongshore/tons-of-skills-marketplace

    Build this skill automates the adaptation of pre-trained machine learning models using transfer learning techniques.

    2.8k GitHub stars~1.1k tokensUpdated today
    Auto-check passed
  • Agent Context Loader

    jeremylongshore/tons-of-skills-marketplace

    Execute proactive auto-loading: automatically detects and loads agents.md files.

    2.8k GitHub stars~1.1k tokensUpdated today
    Auto-check passed
  • Aggregating Performance Metrics

    jeremylongshore/tons-of-skills-marketplace

    Aggregate and centralize performance metrics from applications, systems, databases, caches, and services.

    2.8k GitHub stars~1.2k tokensUpdated today
    Auto-check passed
  • Analyzing Capacity Planning

    jeremylongshore/tons-of-skills-marketplace

    Execute this skill enables AI assistant to analyze capacity requirements and plan for future growth.

    2.8k GitHub stars~947 tokensUpdated today
    Auto-check passed
  • Analyzing Database Indexes

    jeremylongshore/tons-of-skills-marketplace

    Process use when you need to work with database indexing. An agent skill from jeremylongshore/tons-of-skills-marketplace.

    2.8k GitHub stars~2k tokensUpdated today
    Auto-check passed

Works with

Questions about Apify SDK Patterns

What does Apify SDK Patterns do?

Production-ready patterns for Apify SDK and apify-client in TypeScript. Apify SDK Patterns is an agent skill from jeremylongshore/tons-of-skills-marketplace. Production-ready patterns for Apify SDK and apify-client in TypeScript.

When should I use Apify SDK Patterns?

Apify SDK Patterns fits situations like: building Actors with Crawlee; managing datasets/KV stores; implementing robust client wrappers with retry and validation; with apify SDK patterns.

How do I install Apify SDK Patterns in Claude Code?

Run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill apify-sdk-patterns -a claude-code`. Or copy the skill folder (skills/.curated/apify-sdk-patterns in jeremylongshore/tons-of-skills-marketplace) into .claude/skills/apify-sdk-patterns in your project. Claude Code loads it when a task matches its description.

How do I install Apify SDK Patterns in Codex?

Run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill apify-sdk-patterns -a codex`. Or copy the skill folder (skills/.curated/apify-sdk-patterns in jeremylongshore/tons-of-skills-marketplace) into .agents/skills/apify-sdk-patterns in your project. Codex loads it when a task matches its description.

Can I use Apify SDK Patterns in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill apify-sdk-patterns -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/apify-sdk-patterns, .gemini/skills/apify-sdk-patterns, .github/skills/apify-sdk-patterns and .opencode/skills/apify-sdk-patterns in your project.

What does Apify SDK Patterns need to run?

Going by SKILL.md and its folder, Apify SDK Patterns needs credentials named APIFY_TOKEN. Our summary lists: A credential in APIFY_TOKEN. Its frontmatter pre-approves these tools: Read, Write, Edit. Compatibility (from SKILL.md): Designed for Claude Code.

Does Apify SDK Patterns access the network?

SKILL.md names 2 domains. As links in the text: docs.apify.com and crawlee.dev. This is read from the text; nothing was executed.

Is Apify SDK Patterns safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Apify SDK Patterns use?

Apify SDK Patterns is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Apify SDK Patterns use?

About 1.4k tokens (SKILL.md is roughly 5.7k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 3.1k tokens, read only when the agent opens those files.

What are the alternatives to Apify SDK Patterns?

Skills that share tags, products or a category with Apify SDK Patterns: Apify Orchestrator Actor Development (apify/awesome-skills, 265 stars), Apify Actor Development (apify/agent-skills, 2.4k stars), Reddit Post Finder (gooseworks-ai/goose-skills, 1.2k stars) and Apify CLI (apify/apify-cli, 256 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Apify SDK Patterns?

jeremylongshore (a GitHub user) maintains it in jeremylongshore/tons-of-skills-marketplace, which has 2,825 GitHub stars. The repository holds 3,342 skills in this directory. The repository was last updated on October 9, 2026.

Source: jeremylongshore/tons-of-skills-marketplace on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.