@deriv-com/shiftai-cli
v1.0.12
Published
A comprehensive AI code detection and analysis CLI tool for tracking AI-generated code in projects
Downloads
9,375
Maintainers
Readme
ShiftAI CLI 🚀
AI Code Tracking and Productivity Analytics CLI for Development Teams
Track and analyze AI-generated code usage in your development workspace to measure productivity impact and optimize team workflows.
✨ Features
- 🤖 AI Code Detection - Automatically detects AI-wrapped code in multiple languages
- 🎯 AI Rules Configuration - Auto-configure AI tools to consistently mark generated code
- 🔄 Git Integration - Seamless pre-commit hooks with automated processing
- 🌐 GitHub Sync - Automatic upload to compliance repository
- 🎨 Beautiful CLI - Professional interface with colors, progress bars, and spinners
- ⚙️ Flexible Configuration - Multiple configuration methods and options
🚀 Installation
For Project Setup (Team Lead/Admin)
Install ShiftAI in your project to track AI code usage:
# 1. Install the CLI globally
npm install -g @deriv-com/shiftai-cli
# 2. Navigate to your project directory
cd your-project
# 3. Setup ShiftAI in the project
shai installFollow the interactive prompts to configure GitHub integration and organization settings.
What this does:
- Installs pre-commit hooks
- Creates project configuration
- Sets up automatic AI code tracking
For Local Development (Individual Developers)
If ShiftAI is already installed in your project, you just need to setup your GitHub token:
# Create a .env file in your project root
touch .envAdd your GitHub token to the .env file:
# GitHub Personal Access Token (required for uploads)
GITHUB_TOKEN=your_github_token_hereCreate a Personal Access Token:
- Go to GitHub → Settings → Developer settings → Personal access tokens → Tokens (classic)
- Click Generate new token → Generate new token (classic)
- Token details:
- Name:
shiftai-token - Expiration: No expiration (safe for local use)
- Scopes:
- ✅
repo→ Needed to push branches & create PRs - ✅
workflow→ Needed if PR triggers GitHub Actions - (optional)
read:org→ If you need organization info
- ✅
- Name:
- Authorize for your organization:
- Generate token and copy it immediately — you won't be able to see it again
- Click on the Configure SSO dropdown and select the org that should be accessible with this token
- Add the token to your
.envfile
That's it! The pre-commit hook will now automatically:
- Scan staged files for AI markers
- Extract AI code for productivity analytics
- Upload data to your configured repository
- Strip AI markers from source files
- Re-stage cleaned files for commit
📖 AI Code Markers
ShiftAI supports multiple AI marker formats across different languages:
JavaScript/TypeScript/Java/C/C++/C#/PHP/Go/Rust/Swift/Kotlin/Scala
// [AI]
function calculateTotal(items) {
return items.reduce((sum, item) => sum + item.price, 0);
}
// [/AI]Python/Shell/Ruby/PERL/R/YAML/TOML
# [AI]
def calculate_total(items):
return sum(item.price for item in items)
# [/AI]CSS/SCSS/Less
/* [AI] */
.button {
background: linear-gradient(45deg, #007bff, #0056b3);
border: none;
border-radius: 4px;
}
/* [/AI] */HTML/XML/Markdown
<!-- [AI] -->
<div class="card">
<h2>AI Generated Component</h2>
<p>This component was generated by AI</p>
</div>
<!-- [/AI] -->🎯 AI Rules Configuration
Ensure all AI tools consistently wrap generated code with markers!
ShiftAI can automatically configure your AI development tools to always mark generated code with the appropriate [AI] tags.
Quick Setup
# Install AI rules configuration for your project
shai rules installThis creates configuration files that instruct AI tools to automatically wrap all generated code with markers:
Automatic Configuration (IDE-based tools):
- ✅ Cursor (
.cursorrules) - Automatic AI code marking - ✅ Cline (
.clinerules+cline_instructions.md) - Automatic AI code marking - ✅ VS Code AI Extensions (
.vscode/settings.json) - Works with Cline, Continue, CodeGPT, etc. - ✅ Roo AI (
.roo_config.md) - Automatic AI code marking
Reference Files (manual copy/paste):
- 📋 ChatGPT (
.chatgpt-instructions.md) - Copy/paste at start of conversations - 📋 Claude (
.claude-instructions.md) - Copy/paste or attach file - 📋 Other AI tools (
.ai-instructions.md) - General instructions
Why Use AI Rules?
- Consistent Tracking - Ensures all team members mark AI code the same way
- No Manual Work - AI tools automatically add markers, no need to remember
- Team Standards - Enforces consistent AI code marking across your project
- Analytics Ready - All AI code gets tracked for productivity analysis
Commands
shai rules install # Install AI rules to your project
shai rules status # Show what's currently configured
shai rules uninstall # Remove AI rules from your projectAll configuration files are automatically added to .gitignore so they don't interfere with your repository.
🛠️ Commands
shai install
Sets up ShiftAI in your project with interactive configuration.
shai install [options]
Options:
-t, --token <token> GitHub personal access token
-o, --org <org> Organization name
-r, --repo <repo> Target repository for data storage
-f, --force Force reinstallationshai status
Shows current installation and configuration status.
shai statusshai analytics
Views AI code usage analytics.
shai analytics [options]
Options:
-d, --days <days> Number of days to analyze (default: 30)
-f, --format <format> Output format: table|json|csv (default: table)shai remote
Manage git remote selection for diff comparisons (for projects with multiple remotes).
shai remote # Show current remote status
shai remote --list # List all available remotes
shai remote --select # Select/change the main remoteshai rules
Configure AI tools to automatically mark generated code with AI markers.
shai rules install # Install AI rules configuration to project
shai rules uninstall # Remove AI rules configuration from project
shai rules status # Show installation statusshai remove
Removes ShiftAI from your project.
shai remove [options]
Options:
-f, --force Force removal without confirmation📋 Requirements
- Node.js >= 14.0.0
- npm >= 6.0.0
- Git repository
- GitHub personal access token (for uploads)
