Skip to content

Commit 6ef2835

Browse files
Copilotvladfrangu
andcommitted
Add agents.md file adapted from cursor rules
Co-authored-by: vladfrangu <17960496+vladfrangu@users.noreply.github.com>
1 parent 17cde9c commit 6ef2835

File tree

1 file changed

+122
-0
lines changed

1 file changed

+122
-0
lines changed

agents.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# Apify CLI - AI Agent Instructions
2+
3+
This file contains instructions for AI agents working on the Apify CLI project to understand the codebase structure, conventions, and best practices.
4+
5+
## Project Overview
6+
7+
The Apify CLI is a command-line interface that helps developers create, develop, build, and run Apify Actors, and manage the Apify cloud platform. It's built with TypeScript and uses a modular command framework.
8+
9+
## Command Development Guidelines
10+
11+
When creating new CLI commands, follow these guidelines:
12+
13+
### Command Structure
14+
15+
- **Base Class**: All commands must extend `ApifyCommand` from `src/lib/command-framework/apify-command.ts`
16+
- Import: `import { ApifyCommand } from '../lib/command-framework/apify-command.js'`
17+
- Do NOT use `BuiltApifyCommand` class
18+
19+
- **Arguments**: Import from `src/lib/command-framework/args.ts`
20+
- Import: `import { Args } from '../lib/command-framework/args.js'`
21+
- Usage example: `Args.string()`
22+
23+
- **Flags**: Import from `src/lib/command-framework/flags.ts`
24+
- Import: `import { Flags } from '../lib/command-framework/flags.js'`
25+
- Usage example: `Flags.string()`
26+
27+
### Naming Conventions
28+
29+
- Command names must be lowercase
30+
- Use dashes for separators (NOT spaces, NOT underscores)
31+
- Example: `my-command`, `validate-schema`, `push-data`
32+
33+
### Command Class Template
34+
35+
```typescript
36+
export class MyCommandCommand extends ApifyCommand<typeof MyCommandCommand> {
37+
static override name = "my-command" as const;
38+
39+
static override description = "Description of what this command does";
40+
41+
static override examples = [
42+
"$ apify my-command",
43+
"$ apify my-command --flag value"
44+
];
45+
46+
static override args = {
47+
// Define arguments here using Args.*
48+
};
49+
50+
static override flags = {
51+
// Define flags here using Flags.*
52+
};
53+
54+
async run() {
55+
// Command logic implementation
56+
}
57+
}
58+
```
59+
60+
### Command Registration
61+
62+
After creating a command:
63+
64+
1. **For general Apify commands**: Add to the end of the `apifyCommands` array in `src/commands/_register.ts`
65+
2. **For Actor-specific commands**: Add to the `actorCommands` array in `src/commands/_register.ts`
66+
67+
### Reference Examples
68+
69+
Study these existing commands for patterns and best practices:
70+
71+
- `src/commands/validate-schema.ts` - Simple command with validation
72+
- `src/commands/cli-management/upgrade.ts` - Command with flags and external API calls
73+
- `src/commands/_register.ts` - Command registration patterns
74+
75+
### File Organization
76+
77+
- Commands are organized in `src/commands/` directory
78+
- Group related commands in subdirectories (e.g., `cli-management/`, `actor-management/`)
79+
- Use descriptive filenames that match the command name
80+
81+
## Code Style and Conventions
82+
83+
### TypeScript Guidelines
84+
85+
- Always mark class properties as `static override` when extending base classes
86+
- Use proper type annotations and generics
87+
- Follow the existing import patterns and module structure
88+
89+
### Error Handling
90+
91+
- Use appropriate error codes from `src/lib/consts.ts`
92+
- Provide helpful error messages to users
93+
- Handle edge cases gracefully
94+
95+
### Configuration
96+
97+
- Actor configuration uses `.actor/actor.json` (new format)
98+
- Legacy `apify.json` is deprecated but may need migration support
99+
- Reference constants from `src/lib/consts.ts` for file paths and configurations
100+
101+
## Testing
102+
103+
- Write tests for new commands following existing patterns in the `test/` directory
104+
- Use the testing utilities and setup from the project
105+
- Test both success and error scenarios
106+
107+
## Development Workflow
108+
109+
1. Install dependencies: `yarn install`
110+
2. Run in development mode: `yarn dev:apify` or `yarn dev:actor`
111+
3. Lint code: `yarn lint` or `yarn lint:fix`
112+
4. Format code: `yarn format` or `yarn format:fix`
113+
5. Build project: `yarn build`
114+
6. Run tests: `yarn test:local` or `yarn test:all`
115+
116+
## Important Notes
117+
118+
- Always prompt users for required information if not provided
119+
- Follow the established patterns for command structure and organization
120+
- When in doubt about command type (apify vs actor), ask for clarification
121+
- Maintain backward compatibility when possible
122+
- Update documentation when adding new commands

0 commit comments

Comments
 (0)