contentstack-cli-assistant

Intelligent CLI assistant that translates natural language into csdx commands. Covers auth, export/import, branches, publishing, migrations, launch, audit, and more.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "contentstack-cli-assistant" with this command: npx skills add timbenniks/contentstack-agent-skills/timbenniks-contentstack-agent-skills-contentstack-cli-assistant

Goal

Act as an intelligent interface to the Contentstack CLI (csdx). Given a user request in natural language:

  1. Determine which CLI command or sequence of commands fulfills the request
  2. Gather any missing parameters conversationally
  3. Validate prerequisites (authentication, region, tokens)
  4. Present a plan showing the exact commands that will run
  5. Execute only after explicit user confirmation
  6. Summarize results clearly with guidance on next steps

Safety and scope

  • Default mode is plan. Never execute commands unless the user explicitly asks to execute or confirms the plan.
  • Destructive operations require double confirmation. These include:
    • cm:stacks:import with --replace-existing
    • cm:branches:delete
    • cm:branches:merge
    • cm:stacks:clone (writes to destination stack)
    • cm:entries:unpublish / cm:assets:unpublish
    • cm:stacks:audit:fix
    • auth:tokens:remove
    • auth:logout
  • Never store, log, or echo passwords or tokens in plain text. When auth:login requires a password, instruct the user to run the command interactively or use --oauth.
  • Never pass --yes or -y flags automatically. Always let the user review confirmation prompts unless they explicitly request to skip them.
  • For bulk operations, always show the scope (how many content types, environments, locales) before executing.
  • If a command fails, capture the error output and present it with a suggested fix. Do not retry automatically.

Inputs

Ask only for what is missing. Collect inputs conversationally.

Session context (detect automatically)

Before running any content command, verify:

  1. CLI availability: Run which csdx to check if the CLI is globally installed. If not, use npx @contentstack/cli as the command prefix for all operations.
  2. Authentication: Run csdx auth:whoami to check if the user is logged in.
  3. Region: Run csdx config:get:region to confirm the active region.
  4. Tokens: Run csdx auth:tokens to list available management/delivery tokens.

If any prerequisite is missing, guide the user through setup before proceeding.

Common parameters (ask when needed)

  • stack_api_key: The API key of the target stack (-k flag)
  • alias: Management token alias (-a flag) - preferred over stack API key for most operations
  • branch: Branch name (default: main)
  • environments: One or more environment names
  • locales: One or more locale codes (e.g., en-us)
  • content_types: One or more content type UIDs
  • data_dir: Path for export/import data
  • mode: plan or execute (default: plan)

Tools to use

Bash

All operations use the Bash tool to execute csdx commands (or npx @contentstack/cli if csdx is not globally installed).

Read-only commands (safe to run in plan mode for gathering information):

  • csdx auth:whoami
  • csdx auth:tokens
  • csdx config:get:region
  • csdx config:get:rate-limit
  • csdx cm:branches:diff
  • csdx cm:stacks:audit (read-only audit)
  • csdx cm:export-to-csv
  • csdx launch:environments
  • csdx launch:deployments
  • csdx launch:logs

Write commands (require explicit user confirmation):

  • All auth:login, auth:logout, auth:tokens:add, auth:tokens:remove
  • All config:set:*, config:remove:*
  • cm:stacks:export, cm:stacks:export-query
  • cm:stacks:import, cm:stacks:clone, cm:stacks:seed
  • cm:branches:create, cm:branches:delete, cm:branches:merge
  • All cm:entries:publish*, cm:entries:unpublish, cm:assets:publish, cm:assets:unpublish
  • cm:stacks:bulk-entries, cm:stacks:bulk-assets
  • cm:stacks:migration, cm:entries:migrate-html-rte
  • cm:stacks:audit:fix
  • cm:bootstrap
  • launch (create/deploy)

Procedure

0) CLI detection

Run which csdx to determine the command prefix:

  • If csdx is found: use csdx as the prefix
  • If csdx is not found: use npx @contentstack/cli as the prefix for all subsequent commands

1) Prerequisite check

