Skip to content

Workflows

Discover proven patterns and real-world workflows for integrating Rawi into your development, analysis, and creative processes. Each workflow includes step-by-step instructions, shell commands, and automation scripts.

This section provides practical, real-world examples of how to integrate Rawi into your daily workflows. Each workflow includes step-by-step instructions, shell commands, and automation scripts.

Integrate Rawi into your software development process for code review, debugging, documentation, and refactoring assistance.

Use Rawi for writing, editing, and optimizing content including blog posts, documentation, and creative writing.

Leverage Rawi for information gathering, data analysis, literature reviews, and research documentation.



Automate and enhance your code review process with AI assistance.

#!/bin/bash
# code-review.sh - Automated code review workflow
PROJECT_DIR="${1:-.}"
OUTPUT_DIR="code-reviews/$(date +%Y%m%d)"
mkdir -p "$OUTPUT_DIR"
cd "$PROJECT_DIR" || exit 1
Terminal window
# Review specific file
review_file() {
local file="$1"
local language=$(basename "$file" | sed 's/.*\.//')
echo "🔍 Reviewing $file..."
cat "$file" | rawi ask --act code-reviewer \
"Review this $language file for:
1. Code quality and best practices
2. Performance issues
3. Security vulnerabilities
4. Maintainability concerns
Provide specific suggestions with line references." \
> "$OUTPUT_DIR/$(basename "$file").review.md"
}
# Review changed files in git
git diff --name-only HEAD~1 | while read -r file; do
if [[ "$file" =~ \.(js|ts|py|jsx|tsx|java|cpp|c|go)$ ]]; then
review_file "$file"
fi
done
Terminal window
# Full project analysis
analyze_project() {
echo "📊 Analyzing project structure..."
# Get project overview
find . -name "*.js" -o -name "*.ts" -o -name "*.py" | head -20 | \
xargs -I {} cat {} | \
rawi ask --act software-architect \
"Analyze this codebase structure and suggest architectural improvements" \
> "$OUTPUT_DIR/architecture-review.md"
# Analyze dependencies
if [[ -f package.json ]]; then
cat package.json | rawi ask --act security-expert \
"Review these dependencies for security and maintenance concerns" \
> "$OUTPUT_DIR/dependency-review.md"
fi
# Test coverage analysis
if [[ -d tests/ ]] || [[ -d test/ ]]; then
find . -path "*/test*" -name "*.js" -o -name "*.py" | \
xargs cat | \
rawi ask --act qa-engineer \
"Analyze test coverage and suggest improvements" \
> "$OUTPUT_DIR/test-analysis.md"
fi
}

Enhance your Git workflow with AI-powered commit messages and change analysis.

#!/bin/bash
# smart-commit.sh - AI-powered commit message generation
generate_commit_message() {
# Analyze staged changes
local diff_output=$(git diff --cached)
if [[ -z "$diff_output" ]]; then
echo "No staged changes found"
return 1
fi
# Generate commit message
echo "$diff_output" | rawi ask --act git-expert \
"Generate a clear, conventional commit message for these changes.
Follow the format: type(scope): description
Types: feat, fix, docs, style, refactor, test, chore
Keep the summary under 50 characters." | \
head -1
}
# Usage
COMMIT_MSG=$(generate_commit_message)
if [[ -n "$COMMIT_MSG" ]]; then
echo "Suggested commit message: $COMMIT_MSG"
read -p "Use this message? (y/n): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
git commit -m "$COMMIT_MSG"
fi
fi
Terminal window
# Generate release notes from git history
generate_release_notes() {
local from_tag="${1:-$(git describe --tags --abbrev=0)}"
local to_tag="${2:-HEAD}"
echo "📝 Generating release notes from $from_tag to $to_tag..."
git log --oneline "$from_tag..$to_tag" | \
rawi ask --act technical-writer \
"Create release notes from these git commits.
Group by: Features, Bug Fixes, Breaking Changes, Other
Make it user-friendly and highlight important changes." \
> "RELEASE_NOTES_$(date +%Y%m%d).md"
}

