This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
yarn build- Compile TypeScript to JavaScript in dist/ foldertsc- Direct TypeScript compilationyarn prepare- Runs build automatically before publishing
yarn lint- Run ESLint to check for code issuesyarn lint:fix- Auto-fix linting issues where possibleyarn format- Format code with Prettieryarn format:check- Check if code is properly formatted
agility generate-types- Generate TypeScript types and Zod schemas from models (supports shallow/deep content references)agility generate-types --format typescript- Generate only TypeScript interfacesagility generate-types --format zod- Generate only Zod schemasagility generate-types --output ./types- Specify custom output directory- See
docs/TYPE_GENERATION.mdfor comprehensive usage guide and examples
- Install locally:
npm linkoryarn linkto test CLI commands - Global install:
npm i @agility/cli -goryarn global add @agility/cli
This is the Agility CMS Management CLI - a Node.js/TypeScript tool for synchronizing content, models, and assets between Agility CMS instances. The CLI implements a sophisticated content migration system with dependency resolution and multi-region support.
The CLI follows a phased deployment pattern:
- Authentication - OAuth device flow with multi-region endpoint detection
- Sync/Pull - Download source instance data to
.agility-files/directory - Push - Deploy to target instance in dependency order: assets → models → containers → content → templates → pages
- BaseCommand (
src/base/BaseCommand.ts) - Base class for all CLI commands with shared authentication and validation - ConfigService (
src/config.ts) - Centralized configuration management for API endpoints and settings
- Auth (
src/auth.ts) - OAuth flow, user permissions, multi-region API endpoints - Sync (
src/sync.ts) - Downloads content using Agility content-sync SDK - Push (
src/push.ts) - Complex deployment logic with dependency resolution and ID mapping - Model (
src/model.ts) - Content model operations and validation - FileOperations (
src/fileOperations.ts) - File system operations and JSON serialization - ModelSync (
src/modelSync.ts) - Model-specific synchronization operations
- ZodSchemaGenerator (
src/services/ZodSchemaGenerator.ts) - Generates TypeScript types and Zod schemas from Agility models and containers with support for shallow/deep content references
- LoginCommand (
src/commands/LoginCommand.ts) - Handles user authentication with instance validation - PullCommand (
src/commands/PullCommand.ts) - Implements instance pull functionality - PushCommand (
src/commands/PushCommand.ts) - Implements instance push functionality - GenerateTypesCommand (
src/commands/GenerateTypesCommand.ts) - Generates TypeScript types and Zod schemas
The Push class manages complex dependency resolution:
- Models must exist before containers
- Containers before content items
- Content items before templates
- Templates before pages
- Linked content requires ID remapping after initial content creation
Authentication automatically detects API endpoints based on GUID suffixes:
- Default:
https://mgmt.aglty.io - Dev:
https://mgmt-dev.aglty.io - Canada:
https://mgmt-ca.aglty.io - Europe:
https://mgmt-eu.aglty.io - Australia:
https://mgmt-aus.aglty.io
The CLI creates a .agility-files/ directory with:
assets/- Downloaded media files and metadatacontainers/- Container definitionsmodels/- Content model definitionstemplates/- Page template definitions{locale}/- Locale-specific content and pageslogs/- Operation logs and error tracking
The codebase implements comprehensive error handling:
- Graceful degradation with skip tracking
- Detailed logging in
.agility-files/logs/instancelog.txt - Dry-run capabilities for validation
- Progress tracking with
cli-progressmultibar
@agility/management-sdk- Core API client@agility/content-sync- Specialized sync operationsyargs- CLI argument parsinginquirer- Interactive promptscli-progress- Progress barsaxios- HTTP requests for assets