Guidance for Claude Code working in this repository. Humans should read README.md and CONTRIBUTING.md first.
apifyCLI —src/entrypoints/apify.tsactorCLI —src/entrypoints/actor.ts
Run pnpm run lint && pnpm run format && pnpm run build && pnpm run test:local before pushing. Run pnpm run test:api too if you changed anything that touches the Apify API.
If you modified a command's flags, args, description, or added/removed a command, also run pnpm run update-docs and commit the regenerated docs/ output.
- Package manager: pnpm 10 (via Corepack). Do not use npm or yarn.
- Use
.jsimport specifiers for local files (e.g.import { foo } from './foo.js'). The.tssource resolves at build time. - Commands extend
ApifyCommandfromsrc/lib/command-framework/apify-command.ts. Follow the pattern of existing commands:static override name,static override description,static override flags/args, and anasync run()method. - New commands must be registered in
src/commands/_register.ts(or the parent_index.tsfor subcommands). - Do not add docstrings, comments, or type annotations to code you did not change. Keep diffs tight.
The CLI is installed globally by many users and in Actors, so keep the npm install footprint lean. Always look for opportunities to shrink it:
- Prefer Node.js built-ins over dependencies, and prefer dependencies already in the tree over new ones.
- Before adding a dependency, check what it drags in:
npm install <pkg>in an empty temp dir, thendu -sh node_modules. Mention the install-size impact in the PR description. - When touching code that uses a dependency, check whether the dependency is still pulling its weight — a single small helper from a large package is a candidate for replacement or removal.
- To measure the CLI's own footprint, run
node scripts/report-install-size.mjs— it packs the current tree and compares tarball, unpacked, and full-install sizes against the latest published version. The release workflows run it and embed the report in the GitHub release notes.
- Tests use Vitest. See CONTRIBUTING.md for
useAuthSetupanduseTempPathhook usage. - API tests must include
[api]in the test name and live intest/api/. - Always
import process from 'node:process'in command/lib code — never useglobalThis.process. This is required for test cwd mocks to work.
Keep PR descriptions concise: what changed and why, key numbers, follow-ups. Short bullet points over narration; don't restate the diff or describe the process.
- Do not use
--no-verifyto skip git hooks. Fix the underlying issue. - Do not edit
docs/by hand — it is generated bypnpm run update-docs.