Automate documentation creation and maintenance.

#!/bin/bash
# generate-api-docs.sh - Auto-generate API documentation
generate_api_docs() {
local api_dir="${1:-src/api}"
local docs_dir="docs/api"
mkdir -p "$docs_dir"
# Generate overview
find "$api_dir" -name "*.js" -o -name "*.ts" | \
head -10 | xargs cat | \
rawi ask --act api-documentation-expert \
"Create an API overview document with:
1. Available endpoints summary
2. Authentication requirements
3. Response formats
4. Error handling" \
> "$docs_dir/overview.md"
# Document individual endpoints
find "$api_dir" -name "*route*" -o -name "*controller*" | \
while read -r file; do
local endpoint_name=$(basename "$file" .js)
cat "$file" | rawi ask --act api-documentation-expert \
"Document this API endpoint file with:
1. Endpoint URL and methods
2. Request/response schemas
3. Example requests and responses
4. Error codes and messages" \
> "$docs_dir/$endpoint_name.md"
done
}
Terminal window
# Generate JSDoc comments
add_jsdoc_comments() {
local file="$1"
# Backup original file
cp "$file" "$file.backup"
# Generate JSDoc comments
cat "$file" | rawi ask --act code-documenter \
"Add comprehensive JSDoc comments to this JavaScript code.
Include parameter types, return types, examples, and descriptions." \
> "$file.documented"
# Review and replace
echo "Review generated documentation in $file.documented"
}

Systematic approach to AI-assisted debugging.

#!/bin/bash
# debug-assistant.sh - AI-powered debugging workflow
analyze_error() {
local error_log="$1"
local source_file="$2"
echo "🐛 Starting debugging analysis..."
# Analyze error log
if [[ -f "$error_log" ]]; then
cat "$error_log" | rawi ask --act debugging-expert \
"Analyze this error log and provide:
1. Root cause analysis
2. Potential fixes
3. Prevention strategies" \
> "debug-analysis.md"
fi
# Review related source code
if [[ -f "$source_file" ]]; then
cat "$source_file" | rawi ask --act code-reviewer \
"Review this code for potential bugs and issues.
Focus on common error patterns and edge cases." \
>> "debug-analysis.md"
fi
# Generate test cases
rawi ask --act qa-engineer \
"Based on the error analysis, create test cases to verify the fix and prevent regression." \
>> "debug-analysis.md"
}
Terminal window
# Analyze performance issues
analyze_performance() {
local profile_data="$1"
cat "$profile_data" | rawi ask --act performance-expert \
"Analyze this performance profile data:
1. Identify bottlenecks
2. Suggest optimizations
3. Provide implementation examples" \
> "performance-analysis.md"
}

Intelligent log monitoring and analysis system.

