Workflows
Learn how to effectively use MyDeskBot Desktop for common development and productivity workflows.
Getting Started with AI Assistance
Basic Conversation
You: Help me understand this error
AI: What error are you seeing? Please share the error message...
You: [Paste error message]
AI: This error indicates... Here are some solutions...Code Analysis
You: Review this code for potential issues
[Upload code file]
AI: I found several issues:
1. Line 15: Potential null reference
2. Line 23: Unused variable
3. Line 45: Missing error handlingDebugging
You: My function is returning undefined
[Show function code]
AI: The issue is that you're not returning the result. Change:
calculate(a, b) { a + b }
To:
calculate(a, b) { return a + b }Development Workflows
1. Feature Development
Step 1: Planning
You: Help me plan a new user authentication feature
AI: Here's a comprehensive plan:
1. Database schema changes
2. API endpoint creation
3. Frontend UI components
4. Integration with existing auth system
5. Testing strategyStep 2: Implementation
You: Generate the database migration for users table
AI: [Creates migration file]
CREATE TABLE users (
id SERIAL PRIMARY KEY,
email VARCHAR(255) UNIQUE NOT NULL,
password_hash VARCHAR(255) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);Step 3: Code Review
You: Review the auth API implementation
[Show API code]
AI: Overall good, but consider:
- Add rate limiting
- Implement password hashing with bcrypt
- Add input validation2. Bug Fixing
Identify the Bug:
You: The pagination isn't working correctly
[Show relevant code]
AI: The issue is in the OFFSET calculation. You're using:
offset = (page - 1) * limit
But page starts from 0 in your frontend. Change to:
offset = page * limitTest the Fix:
You: Generate unit tests for the pagination function
AI: [Creates test file]
describe('pagination', () => {
it('should calculate correct offset', () => {
expect(getOffset(2, 10)).toBe(20);
});
});3. Code Refactoring
Refactor for Clarity:
You: Refactor this function to be more readable
[Show complex function]
AI: [Refactored version]
function calculateDiscount(price, quantity, tier) {
const discountRate = getDiscountRate(tier);
const subtotal = price * quantity;
return subtotal * (1 - discountRate);
}Extract to Components:
You: Extract the user profile section into a reusable component
AI: [Creates UserProfile component]
const UserProfile = ({ user, onUpdate }) => {
return (
<div className="user-profile">
<Avatar src={user.avatar} />
<Info name={user.name} email={user.email} />
<Actions onEdit={onUpdate} />
</div>
);
};Database Workflows
1. Query Building
Natural Language to SQL:
You: Get all users who signed up in the last 30 days
and have made at least one purchase
AI: [Generates SQL]
SELECT u.*, COUNT(o.id) as order_count
FROM users u
LEFT JOIN orders o ON u.id = o.user_id
WHERE u.created_at >= NOW() - INTERVAL '30 days'
GROUP BY u.id
HAVING COUNT(o.id) >= 1;2. Data Migration
Migrate Data:
You: Migrate users from old schema to new schema
AI: [Generates migration]
INSERT INTO users_new (email, password_hash, created_at)
SELECT email, password, signup_date
FROM users_old;3. Performance Optimization
Analyze Slow Queries:
You: This query is slow, how can I optimize it?
AI: The query is slow because:
1. Missing index on `email` column
2. Using LIKE with leading wildcard
Solutions:
1. Add index: CREATE INDEX idx_users_email ON users(email);
2. Use full-text search instead of LIKE
3. Consider adding LIMIT for large result setsSSH/SFTP Workflows
1. Remote Deployment
Deploy to Server:
You: Deploy the latest changes to production
AI: I'll run the deployment sequence:
1. Pull latest code
2. Install dependencies
3. Run migrations
4. Build the application
5. Restart services
[Executes deployment]2. Log Analysis
Monitor Logs:
You: Check for errors in the application logs
AI: [Scans logs]
Found 3 errors in the last hour:
1. Database connection timeout (line 1234)
2. API rate limit exceeded (line 1456)
3. Null reference exception (line 1567)3. File Management
Sync Files:
You: Upload the new build artifacts to the server
AI: [Uploads via SFTP]
✓ Uploaded dist/app.js (2.4 MB)
✓ Uploaded dist/app.css (156 KB)
✓ Uploaded dist/index.html (12 KB)Documentation Workflows
1. Generate Documentation
API Documentation:
You: Generate API documentation for the user endpoints
AI: [Creates documentation]
## User Endpoints
### Get User
GET /api/users/:id
**Response:**
```json
{
"id": 123,
"email": "user@example.com",
"name": "John Doe"
}Create User
POST /api/users
Request Body:
{
"email": "user@example.com",
"password": "securepass123"
}
### 2. Write README
**Project README:**You: Create a README for this project [Show project structure]
AI: [Creates comprehensive README]
My Project
Installation
npm install
Development
npm run dev
Testing
npm test
Building
npm run build
### 3. Update Changelog
**Generate Changelog:**You: Generate a changelog from recent commits
AI: [Creates changelog]
[1.2.0] - 2024-01-20
Added
- User authentication
- Profile management
Fixed
- Pagination bug
- Memory leak in cache
Changed
- Updated dependencies
- Improved error handling
## Learning & Education
### 1. Code Explanation
**Explain Concepts:**You: Explain how React hooks work
AI: React hooks are functions that let you use state and other React features in functional components. For example, useState lets you add state to a component:
const [count, setCount] = useState(0);
The array destructuring assigns:
- count: current state value
- setCount: function to update the state
### 2. Best Practices
**Learn Best Practices:**You: What are best practices for API design?
AI: Here are key API design best practices:
- Use nouns for resources (users, orders)
- Use plural nouns (/users, not /user)
- Use HTTP verbs properly (GET, POST, PUT, DELETE)
- Use proper status codes (200, 201, 400, 404, 500)
- Provide clear error messages
- Version your API (/api/v1/users)
- Use consistent naming conventions
- Implement rate limiting
- Include request IDs for debugging
- Document your API thoroughly
### 3. Code Translation
**Convert Between Languages:**You: Convert this Python code to JavaScript
You: [Show Python code]
AI: [JavaScript version] function processData(data) { return data.map(item => ({ id: item.id, name: item.name.toUpperCase(), total: item.quantity * item.price })); }
## Automation & Productivity
### 1. Create Scripts
**Generate Scripts:**You: Create a script to backup the database
AI: [Creates shell script] #!/bin/bash
Database Backup Script
DATE=$(date +%Y%m%d_%H%M%S) BACKUP_DIR="/backups" DB_NAME="myapp"
pgdump $DB_NAME > $BACKUP_DIR/backup$DATE.sql echo "Backup completed: backup_$DATE.sql"
### 2. Generate Tests
**Unit Tests:**You: Write unit tests for the calculate function
AI: [Creates test file] describe('calculate', () => { it('should add two numbers', () => { expect(calculate(2, 3)).toBe(5); });
it('should handle negative numbers', () => { expect(calculate(-2, 3)).toBe(1); });
it('should handle zero', () => { expect(calculate(0, 0)).toBe(0); }); });
### 3. CI/CD Configuration
**GitHub Actions:**You: Create a GitHub Actions workflow for testing
AI: [Creates .github/workflows/test.yml] name: Tests
on: [push, pull_request]
jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: node-version: '18' - run: npm install - run: npm test
## Advanced Workflows
### 1. Multi-step Operations
**Complete Feature:**You: Help me build a complete CRUD feature for products
AI: I'll create the complete CRUD implementation:
- Database Model
- API Endpoints (GET, POST, PUT, DELETE)
- Frontend Components (List, Create, Edit, Delete)
- Form Validation
- Error Handling
- Unit Tests
- API Documentation
Let's start with the database model...
### 2. Performance Profiling
**Optimize Performance:**You: Profile and optimize this slow API endpoint [Show endpoint code]
AI: Performance analysis:
- Current response time: 2.5s
- Main bottleneck: Database queries (1.8s)
- Issues found:
- N+1 query problem
- Missing indexes
- Fetching unnecessary data
Optimizations:
- Use eager loading
- Add database indexes
- Select only needed fields
- Implement caching
Estimated improvement: 200ms (12.5x faster)
### 3. Security Auditing
**Security Review:**You: Review this code for security vulnerabilities [Show authentication code]
AI: Security issues found:
- [HIGH] SQL Injection vulnerability
- [HIGH] Storing passwords in plain text
- [MEDIUM] Missing rate limiting
- [MEDIUM] No input validation
- [LOW] Verbose error messages leak information
Recommendations:
- Use parameterized queries
- Hash passwords with bcrypt
- Implement rate limiting middleware
- Add input validation with Joi/Zod
- Use generic error messages
## Tips for Effective Workflows
1. **Be Specific**: Provide clear, detailed prompts
2. **Iterate**: Refine responses through follow-up questions
3. **Context**: Share relevant code and error messages
4. **Verify**: Always review and test AI-generated code
5. **Learn**: Ask the AI to explain its suggestions
6. **Save Time**: Use templates for common tasks
7. **Collaborate**: Use the AI as a pair programming partner
## See Also
- [Installation Guide](./installation.md)
- [Configuration Guide](./configuration.md)
- [Features](../features/)
- [Keyboard Shortcuts](../guides/keyboard-shortcuts.md)