GenLayer CLI Development Assistant
Expert assistant for working with the GenLayer CLI codebase. Provides guidance on architecture, command creation, testing, and local blockchain management.
Instructions
When working with the GenLayer CLI repository, follow these guidelines:
1. Setup & Build Commands
For initial setup and development:
Run `npm install` to install all dependenciesUse `npm run dev` for watch mode during development (uses esbuild)Use `npm run build` for production buildsTest locally with `node dist/index.js`2. Testing Strategy
When testing or adding tests:
Run full test suite with `npm test` (uses vitest)Use `npm run test:watch` for watch mode during developmentGenerate coverage reports with `npm run test:coverage`Run specific test files: `npx vitest tests/commands/deploy.test.ts`Run tests matching a pattern: `npx vitest -t "test name pattern"`3. Architecture Understanding
The codebase follows these patterns:
**Entry Point:**
`src/index.ts` is the main entry pointInitializes Commander program and registers all command groups**Command Structure:**
Commands organized by domain in `src/commands/<domain>/index.ts`Each domain exports an `initialize*Commands(program)` functionDomains include: general (init/up/stop), account, contracts, config, localnet, update, scaffold, network, transactions, staking**Core Classes:**
`BaseAction` (`src/lib/actions/BaseAction.ts`) - Base class providing: - GenLayer client initialization via `genlayer-js` SDK
- Keystore management (encrypted wallet with password)
- Spinner/logging utilities (ora, chalk)
- User prompts (inquirer)
`ConfigFileManager` (`src/lib/config/ConfigFileManager.ts`) - Manages `~/.genlayer/genlayer-config.json``KeychainManager` (`src/lib/config/KeychainManager.ts`) - System keychain integration via keytar**Key Dependencies:**
`commander` - CLI framework`genlayer-js` - GenLayer SDK for blockchain interactions`ethers` - Wallet/keystore encryption`dockerode` - Docker management for localnet`viem` - Ethereum utilities**Path Aliases:**
`@/*` maps to `./src/*``@@/tests/*` maps to `./tests/*`4. Adding New Commands
When creating a new command, follow this pattern:
1. Create action class extending `BaseAction` in `src/commands/<domain>/<action>.ts`
2. Export an action options interface for the command
3. Register the command in the domain's `index.ts` file via Commander
4. Add tests in both:
- `tests/commands/<domain>.test.ts` (integration tests)
- `tests/actions/<action>.test.ts` (action-specific tests)
5. Code Style & Patterns
Extend `BaseAction` for all CLI actions to get shared utilitiesUse the provided spinner/logging utilities (ora, chalk) for consistent UXHandle user prompts via inquirer (available through BaseAction)Follow TypeScript best practices with explicit typingKeep command logic in action classes, not in command registration6. Docker & Local Blockchain
The CLI manages a Docker-based local GenLayer blockchain:
Uses `dockerode` for Docker container managementLocal blockchain commands are in the `localnet` and general (`init`, `up`, `stop`) domainsReference GenLayer documentation at https://docs.genlayer.com/developers/intelligent-contracts/tools/genlayer-cli7. Configuration Management
Configuration stored in `~/.genlayer/genlayer-config.json`Use `ConfigFileManager` for all config operationsSensitive data stored via `KeychainManager` (system keychain)Never hardcode credentials or private keysWhen to Use This Skill
Use this skill when:
Adding new commands to the GenLayer CLIUnderstanding the CLI architecture and patternsWriting or debugging testsWorking with Docker-based local blockchainManaging configuration or keystore operationsIntegrating with the genlayer-js SDKDebugging command execution or action classes