CLI Samples
Practical Examples
CLI Samples
Practical examples of using Sypha CLI for common development tasks.
Quick Examples
Basic Code Generation
Generate a new feature:
sypha "Create a REST API endpoint for user registration"Add tests to existing code:
sypha "Add unit tests for src/utils/validation.js"Refactor code:
sypha "Refactor the authentication module to use async/await instead of callbacks"Image Analysis
Analyze UI screenshots:
sypha "@screenshot.png What are the accessibility issues in this UI?"Understand diagrams:
sypha "@architecture-diagram.png Explain this system architecture"Review mockups:
sypha "@"designs/mobile-app.png" Compare this design to our current implementation"Git Operations
Stage and commit changes:
# Inside Sypha CLI
> /add src/auth/*.ts
> /commit "Add JWT authentication module"
> /pushView detailed diffs:
> /diff
> /diff --stagedUndo last change:
> /undoUse Cases by Category
1. Code Generation
Generate API Endpoints
sypha "Create a RESTful API for a blog with posts, comments, and users. Use Express.js and TypeScript."Output:
src/routes/posts.ts- Post routessrc/routes/comments.ts- Comment routessrc/routes/users.ts- User routessrc/controllers/- Controller implementationssrc/models/- Data modelssrc/middleware/auth.ts- Authentication middleware
Generate React Components
sypha "Create a reusable DataTable component with sorting, filtering, and pagination. Use TypeScript and Tailwind CSS."Output:
components/DataTable.tsxcomponents/DataTable.test.tsxhooks/useDataTable.tstypes/dataTable.ts
Generate Database Schemas
sypha "Create a PostgreSQL schema for an e-commerce platform with products, orders, customers, and inventory tracking."Output:
database/schema.sql- Complete schema with tables, indexes, constraintsdatabase/migrations/- Migration filesdatabase/seeds/- Seed data
2. Code Refactoring
Modernize Legacy Code
sypha "Refactor src/legacy/user-service.js to TypeScript with proper types and modern async/await patterns"Before:
function getUser(id, callback) {
db.query('SELECT * FROM users WHERE id = ?', [id], function(err, results) {
if (err) return callback(err);
callback(null, results[0]);
});
}After:
async function getUser(id: string): Promise<User> {
const results = await db.query<User>('SELECT * FROM users WHERE id = $1', [id]);
return results[0];
}Extract Reusable Utilities
sypha "Extract repeated validation logic from src/controllers/*.ts into reusable utility functions"Output:
utils/validators.ts- Extracted validation functions- Updated controller files with cleaner code
Improve Code Structure
sypha "Split src/app.ts into separate modules following the single responsibility principle"Output:
src/app.ts- Main app setup (simplified)src/config/- Configuration managementsrc/middleware/- Middleware functionssrc/routes/- Route definitionssrc/services/- Business logic
3. Testing
Generate Unit Tests
sypha "Generate comprehensive unit tests for src/services/payment.ts using Jest"Output:
// src/services/payment.test.ts
describe('PaymentService', () => {
describe('processPayment', () => {
it('should process valid payment successfully', async () => {
// Test implementation
});
it('should reject invalid card numbers', async () => {
// Test implementation
});
it('should handle payment gateway timeouts', async () => {
// Test implementation
});
});
});Generate Integration Tests
sypha "Create integration tests for the authentication API endpoints using supertest"Output:
tests/integration/auth.test.ts- Test setup and teardown
- Database fixtures
- API endpoint tests
Generate E2E Tests
sypha "Write Playwright E2E tests for the user registration flow"Output:
e2e/registration.spec.ts- Page object models
- Test utilities
4. Documentation
Generate API Documentation
sypha "Generate OpenAPI/Swagger documentation for all API routes in src/routes/"Output:
docs/openapi.yaml- Complete API specification- JSDoc comments in route files
Generate README
sypha "Create a comprehensive README.md for this project with setup instructions, architecture overview, and usage examples"Output:
README.md- Professional documentation with:- Project overview
- Installation steps
- Configuration guide
- Usage examples
- API documentation
- Contributing guidelines
- License information
Generate Code Comments
sypha "Add JSDoc comments to all functions in src/utils/ explaining parameters, return values, and usage"5. Debugging
Analyze Error Logs
sypha "@error.log Analyze these error logs and identify patterns. What's the root cause?"Debug Performance Issues
sypha "The API /api/users endpoint is slow. Profile it and suggest optimizations."Sypha will:
- Analyze the endpoint code
- Identify bottlenecks (N+1 queries, missing indexes, etc.)
- Suggest specific optimizations
- Implement fixes with your approval
Find Memory Leaks
sypha "I'm seeing increasing memory usage in the Node.js app. Help me find the leak."Sypha will:
- Add memory profiling instrumentation
- Analyze object retention
- Identify closure issues
- Suggest fixes
6. Migration & Conversion
Migrate Between Frameworks
sypha "Migrate this Express.js app to Fastify while maintaining the same API"Convert Between Languages
sypha "Convert this Python script to TypeScript: @script.py"Update Dependencies
sypha "Update the codebase from React 17 to React 18, handling all breaking changes"7. Infrastructure as Code
Generate Terraform
sypha "Create Terraform configuration for deploying this app to AWS with EC2, RDS, and S3"Output:
terraform/main.tfterraform/variables.tfterraform/outputs.tfterraform/modules/
Generate Docker Configuration
sypha "Create a production-ready Dockerfile and docker-compose.yml for this Node.js + PostgreSQL app"Output:
Dockerfile- Multi-stage builddocker-compose.yml- Services configuration.dockerignore
Generate CI/CD Pipelines
sypha "Create a GitHub Actions workflow for testing, building, and deploying to AWS"Output:
.github/workflows/ci-cd.yml- Test, build, and deploy stages
- Environment-specific configurations
Advanced Workflows
Multi-Step Feature Development
Scenario: Implementing a complete notification system
# Step 1: Plan the architecture
$ /mode plan
> Design a notification system with email, SMS, and push notifications.
> Include queuing, retry logic, and template management.
# Sypha creates detailed plan
# Step 2: Implement core logic
$ /mode code
[Ctrl+Y to enable auto-edit]
> Implement the notification service based on the plan
# Step 3: Add tests
> Generate unit tests for the notification service
# Step 4: Add API endpoints
> Create REST API endpoints for sending notifications
# Step 5: Review all changes
$ /diff --staged
# Step 6: Commit in logical chunks
$ /add src/services/notification/*.ts
$ /commit "Add notification service with email/SMS/push support"
$ /add src/routes/notifications.ts
$ /commit "Add notification API endpoints"
$ /add tests/
$ /commit "Add comprehensive tests for notification system"
# Step 7: Push everything
$ /pushCross-Project Session Management
Scenario: Working on multiple related projects
# Project A - Main API
$ cd ~/projects/api
$ sypha "Add rate limiting to all endpoints"
# ... work ...
$ /session save "api-rate-limiting"
$ exit
# Project B - Frontend
$ cd ~/projects/frontend
$ sypha "Update API client to handle rate limit errors"
# ... work ...
$ /session save "frontend-rate-limit-handling"
$ exit
# Project C - Shared Library
$ cd ~/projects/shared-lib
$ sypha "Add rate limit types to shared package"
# ... work ...
$ /session save "shared-lib-rate-limit-types"
$ exit
# Later: Resume any project
$ cd ~/projects/api
$ sypha
$ /session list
$ /session select api-rate-limiting
# Continue where you left offAI Model Comparison
Scenario: Compare different models for code generation
# Try Claude Sonnet
$ /provider anthropic
$ /model claude-sonnet-4-5
> Implement a binary search tree in TypeScript
# Save the implementation
$ /checkpoint create "claude-bst-implementation"
# Try GPT-4
$ /provider openai
$ /model gpt-4
$ /undo # Undo Claude's changes
> Implement a binary search tree in TypeScript
# Compare implementations
$ /diff
# Review differences between models' approaches
# Choose the best implementation
# Or cherry-pick features from bothDebugging with Checkpoints
Scenario: Experimental debugging approach
$ /mode debug
> API endpoint /api/orders is returning 500 errors
# Create checkpoint before making changes
$ /checkpoint create "Before debugging orders endpoint"
# Try fix #1: Increase timeout
> Increase the database query timeout to 30 seconds
# Test it... doesn't work
# Restore and try different approach
$ /checkpoint restore <checkpoint-id>
# Try fix #2: Add connection pooling
> Configure database connection pooling
# Test it... still doesn't work
# Restore and try different approach
$ /checkpoint restore <checkpoint-id>
# Try fix #3: Fix N+1 query problem
> Optimize the orders query to use JOIN instead of separate queries
# Test it... works!
# Commit the working fix
$ /commit "Fix N+1 query in orders endpoint"Command Chaining Examples
Quick Feature Implementation
$ sypha "Add user profile page" &&
/add src/pages/Profile.tsx &&
/commit "Add user profile page" &&
/pushTesting Workflow
$ sypha "Add tests for auth module"
# After tests are generated
> /checkpoint create "Added auth tests"
> ! npm test
# If tests fail, refine with Sypha
# If tests pass:
> /commit "Add comprehensive auth module tests"Documentation Generation
$ sypha "Generate JSDoc for all files in src/services/"
$ /add src/services/
$ /commit "docs: Add JSDoc comments to service layer"Tips and Tricks
Use Specific Instructions
❌ Vague:
sypha "Make the code better"✅ Specific:
sypha "Refactor the authentication module to:
1. Use async/await instead of callbacks
2. Add proper error handling with custom error types
3. Extract validation logic into separate functions
4. Add JSDoc comments"Leverage Image Support
Upload error screenshots, UI mockups, or architecture diagrams:
# Debug based on screenshot
sypha "@error-screenshot.png This error appears when users click the submit button. Why?"
# Implement from design
sypha "@figma-export.png Implement this design in React with Tailwind CSS"
# Understand architecture
sypha "@system-diagram.png Explain this architecture and suggest improvements"Use Shell Commands
Run tests, builds, or other commands without leaving Sypha:
> ! npm test
> ! npm run build
> ! git status
> ! docker-compose up -dSave Important Sessions
Don't lose important work:
# After completing a major feature
$ /session save "user-authentication-implementation"
$ /session favorite <session-id>
# Add descriptive notes
$ /session rename <session-id> "JWT Auth + OAuth2 + 2FA Implementation"Quick Mode Switching
Use keyboard shortcuts for faster workflows:
# Shift+Tab for quick mode switch
[Shift+Tab] → Select "debug"
[Shift+Tab] → Select "plan"
[Shift+Tab] → Select "code"Export Sessions for Team Collaboration
Share your work with team members:
$ /export session <session-id> --format json
$ /export session <session-id> --format markdown
# Share the exported file with your team
# They can review your conversation and decisionsLooking for specific command syntax and options? Check the CLI Reference for complete documentation.