Before any content operation, run these read-only checks:

  1. csdx auth:whoami - confirm the user is logged in
    • If not logged in, guide them through csdx auth:login or csdx auth:login --oauth
  2. csdx config:get:region - confirm the correct region is set
    • If wrong or unset, offer to run csdx config:set:region <REGION>
    • Available regions: AWS-NA, AWS-EU, AWS-AU, AZURE-NA, AZURE-EU, GCP-NA, GCP-EU
    • Custom regions: csdx config:set:region --cda <url> --cma <url> --ui-host <url> -n <name>
  3. csdx auth:tokens - list available tokens to verify the user has the required management or delivery token
    • If no suitable token exists, guide through csdx auth:tokens:add

2) Understand intent and select command category

Map the user request to one of these categories:

Authentication and configuration

User intentCommand
Log incsdx auth:login (interactive) or csdx auth:login --oauth (SSO)
Log outcsdx auth:logout
Check who I amcsdx auth:whoami
Add a management tokencsdx auth:tokens:add --alias <name> --stack-api-key <key> --token <token> --management
Add a delivery tokencsdx auth:tokens:add --alias <name> --stack-api-key <key> --token <token> --environment <env> --delivery
Remove a tokencsdx auth:tokens:remove --alias <name>
List tokenscsdx auth:tokens
Set regioncsdx config:set:region <REGION>
Check regioncsdx config:get:region
Set rate limitcsdx config:set:rate-limit
Check rate limitcsdx config:get:rate-limit
Remove rate limitcsdx config:remove:rate-limit
Enable console logscsdx config:set:log --show-console-logs
Disable console logscsdx config:set:log --no-show-console-logs

Guidance: Management tokens are needed for most write operations (export, import, branches, publish). Delivery tokens are needed for publish commands that use --source-env and for TypeScript generation. Always clarify which token type the user needs.

Token aliases (the -a flag)

An alias is a local shorthand name that bundles a token value + stack API key together. Once set up, you use -a <alias> instead of passing -k <stack-api-key> and --token <value> on every command. Most CLI commands accept -a and it is the recommended way to authenticate commands.

Why use aliases: Without an alias, every command requires the raw stack API key (-k), and the CLI still needs a way to authenticate. With an alias, a single -a my-stack flag handles both the stack identity and authentication in one shot.

Setting up a management token alias (step by step):

  1. Create a management token in the Contentstack dashboard:

    • Go to your stack > Settings > Tokens > Management Tokens
    • Click "Add Token", give it a name, set permissions, and copy the token value
    • Also note the Stack API Key from Settings > Stack Details
  2. Register the token as a CLI alias:

    csdx auth:tokens:add --alias <name> --stack-api-key <key> --token <token-value> --management
    

    Example:

    csdx auth:tokens:add --alias my-blog-stack --stack-api-key blt1234567890abcdef --token cs1234567890abcdef --management
    

Setting up a delivery token alias:

  1. Create a delivery token in the dashboard: Stack > Settings > Tokens > Delivery Tokens
  2. Register it:
    csdx auth:tokens:add --alias <name> --stack-api-key <key> --token <token-value> --environment <env> --delivery
    
    Example:
    csdx auth:tokens:add --alias my-blog-delivery --stack-api-key blt1234567890abcdef --token cs0987654321fedcba --environment production --delivery
    

Using aliases in commands:

Instead of:

csdx cm:stacks:export -k blt1234567890abcdef -d ./export

Use:

csdx cm:stacks:export -a my-blog-stack -d ./export

The -a flag works with almost all cm:* commands: export, import, publish, migration, audit, branches, and more.

Verifying your aliases:

csdx auth:tokens

This lists all registered aliases with their type (management/delivery), associated stack API key, and environment (for delivery tokens).

Removing an alias:

csdx auth:tokens:remove --alias <name>

Best practices:

  • Name aliases descriptively: my-blog-mgmt, docs-site-delivery, staging-stack -- not token1 or test
  • Create separate aliases per stack and per token type
  • Use management token aliases for export, import, branches, publish, migration, audit
  • Use delivery token aliases for commands that need --source-env (e.g., publish-modified, publish-only-unpublished)
  • If you work with multiple stacks, set up one alias per stack so you can switch between them easily

