Complete command reference for the cx CLI tool.
- Quick Start
- Basic Commands
- Output Options
- Output Formats
- Incremental Mode
- File Filtering
- Snapshots
- Configuration
- Advanced Options
# Install globally
npm install -g ai-context
# Generate context from current directory
cx
# Generate from specific directory
cx ./src
# Generate with a message
cx -m "feature update"| Command | Description |
|---|---|
cx |
Generate context from current directory |
cx <path> |
Generate context from specific path |
cx <path1> <path2> |
Generate context from multiple paths |
cx -h |
Show basic help |
cx -h --more |
Show detailed help |
cx -v |
Show version |
cx # Current directory
cx ./src # Specific directory
cx ./lib ./src/main.js # Multiple paths
cx ./src -m "auth api" # With descriptive message| Option | Description |
|---|---|
-o |
Output to screen (stdout) instead of file |
-t, --tree |
Display directory tree only |
--no-clipboard |
Skip copying to clipboard |
--verbose |
Show detailed progress |
cx -o # Print to screen
cx -o | head -100 # Pipe to other commands
cx -t # Show tree only
cx -t ./src ./lib # Show trees for multiple paths
cx --verbose # See detailed progressGenerate context in different formats using -f or --format.
| Format | Extension | Description |
|---|---|---|
text |
.txt |
Plain text (default) |
md |
.md |
Markdown with tables and code blocks |
json |
.json |
Structured JSON for programmatic use |
xml |
.xml |
XML format with CDATA sections |
cx -f text # Plain text (default)
cx -f md # Markdown format
cx -f json # JSON format
cx -f xml # XML format
cx ./src -f md -m "docs" # Markdown with messageMarkdown (-f md)
- Tables for metadata and file info
- Fenced code blocks with syntax highlighting
- Clean, readable structure
JSON (-f json)
- Structured data with metadata
- File array with content and stats
- Ideal for programmatic processing
XML (-f xml)
- Valid XML with proper encoding
- CDATA sections for code content
- Supports XML-based toolchains
Only include files that changed since a specific time or git reference.
| Option | Description |
|---|---|
--since <time> |
Files changed since time expression |
--git-diff <ref> |
Files changed vs git reference |
--changed |
Files changed since last cx run |
| Expression | Meaning |
|---|---|
30m |
30 minutes ago |
2h |
2 hours ago |
1d |
1 day ago |
1w |
1 week ago |
2024-01-15 |
Since specific date |
cx --since 2h # Changed in last 2 hours
cx --since 1d # Changed in last day
cx --since 2024-01-15 # Changed since date
cx --git-diff main # Changed vs main branch
cx --git-diff HEAD~5 # Changed in last 5 commits
cx --changed # Changed since last cx run- Daily standups:
cx --since 1d- What changed today - PR reviews:
cx --git-diff main- Changes in feature branch - Quick updates:
cx --changed- Only new changes
Exclude files matching glob patterns.
| Command | Description |
|---|---|
cx ignore <pattern> |
Add ignore pattern |
cx ignore rm <pattern> |
Remove pattern |
cx ignore show |
List all patterns |
cx ignore clear |
Remove all patterns |
cx ignore test |
Preview excluded files |
cx ignore "*.log" # Exclude log files
cx ignore "dist/**" # Exclude dist directory
cx ignore "**/*.test.js" # Exclude test files
cx ignore rm "*.log" # Remove pattern
cx ignore show # List patterns
cx ignore test # Preview exclusionsWhitelist files - only matching files are processed.
| Command | Description |
|---|---|
cx include <pattern> |
Add include pattern |
cx include rm <pattern> |
Remove pattern |
cx include show |
List all patterns |
cx include clear |
Remove all patterns |
cx include "src/**/*.ts" # Only TypeScript in src/
cx include "*.js" # Only JavaScript files
cx include "lib/**" # Only files in lib/
cx include rm "*.js" # Remove pattern
cx include show # List patterns
cx include clear # Reset to include all| Pattern | Matches |
|---|---|
*.js |
All .js files |
**/*.ts |
All .ts files (recursive) |
src/** |
Everything in src/ |
*.{js,ts} |
.js and .ts files |
!*.test.js |
Negation (exclude) |
Precedence Rules:
- System exclusions always apply first (node_modules, .git, binaries)
.gitignorepatterns are applied next- Include patterns act as a whitelist (if defined)
- Ignore patterns exclude from the remaining files
In Practice:
- If no include patterns: all non-excluded files are processed
- If include patterns defined: only matching files are considered
- Ignore patterns can then further exclude from included files
- Files must match include AND not match ignore to be processed
Example:
cx include "src/**" # Only files in src/
cx ignore "**/*.test.js" # But exclude test files
# Result: All files in src/ except test filesCreate point-in-time captures of your codebase.
| Option | Description |
|---|---|
-s, --snap |
Create a snapshot |
cx -s # Create snapshot
cx -s -m "before refactor" # Snapshot with message
cx -s -f json # Snapshot in JSON format- Regular context:
.aicontext/code/ - Snapshots:
.aicontext/snapshots/ - Latest file:
.aicontext/latest-context.txt
| Command | Description |
|---|---|
cx configure |
Interactive configuration |
cx show |
Show current settings |
| Setting | Description | Default |
|---|---|---|
| Auto-clipboard | Copy to clipboard automatically | Off |
| Timeout | File search timeout | 30s |
| Max file size | Maximum file size to include | 1MB |
cx configure # Interactive setup
cx show # View current config| File | Purpose |
|---|---|
~/.aicontext/config.json |
Global settings |
.aicontext/ignore.json |
Project patterns |
| Option | Description | Default |
|---|---|---|
--timeout <sec> |
File search timeout | 30 |
--max-size <MB> |
Max file size | 1 |
--clear |
Remove generated context files | - |
--clear-all |
Remove ALL context files (with confirmation) | - |
cx --timeout 60 # Longer timeout for large projects
cx --max-size 5 # Include larger files
cx --clear # Clean up code/ directory
cx --clear-all # Clean up everythingThese are automatically excluded:
- Directories:
node_modules,.git,dist,build,coverage, etc. - Files: Lock files, OS files (
.DS_Store), IDE configs - Binary files: Images, executables, archives, media files
- Large files: Files exceeding max-size limit
- Add
.aicontextto.gitignoreto keep generated files local - Use snapshots before major refactors
- Combine filters:
cx --since 1d -f mdfor daily markdown reports - Use include patterns for focused context on specific file types
- Use
cx -o | headto preview output before generating
# Core
cx # Generate from current dir
cx ./src # Generate from path
cx -m "message" # Add filename message
# Output
cx -o # To screen
cx -t # Tree only
cx -f md # Markdown format
cx -f json # JSON format
# Incremental
cx --since 2h # Last 2 hours
cx --git-diff main # Vs main branch
cx --changed # Since last run
# Filtering
cx ignore "*.log" # Exclude pattern
cx include "*.ts" # Include only pattern
cx ignore show # List ignore patterns
cx include show # List include patterns
# Snapshots
cx -s # Create snapshot
cx -s -m "backup" # With message
# Config
cx configure # Setup
cx show # View settings