Sypha AI Docs
CLI

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"
> /push

View detailed diffs:

> /diff
> /diff --staged

Undo last change:

> /undo

Use 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 routes
  • src/routes/comments.ts - Comment routes
  • src/routes/users.ts - User routes
  • src/controllers/ - Controller implementations
  • src/models/ - Data models
  • src/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.tsx
  • components/DataTable.test.tsx
  • hooks/useDataTable.ts
  • types/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, constraints
  • database/migrations/ - Migration files
  • database/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 management
  • src/middleware/ - Middleware functions
  • src/routes/ - Route definitions
  • src/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:

  1. Analyze the endpoint code
  2. Identify bottlenecks (N+1 queries, missing indexes, etc.)
  3. Suggest specific optimizations
  4. 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:

  1. Add memory profiling instrumentation
  2. Analyze object retention
  3. Identify closure issues
  4. 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.tf
  • terraform/variables.tf
  • terraform/outputs.tf
  • terraform/modules/

Generate Docker Configuration

sypha "Create a production-ready Dockerfile and docker-compose.yml for this Node.js + PostgreSQL app"

Output:

  • Dockerfile - Multi-stage build
  • docker-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
$ /push

Cross-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 off

AI 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 both

Debugging 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" &&
  /push

Testing 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 -d

Save 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 decisions

Looking for specific command syntax and options? Check the CLI Reference for complete documentation.

On this page