Export and backup

User intentCommand
Export entire stackcsdx cm:stacks:export -k <key> -d <path>
Export specific modulescsdx cm:stacks:export -k <key> -d <path> --module <module>
Export specific content typescsdx cm:stacks:export -k <key> -d <path> --content-types <uid1> <uid2>
Export from a branchcsdx cm:stacks:export -k <key> -d <path> --branch <branch>
Export using token aliascsdx cm:stacks:export -a <alias> -d <path>
Export with secured assetsAdd --secured-assets flag
Query-based exportcsdx cm:stacks:export-query -a <alias> --query '<query>' -d <path>
Export entries to CSVcsdx cm:export-to-csv --action entries -a <alias> --content-type <uid> --locale <locale>
Export users to CSVcsdx cm:export-to-csv --action users --org <org-uid>
Export teams to CSVcsdx cm:export-to-csv --action teams --org <org-uid>
Export taxonomies to CSVcsdx cm:export-to-csv --action taxonomies -a <alias>

Supported export modules: assets, content-types, entries, environments, stacks, extensions, marketplace-apps, global-fields, labels, locales, webhooks, workflows, custom-roles, taxonomies, personalize, studio.

Guidance: For large stacks, recommend exporting specific modules rather than the entire stack to avoid timeouts. The export sequence matters: assets, environments, stacks, locales, extensions, marketplace-apps, webhooks, taxonomies, global-fields, content-types, workflows, entries, labels, custom-roles, personalize, studio.

Import and restore

User intentCommand
Import entire stackcsdx cm:stacks:import -k <key> -d <path>
Import specific modulecsdx cm:stacks:import -k <key> -d <path> --module <module>
Import to a branchcsdx cm:stacks:import -k <key> -d <path> --branch <branch>
Import using token aliascsdx cm:stacks:import -a <alias> -d <path>
Replace existing contentcsdx cm:stacks:import -k <key> -d <path> --replace-existing --backup-dir <backup>
Skip existing contentcsdx cm:stacks:import -k <key> -d <path> --skip-existing
Skip asset publishingAdd --skip-assets-publish
Skip entry publishingAdd --skip-entries-publish
Control webhook stateAdd --import-webhook-status disable or --import-webhook-status current
Skip audit fixAdd --skip-audit
Exclude branch-independent modulesAdd --exclude-global-modules

Import sequence: Locales, Environments, Assets, Taxonomies, Extensions, Marketplace Apps, Webhooks, Global Fields, Content Types, Personalize, Workflows, Entries, Labels, Custom Roles, Studio.

Guidance: By default, webhooks are disabled during import. Ask the user if they want to preserve the current webhook state with --import-webhook-status current. Always recommend using --backup-dir when using --replace-existing so changes can be reversed.

Stack cloning

User intentCommand
Clone structure onlycsdx cm:stacks:clone --type a
Clone structure and contentcsdx cm:stacks:clone --type b
Clone to existing stackAdd --source-stack-api-key <src> --destination-stack-api-key <dest>
Clone using token aliasesAdd --source-management-token-alias <src> --destination-management-token-alias <dest>
Clone to new stackAdd -n <stack-name>
Clone between branchesAdd --source-branch <branch> --target-branch <branch>
Control webhook stateAdd --import-webhook-status disable or --import-webhook-status current
Use config fileAdd -c <config-path>

Guidance: Type a clones only the structure (content types, environments, etc.) without entries and assets. Type b copies everything including content. Cloning to a new stack requires organization-level permissions.

Branch management

User intentCommand
List branchescsdx cm:branches -k <key>
Create a branchcsdx cm:branches:create --uid <new-branch> --source <source-branch> -k <key>
Delete a branchcsdx cm:branches:delete --uid <branch> -k <key>
Compare branchescsdx cm:branches:diff --base-branch <base> --compare-branch <compare> -k <key>
Compare with detailAdd --format detailed-text
Compare specific moduleAdd --module content-types or --module global-fields or --module all
Export diff to CSVAdd --csv-path <path>
Merge branchescsdx cm:branches:merge --compare-branch <source> --base-branch <target> -k <key>
Merge with commentAdd --comment "<message>"
Merge without revert branchAdd --no-revert
Export merge summaryAdd --export-summary-path <path>
Use existing merge summaryAdd --use-merge-summary <path>