#!/bin/bash
# log-monitor.sh - AI-powered log analysis
LOGFILE="${1:-/var/log/app.log}"
ALERT_THRESHOLD="CRITICAL|ERROR|FATAL"
monitor_logs() {
echo "👀 Starting intelligent log monitoring..."
tail -f "$LOGFILE" | while read -r line; do
# Check for critical issues
if echo "$line" | grep -qE "$ALERT_THRESHOLD"; then
# Get context (previous 10 lines)
context=$(tail -10 "$LOGFILE")
# Analyze with AI
alert_analysis=$(echo -e "$context\n---\n$line" | \
rawi ask --act incident-responder \
"Analyze this error in context. Provide:
1. Severity assessment
2. Immediate actions needed
3. Root cause hypothesis")
# Send alert if critical
if echo "$alert_analysis" | grep -q "IMMEDIATE\|URGENT"; then
echo "$alert_analysis" | mail -s "Critical Alert" admin@company.com
fi
# Log analysis
echo "$(date): $alert_analysis" >> "alert-analysis.log"
fi
done
}
Terminal window
# Analyze log patterns over time
analyze_log_patterns() {
local logfile="$1"
local timeframe="${2:-24h}"
echo "📊 Analyzing log patterns for last $timeframe..."
# Extract recent logs
if [[ "$timeframe" == "24h" ]]; then
grep "$(date -d '24 hours ago' '+%Y-%m-%d')" "$logfile" > recent.log
fi
# Analyze patterns
cat recent.log | rawi ask --act data-analyst \
"Analyze these log patterns:
1. Error frequency and trends
2. Peak usage times
3. Anomalies and outliers
4. Recommended monitoring alerts" \
> "log-pattern-analysis.md"
# Generate monitoring rules
rawi ask --act devops-engineer \
"Based on the log analysis, create monitoring rules and alerts for:
1. Error rate thresholds
2. Performance degradation
3. Security incidents" \
>> "log-pattern-analysis.md"
}

Comprehensive performance analysis and optimization.

#!/bin/bash
# performance-monitor.sh - AI-driven performance analysis
analyze_app_performance() {
local metrics_file="$1"
echo "⚡ Analyzing application performance..."
# Collect performance metrics
if command -v npm &> /dev/null && [[ -f package.json ]]; then
npm run build 2>&1 | grep -E "(time|size|duration)" > build-metrics.txt
fi
# Analyze metrics with AI
cat "$metrics_file" | rawi ask --act performance-expert \
"Analyze these performance metrics:
1. Identify bottlenecks
2. Suggest optimizations
3. Benchmark against industry standards
4. Provide implementation roadmap" \
> "performance-report.md"
# Database performance (if applicable)
if [[ -f slow-query.log ]]; then
cat slow-query.log | rawi ask --act database-expert \
"Analyze these slow queries and provide optimization suggestions" \
>> "performance-report.md"
fi
}

Complete API development lifecycle with AI assistance.

#!/bin/bash
# api-development.sh - AI-assisted API development
design_api() {
local requirements="$1"
echo "🔧 Designing API based on requirements..."
# Generate API specification
cat "$requirements" | rawi ask --act api-architect \
"Design a RESTful API specification:
1. Endpoint structure
2. Request/response schemas
3. Authentication strategy
4. Error handling
5. Rate limiting
Output in OpenAPI 3.0 format" \
> "api-specification.yaml"
# Generate implementation plan
rawi ask --act software-architect \
"Create an implementation plan for this API:
1. Technology stack recommendations
2. Database schema
3. Security considerations
4. Testing strategy" \
> "implementation-plan.md"
}
# Generate API tests
generate_api_tests() {
local spec_file="api-specification.yaml"
cat "$spec_file" | rawi ask --act qa-engineer \
"Generate comprehensive API test cases:
1. Unit tests for endpoints
2. Integration tests
3. Load testing scenarios
4. Security testing checklist" \
> "api-test-plan.md"
}

Begin with basic workflows and gradually add complexity as you become more comfortable with the patterns.

Adapt the example scripts to match your:

  • File structures
  • Naming conventions
  • Tools and frameworks
  • Team processes

Always include error handling in your workflow scripts:

Terminal window
# Example error handling pattern
perform_analysis() {
local input="$1"
if [[ ! -f "$input" ]]; then
echo "Error: Input file not found"
return 1
fi
# Try AI analysis with fallback
if ! cat "$input" | rawi ask --act analyzer "Analyze this" > result.txt 2>/dev/null; then
echo "AI analysis failed, using basic analysis"
grep -E "(error|warning|info)" "$input" > result.txt
fi
}

Track your workflow scripts and generated documentation:

Terminal window
# Add to .gitignore
echo "ai-analysis-temp/" >> .gitignore
echo "*.ai-review" >> .gitignore
# Track important generated docs
git add docs/ai-generated/
git commit -m "Add AI-generated documentation"

Regularly review and refine your workflows:

  • Monitor which patterns work best for your team
  • Collect feedback on AI-generated content quality
  • Optimize for your most common use cases