Convex CLI expert for serverless backend and real-time database. Use when users need to deploy functions, manage environments, or import/export data.
Resources
1Install
npx skillscat add leobrival/topographic-plugins-official/convex-cli Install via the SkillsCat registry.
Convex CLI Guide
Convex is a serverless backend platform with a built-in real-time database. This guide provides essential workflows and quick references for common Convex operations.
Quick Start
# Check CLI installation
convex --version
# Authenticate with Convex
convex login
# Initialize new project
convex init
# Start local development
convex dev
# Deploy to production
convex deploy
# View deployment status
convex deployments listCommon Workflows
Workflow 1: Local Development Setup
# Login and initialize
convex login
convex init
# Start dev server with hot reload
convex dev
# Dev server runs at http://localhost:3210
# Changes to functions auto-reload
# Dashboard shows data and logs in real-timeWorkflow 2: Develop and Deploy Functions
# Create function in convex/queries/ or convex/mutations/
# Test function locally
convex run queries/getUser --args '{"id": "123"}'
# Deploy to production
convex deploy --typecheck
# Monitor logs
convex logs --prod --followWorkflow 3: Environment Configuration
# Set API keys for current environment
convex env set API_KEY sk_test_123
convex env set DATABASE_URL postgres://...
# Set production secrets
convex env set SECRET_KEY value --prod
# List all variables
convex env listWorkflow 4: Data Import & Export
# Export data before major changes
convex export --all --output backup.json
# Import seed data
convex import users seed-users.json
# Batch import multiple tables
convex import --all data/
# Backup production data
convex export --all --prod --output prod-backup.jsonWorkflow 5: Debugging Production Issues
# Stream production logs
convex logs --prod --follow
# Filter logs by function
convex logs --function myFunction --level error
# Test function in production
convex run queries/getUser --args '{"id": "123"}' --prod
# View all function executions
convex dashboard --logsDecision Tree
When to use which command:
- To start developing: Use
convex devfor local server with hot reload - To test functions locally: Use
convex run function-name --args '...' - To deploy code: Use
convex deploywith--typecheckand--dry-runfirst - To manage secrets: Use
convex env set/get/listcommands - To backup data: Use
convex export --all --output backup.json - To restore data: Use
convex import table-name file.json - To view logs: Use
convex logs --followfor real-time monitoring - For detailed command syntax: See Commands Reference
- For complex workflows: See Common Patterns
- For troubleshooting: See Troubleshooting Guide
Common Patterns
Development Cycle
# 1. Start development
convex dev
# 2. Edit functions in convex/queries/, convex/mutations/
# 3. Test locally
convex run queries/myFunction --args '{"key": "value"}'
# 4. Type check and deploy
convex deploy --typecheck
# 5. Monitor
convex logs --prod --followSafe Deployments
# Preview changes
convex deploy --dry-run
# Deploy with message
convex deploy --message "feat: added user authentication"
# Monitor after deploy
convex logs --prod --limit 50Environment Setup
# Development variables
convex env set NODE_ENV development
convex env set LOG_LEVEL debug
# Production variables
convex env set NODE_ENV production --prod
convex env set LOG_LEVEL error --prod
# Verify variables
convex env list
convex env list --prodData Management
# Regular backups
convex export --all --output "backup-$(date +%Y-%m-%d).json"
# Seed data for testing
convex import users test-data/users.json
# Database migrations
convex export --all --output pre-migration.json
# Update schema.ts
convex deploy
# Verify with: convex run queries/checkSchemaTroubleshooting
Common Issues:
Dev server won't start
- Solution: Use
convex dev --clear-deploymentto reset state - See: Development Server Issues
- Solution: Use
Function not found error
- Quick fix: Ensure function is exported and path is correct
- See: Function Not Found
Environment variables not loading
- Quick fix: Run
convex env set KEY valueand redeploy - See: Environment Variable Issues
- Quick fix: Run
Deployment fails with type errors
- Quick fix: Run
convex deploy --typecheckto check types first - See: Deployment Issues
- Quick fix: Run
Cannot access production data
- Quick fix: Use
--prodflag with commands - See: Access Issues
- Quick fix: Use
For detailed troubleshooting steps, see the Troubleshooting Guide.
Reference Files
Load as needed for detailed information:
Commands Reference - Complete CLI command documentation with all flags and options. Use when you need exact syntax or flag details for any Convex command.
Common Patterns - Real-world patterns and workflows for development, data management, deployment, team collaboration, monitoring, and CI/CD integration. Use for implementing specific workflows or integrations.
Troubleshooting Guide - Detailed error messages, diagnosis steps, and resolution strategies for authentication, development, deployment, functions, data, environment, and configuration issues. Use when encountering errors or unexpected behavior.
When to use each reference:
- Use Commands Reference when you need exact syntax, flag combinations, or comprehensive command documentation
- Use Common Patterns for implementing multi-environment setups, production configurations, or CI/CD pipelines
- Use Troubleshooting when dev server won't start, deployments fail, logs aren't showing, or you encounter permission/access/performance issues
Resources
- Official Docs: https://docs.convex.dev
- Dashboard: https://dashboard.convex.dev
- API Reference: https://docs.convex.dev/api
- Community: https://discord.gg/convex