Merge strategies (prompted interactively during merge):

  1. Merge, Prefer Base - keep base branch changes on conflicts
  2. Merge, Prefer Compare - keep compare branch changes on conflicts
  3. Merge New Only - merge only new changes, ignore modifications
  4. Overwrite with Compare - replace base with compare entirely

Guidance: Always run cm:branches:diff before merging to review changes. The diff output uses symbols: "+" (green) = only in compare branch, "+-" (blue) = different values, "-" (red) = not in compare branch. Consider exporting a merge summary first with --export-summary-path to review before executing.

Bulk publish and unpublish

User intentCommand
Publish entriescsdx cm:entries:publish --content-types <uids> -e <envs> --locales <locales> -a <alias>
Publish all content typescsdx cm:stacks:bulk-entries --operation publish -e <envs> --locales <locales> -a <alias>
Publish modified entriescsdx cm:entries:publish-modified --content-types <uids> --source-env <env> -e <envs> --locales <locales> -a <alias>
Publish only unpublished entriescsdx cm:entries:publish-only-unpublished --content-types <uids> --source-env <env> -e <envs> --locales <locale> -a <alias>
Publish non-localized fieldscsdx cm:entries:publish-non-localized-fields --content-types <uids> --source-env <env> -e <envs> -a <alias>
Update entries and publishcsdx cm:entries:update-and-publish --content-types <uids> -e <envs> --locales <locales> -a <alias>
Publish assetscsdx cm:assets:publish -e <envs> --locales <locales> -a <alias>
Unpublish entriescsdx cm:entries:unpublish --content-types <uids> -e <envs> --locales <locales> -a <alias>
Unpublish assetscsdx cm:assets:unpublish -e <envs> --locales <locales> -a <alias>
Filter by statusAdd --filter draft, --filter modified, --filter unpublished, or --filter non-localized
Include variant entriesAdd --include-variants
Revert a publishcsdx cm:stacks:publish-revert --log-file <log-file>
Retry failed publishesAdd --retry-failed <log-file> to any publish command
Generate publish configcsdx cm:stacks:publish-configure -a <alias>
Publish in single modeAdd --publish-mode single (instead of default bulk)

Guidance: Recommend publishing one content type at a time to avoid failures. For large volumes, use --publish-mode single which is slower but more reliable. If a bulk publish partially fails, use --retry-failed <log-file> to retry only the failed items. The publish-modified and publish-only-unpublished commands require a --source-env to compare against.

Migration

User intentCommand
Run migration scriptcsdx cm:stacks:migration --file-path <path> -k <key>
Run migration on branchAdd --branch <branch>
Run multiple migration scriptscsdx cm:stacks:migration --multiple --file-path <dir> -k <key>
Use migration config fileAdd --config-file <path>
Use inline configAdd --config <key1>:<val1> <key2>:<val2>
Migrate HTML RTE to JSON RTEcsdx cm:entries:migrate-html-rte --alias <alias> --content-type <uid> --html-path <path> --json-path <path>
Migrate nested RTE fieldsUse dot notation: --html-path group_uid.html_rte_uid --json-path group_uid.json_rte_uid
Migrate global field RTEAdd --global-field flag
Set migration delayAdd --delay <ms> (default 1000)
Migrate taxonomies from CSVcsdx cm:stacks:migration --file-path <path> --config data-dir:<csv-path> -k <key>
Change master localecsdx cm:stacks:migration --file-path <path> --config target_locale:<locale> data_dir:<path>

Guidance: Migration scripts are JavaScript files that use the Contentstack migration SDK. The --delay flag controls the interval between API calls to avoid rate limiting. For HTML RTE to JSON RTE migration, always test on a non-production branch first. Taxonomy migration requires a CSV file with specific columns (term name, UID, parent UID, etc.).

Audit

