Usage Patterns
Learn the most effective ways to use Rawi through proven patterns, best practices, and advanced techniques that maximize productivity and AI assistance quality.
Core Usage Patterns
Section titled “Core Usage Patterns”Question Formulation Patterns
Section titled “Question Formulation Patterns”Specific vs General Questions
Section titled “Specific vs General Questions”Instead of:
rawi ask "Help with JavaScript"
Use:
rawi ask "How do I handle async/await errors in JavaScript when making API calls?"
Pattern: Context + Specific Task + Technology
rawi ask "In a React application, how do I optimize performance when rendering large lists of items?"rawi ask "For a Node.js Express API, what's the best way to implement rate limiting for different user tiers?"
Progressive Question Patterns
Section titled “Progressive Question Patterns”Start Broad, Get Specific:
# 1. Overviewrawi ask --new-session "I want to implement user authentication in my web app"
# 2. Technology selectionrawi ask "Should I use JWT tokens or session-based auth for a React/Node.js app?"
# 3. Implementation detailsrawi ask "Show me how to implement JWT authentication with refresh tokens"
# 4. Security considerationsrawi ask "What security best practices should I follow with this JWT implementation?"
Template Selection Patterns
Section titled “Template Selection Patterns”Task-Based Template Selection
Section titled “Task-Based Template Selection”Code-Related Tasks:
# Code review and improvementrawi ask --act code-reviewer "Review this function for performance issues"
# Architecture decisionsrawi ask --act software-architect "Design a scalable microservices architecture for e-commerce"
# Debugging assistancerawi ask --act debugging-expert "Help me debug this memory leak in my Node.js application"
Writing and Documentation:
# Technical documentationrawi ask --act technical-writer "Document this REST API endpoint with examples"
# User-facing contentrawi ask --act copywriter "Create user onboarding emails for our SaaS product"
# Code commentsrawi ask --act code-documenter "Generate comprehensive JSDoc comments for this module"
Analysis and Research:
# Data analysisrawi ask --act data-scientist "Analyze this user behavior dataset and find insights"
# Market researchrawi ask --act business-analyst "Research competitors in the project management software space"
# Technology evaluationrawi ask --act technology-consultant "Compare React vs Vue.js for our team's next project"
Development Workflow Patterns
Section titled “Development Workflow Patterns”Feature Development Pattern
Section titled “Feature Development Pattern”# 1. Planning phaserawi ask --new-session --act software-architect "I need to add real-time notifications to my web app"
# 2. Technology researchrawi ask "Compare WebSockets vs Server-Sent Events vs long polling for real-time features"
# 3. Implementation planningrawi ask "Design the database schema and API endpoints for a notification system"
# 4. Code implementationrawi ask --act software-engineer "Implement WebSocket connection handling in Node.js with error recovery"
# 5. Testing strategyrawi ask --act qa-engineer "Create test cases for real-time notification delivery"
# 6. Documentationrawi ask --act technical-writer "Document the notification API for other developers"
Debugging Pattern
Section titled “Debugging Pattern”# 1. Problem descriptionrawi ask --new-session "My React app is crashing with 'Cannot read property of undefined' error"
# 2. Error analysisrawi ask "Here's the full error stack trace: [paste trace]"
# 3. Code reviewrawi ask --act code-reviewer "Here's the component where the error occurs: [paste code]"
# 4. Solution implementationrawi ask "Show me the corrected code with proper error handling"
# 5. Preventionrawi ask "What patterns can I use to prevent similar errors in the future?"
Code Review Pattern
Section titled “Code Review Pattern”# 1. Overall assessmentcat src/components/UserProfile.jsx | rawi ask --act code-reviewer "Review this React component"
# 2. Security analysiscat src/api/auth.js | rawi ask --act security-expert "Check this authentication code for security vulnerabilities"
# 3. Performance reviewcat src/utils/dataProcessor.js | rawi ask --act performance-expert "Analyze this code for performance bottlenecks"
# 4. Best practices checkcat src/hooks/useDataFetching.js | rawi ask --act react-expert "Does this custom hook follow React best practices?"
Advanced Usage Patterns
Section titled “Advanced Usage Patterns”Multi-Step Problem Solving
Section titled “Multi-Step Problem Solving”Complex Feature Implementation
Section titled “Complex Feature Implementation”# Session: Building a chat applicationrawi ask --new-session --act software-architect "Design a scalable real-time chat application architecture"
# Continue with database designrawi ask --act database-expert "Design the database schema for the chat application we discussed"
# Backend implementationrawi ask --act backend-engineer "Implement the WebSocket server for real-time messaging"
# Frontend implementationrawi ask --act frontend-engineer "Create a React component for the chat interface"
# Security considerationsrawi ask --act security-expert "What security measures should I implement for this chat app?"
# Performance optimizationrawi ask --act performance-expert "How can I optimize message delivery and storage?"
Learning Pattern
Section titled “Learning Pattern”# Learning new technology: Dockerrawi ask --new-session --act teacher "I'm new to Docker. Explain containers and how they work"
# Practical applicationrawi ask "Show me how to containerize a Node.js application step by step"
# Advanced conceptsrawi ask "Explain Docker Compose and when to use it"
# Real-world scenariorawi ask "Help me dockerize my existing React/Node.js application with a database"
# Best practicesrawi ask "What are Docker security best practices for production deployments?"
Data Analysis Patterns
Section titled “Data Analysis Patterns”Log Analysis Workflow
Section titled “Log Analysis Workflow”# 1. Initial analysistail -1000 /var/log/app.log | rawi ask --act system-administrator "Summarize the main issues in this log"
# 2. Error categorizationgrep ERROR /var/log/app.log | rawi ask --act troubleshooting-expert "Categorize these errors by severity and type"
# 3. Pattern detectionawk '{print $4}' /var/log/app.log | sort | uniq -c | rawi ask --act data-analyst "Analyze these timestamp patterns for anomalies"
# 4. Solution recommendationsrawi ask --act devops-engineer "Based on the log analysis, what monitoring and alerting should I implement?"
Performance Analysis Pattern
Section titled “Performance Analysis Pattern”# 1. Baseline measurementcat performance-metrics.json | rawi ask --act performance-expert "Analyze these application performance metrics"
# 2. Bottleneck identificationcat database-query-times.log | rawi ask --act database-expert "Identify slow queries and optimization opportunities"
# 3. Optimization planningrawi ask --act software-architect "Create a performance optimization plan based on the analysis"
# 4. Implementation guidancerawi ask --act backend-engineer "Show me how to implement database query optimization"
Content Creation Patterns
Section titled “Content Creation Patterns”Documentation Workflow
Section titled “Documentation Workflow”# 1. Structure planningrawi ask --act technical-writer --new-session "Create an outline for API documentation for a project management tool"
# 2. Content generationrawi ask "Write the introduction section explaining the API's purpose and capabilities"
# 3. Example creationrawi ask --act api-documentation-expert "Create comprehensive examples for user authentication endpoints"
# 4. Review and improvementrawi ask --act editor "Review this documentation for clarity and completeness"
Content Marketing Pattern
Section titled “Content Marketing Pattern”# 1. Research phaserawi ask --act market-researcher --new-session "Research trending topics in web development for blog content"
# 2. Content planningrawi ask --act content-strategist "Create a content calendar for a developer-focused blog"
# 3. Writingrawi ask --act technical-blogger "Write a comprehensive guide to React Server Components"
# 4. SEO optimizationrawi ask --act seo-expert "Optimize this blog post for search engines while maintaining readability"
Productivity Patterns
Section titled “Productivity Patterns”Daily Development Routine
Section titled “Daily Development Routine”# Morning planningrawi ask --profile work --new-session "Help me plan today's development tasks for the user dashboard feature"
# Code review routinefor file in $(git diff --name-only HEAD~1); do cat "$file" | rawi ask --profile work --act code-reviewer "Quick review of changes in $file"done
# End-of-day reflectionrawi ask --profile work "Summarize today's progress and suggest tomorrow's priorities"
Learning and Research Routine
Section titled “Learning and Research Routine”# Weekly learning sessionrawi ask --act teacher --new-session "Teach me about GraphQL - I'm familiar with REST APIs"
# Technology comparisonrawi ask --act technology-consultant "Compare different state management solutions for React applications"
# Stay updatedrawi ask --act tech-trends-analyst "What are the latest trends in web development I should be aware of?"
Error Handling and Recovery Patterns
Section titled “Error Handling and Recovery Patterns”Graceful Degradation
Section titled “Graceful Degradation”# Primary attempt with error handlingcat complex-code.js | rawi ask --act code-reviewer "Comprehensive code review" 2>/dev/null || \# Fallback to simpler analysiscat complex-code.js | rawi ask "Quick code review - any obvious issues?"
Retry Patterns
Section titled “Retry Patterns”# Retry with exponential backofffor i in {1..3}; do if output=$(rawi ask "Complex analysis question" 2>/dev/null); then echo "$output" break else echo "Attempt $i failed, retrying in $((i*2)) seconds..." sleep $((i*2)) fidone
Integration Patterns
Section titled “Integration Patterns”Git Workflow Integration
Section titled “Git Workflow Integration”# Pre-commit hook pattern#!/bin/bash# Check for TODO comments and get AI suggestionsgit diff --cached | grep -i "TODO\|FIXME" | \ rawi ask --act project-manager "Prioritize these TODO items and suggest immediate actions"
# Commit message generationgit diff --cached | rawi ask --act git-expert "Generate a clear, conventional commit message for these changes"
CI/CD Integration Pattern
Section titled “CI/CD Integration Pattern”# Code quality gatechanged_files=$(git diff origin/main...HEAD --name-only | grep -E '\.(js|ts|py)$')for file in $changed_files; do score=$(cat "$file" | rawi ask --act code-quality-assessor "Rate this code quality from 1-10 and explain") if [[ "$score" =~ ^[1-5] ]]; then echo "Code quality concern in $file: $score" exit 1 fidone
Monitoring Integration
Section titled “Monitoring Integration”# Intelligent alertingwhile read -r alert; do echo "$alert" | rawi ask --act incident-responder "Assess this alert severity and suggest immediate actions" | \ if grep -q "CRITICAL"; then # Send to on-call engineer mail -s "Critical Alert" oncall@company.com fidone < alerts.log
Best Practices Summary
Section titled “Best Practices Summary”Question Quality
Section titled “Question Quality”- Be Specific: Include context, technology stack, and specific requirements
- Provide Examples: Show what you’ve tried and what didn’t work
- Ask Follow-ups: Build on previous responses for deeper understanding
Template Usage
Section titled “Template Usage”- Match Expertise: Choose templates that align with your task
- Combine Templates: Use different templates for different aspects of a problem
- Learn Templates: Explore
rawi act --list
regularly
Session Management
Section titled “Session Management”- Stay Focused: Keep sessions topic-focused for better context
- Use Descriptive Starts: Begin sessions with clear context
- Reference Previous Work: Build on earlier conversation points
Profile Management
Section titled “Profile Management”- Environment Separation: Different profiles for work/personal/projects
- Provider Optimization: Match providers to task complexity
- Cost Management: Use appropriate models for different scenarios
Integration
Section titled “Integration”- Error Handling: Always include fallback options in scripts
- Resource Limits: Be mindful of input size and API limits
- Caching: Cache common responses to improve performance
Common Anti-Patterns to Avoid
Section titled “Common Anti-Patterns to Avoid”Ineffective Question Patterns
Section titled “Ineffective Question Patterns”Too Vague:
rawi ask "Fix my code" # No context
Too Broad:
rawi ask "Teach me programming" # Too general
No Context:
rawi ask "Why is this broken?" # No code or error provided
Poor Session Management
Section titled “Poor Session Management”- Mixing unrelated topics in one session
- Starting new sessions for follow-up questions
- Not providing context in session continuations
Inefficient Template Usage
Section titled “Inefficient Template Usage”- Using generic templates for specialized tasks
- Not exploring available templates
- Mixing expertise levels inappropriately
See Also
Section titled “See Also”- ask command — Command reference
- Act Templates Guide — Template details
- Session Management — Managing conversations
- Shell Integration — Automation patterns
- Workflows — Complete workflow examples