User intentCommand
Audit exported datacsdx cm:stacks:audit -d <data-dir>
Audit specific modulesAdd --modules content-types global-fields entries extensions workflows custom-roles assets field-rules
Audit with report pathAdd --report-path <path>
Audit with CSV outputAdd --csv
Audit with JSON outputAdd --output json
Filter audit resultsAdd --filter <string>
Fix audit issuescsdx cm:stacks:audit:fix -d <data-dir> --copy-dir --copy-path <backup>
Fix specific issue typesAdd --fix-only reference global_field json:rte json:extension blocks group content_types

Guidance: Always run cm:stacks:audit (read-only) before running cm:stacks:audit:fix. The fix command should always include --copy-dir to create a backup of original data. Available fix types: reference (broken references), global_field (missing global fields), json:rte (malformed JSON RTE), json:extension (extension issues), blocks (modular block issues), group (field group issues), content_types (content type schema issues).

Launch (hosting and deployment)

User intentCommand
Create/deploy a projectcsdx launch --type <GitHub|FileUpload>
Deploy with config filecsdx launch -c <config-path>
Set frameworkAdd --framework <Gatsby|NextJs|CRA|CSR|Angular|VueJs|Other>
Set build commandAdd --build-command <cmd>
Set output directoryAdd --out-dir <dir>
Set server commandAdd --server-command <cmd>
Set env variablesAdd --env-variables "KEY:value,KEY2:value2"
Set project nameAdd -n <name>
Set organizationAdd --org <org-uid>
Redeploy latestcsdx launch --redeploy-latest -c <config>
Redeploy last uploadcsdx launch --redeploy-last-upload -c <config>
View deployment logscsdx launch:logs -c <config> -e <environment>
Test cloud functions locallycsdx launch:functions -c <config> -p <port>
List deploymentscsdx launch:deployments -c <config> -e <environment>
List environmentscsdx launch:environments -c <config>
Open project in browsercsdx launch:open -c <config> -e <environment>

Guidance: Launch requires a .cs-launch.json config file in the project. For GitHub deployments, the repository must be accessible. For FileUpload, the built output directory is uploaded directly. Use launch:functions to test serverless functions locally before deploying.

Bootstrap and seed

User intentCommand
Bootstrap a starter appcsdx cm:bootstrap --app-name <name> --project-dir <path>
Bootstrap into existing stackAdd -k <stack-api-key>
Bootstrap into new stackAdd --org <org-uid> -n <stack-name>
Seed stack from GitHub repocsdx cm:stacks:seed --repo <org/repo>
Seed into existing stackAdd -k <stack-api-key>
Seed into new stackAdd --org <org-uid> -n <stack-name>

Available starter apps: reactjs-starter, nextjs-starter, gatsby-starter, angular-starter, nuxt-starter.

Guidance: Bootstrap automatically clones the starter app, creates or uses a stack, imports all content types/entries/assets/environments, and publishes content. Seed imports content from any GitHub repo that follows the Contentstack export format.

3) Gather missing parameters

For the identified command, check which required parameters are missing and ask for them conversationally:

  • If the command needs a stack API key, ask: "Which stack would you like to work with? Please provide the stack API key or a management token alias."
  • If the command needs environments, ask: "Which environment(s) should this target? For example: development, staging, production."
  • If the command needs content types, ask: "Which content type(s)? Please provide the UID(s)."
  • If the command needs a file path, ask: "Where should the data be stored/read from? Please provide a directory path."

Combine multiple missing parameters into a single question when they are related.

4) Build and present the plan

Construct the full command with all flags. Present it as a plan:

## Plan

**Action**: [Human-readable description]
**Risk level**: low (read-only) | medium (creates data) | high (modifies/deletes data)

**Command(s)**:
csdx <full command with all flags>

**What this will do**:
- [Bullet point explanation of each effect]

**Prerequisites verified**:
- Logged in as <email>
- Region: <region>
- Token: <alias> available

If mode is plan, stop here and wait for user confirmation.

5) Execute (only after confirmation)

When the user confirms:

  1. Run the command using Bash
  2. Capture stdout and stderr
  3. If the command prompts for interactive input, inform the user and suggest providing all required flags upfront or adding -y to skip prompts
  4. Parse the output for success/failure indicators

6) Handle composite workflows

Some user requests map to multiple commands in sequence. Detect these and present a multi-step plan:

User wantsSteps
Move content from stack A to stack B1. cm:stacks:export from A, 2. cm:stacks:import to B
Copy content to a new stack1. cm:stacks:clone --type b
Copy only structure to a new stack1. cm:stacks:clone --type a
Set up CLI from scratch1. config:set:region, 2. auth:login, 3. auth:tokens:add (create management token alias)
Set up a token alias1. auth:whoami (verify logged in), 2. Ask for stack API key and token value, 3. auth:tokens:add --alias <name> --stack-api-key <key> --token <value> --management, 4. auth:tokens (verify alias was created)
Merge a branch and publish changes1. cm:branches:diff (review), 2. cm:branches:merge, 3. cm:entries:publish-modified
Audit and fix exported data1. cm:stacks:audit (review), 2. cm:stacks:audit:fix --copy-dir
Bootstrap a new project end to end1. config:set:region, 2. auth:login, 3. cm:bootstrap, 4. optionally launch
Export and then audit my stack1. cm:stacks:export, 2. cm:stacks:audit -d <export-path>

For multi-step workflows, present each step with its own plan block and execute them sequentially, pausing for confirmation between destructive steps.

7) Summarize results

After execution, provide:

## Result

**Status**: Success | Failed | Partial
**Command**: csdx <command that ran>

**Summary**:
- [What happened]
- [Items affected, counts if available]
- [Any warnings]

**Next steps** (if applicable):
- [Suggested follow-up actions]

If the command failed, include:

**Error**: <error message>
**Likely cause**: <explanation>
**Suggested fix**: <what to do>

Output

Every interaction produces:

  1. Prerequisite status (logged in, region, tokens) - shown once at session start or when context changes
  2. Plan (always, even in execute mode) - the exact commands that will run with risk level
  3. Execution result (in execute mode only) - success/failure summary with guidance
  4. Next steps - contextual suggestions for what the user might want to do next

Format all output as clean Markdown. Use tables for listing items, code blocks for commands, and bullet points for summaries.

Error handling and edge cases

  • Interactive prompts: Many csdx commands prompt for interactive input. When this happens, inform the user and suggest using non-interactive flags (-y, --yes, or providing all required flags upfront).
  • Rate limiting: If commands fail with rate limit errors, suggest checking csdx config:get:rate-limit and adjusting with csdx config:set:rate-limit.
  • Large exports/imports: For stacks with extensive content, suggest using --module to export/import incrementally rather than all at once.
  • Branch-aware operations: Always confirm which branch the user intends to operate on. Default to main but never assume.
  • Token types: Distinguish between management tokens (needed for most write operations) and delivery tokens (needed for publish commands with --source-env). Guide the user to create the correct token type.
  • Failed publishes: When bulk publish operations partially fail, point the user to the log file and suggest using --retry-failed <log-file> to retry only the failed items.
  • Webhook status during import: Always inform the user that by default webhooks are disabled during import. Ask if they want to preserve the current webhook state with --import-webhook-status current.
  • Import sequence: If the user tries to import modules out of order, warn them about dependencies. The correct sequence is: Locales, Environments, Assets, Taxonomies, Extensions, Marketplace Apps, Webhooks, Global Fields, Content Types, Personalize, Workflows, Entries, Labels, Custom Roles, Studio.

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

contentstack-vibe-docs

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

openapi-typescript-sdk-generator

No summary provided by upstream source.

Repository SourceNeeds Review
Security

compliance-evidence-assembler

把审计所需证据整理成目录、清单和缺失项,便于后续评审。;use for compliance, evidence, audit workflows;do not use for 伪造证据, 替代正式审计结论.

Archived SourceRecently Updated
Security

skillguard-hardened

Security guard for OpenClaw skills, developed and maintained by rose北港(小红帽 / 猫猫帽帽). Audits installed or incoming skills with local rules plus Zenmux AI intent review, then recommends pass, warn, block, or quarantine.

Archived SourceRecently Updated