Skip to content

Development Workflow

This guide shows how to integrate Rawi into your development workflow for code review, documentation, and problem-solving.

Rawi can assist with various development tasks:

  • Code review and analysis
  • Bug investigation and debugging
  • Documentation generation
  • Refactoring assistance
  • Testing strategy
  • Command generation for development tasks
Terminal window
# Create a development-specific profile
rawi configure --profile dev --provider openai
# For budget-conscious development
rawi configure --profile dev-budget --provider openai --model gpt-3.5-turbo
# For privacy-focused development
rawi configure --profile dev-local --provider ollama --model codellama
Terminal window
# Add to your shell configuration (interactive setup)
rawi configure
Terminal window
# Review a specific file
rawi ask --act code-reviewer "Review this code for potential issues:" < src/utils.ts
# Review git diff
git diff | rawi ask --act code-reviewer "Analyze these changes for potential issues"
# Review pull request
gh pr diff 123 | rawi ask --act code-reviewer "Review this PR for code quality and security"
Terminal window
# Analyze error logs
rawi ask "Help me understand this error:" < error.log
# Debug function behavior
rawi ask --act debugging-expert "Why might this function be returning unexpected results?" < src/buggy-function.js
# Analyze stack trace
rawi ask --act debugging-expert "Explain this stack trace and suggest fixes:" < stack-trace.txt
Terminal window
# Development server management
rawi exec "start development server on port 3000"
rawi exec "run tests in watch mode"
rawi exec "build production bundle"
# Git operations
rawi exec "create new feature branch for user authentication"
rawi exec "commit all changes with descriptive message"
rawi exec "merge feature branch and delete it"
# Package management
rawi exec "install TypeScript as dev dependency"
rawi exec "update all npm packages to latest versions"
rawi exec "remove unused dependencies"
# Build and deploy
rawi exec "run linter and fix auto-fixable issues"
rawi exec "generate production build with source maps"
rawi exec "deploy to staging environment"
Terminal window
# Generate README content
rawi ask --act tech-writer "Create a README for this project" < package.json
# Document API endpoints
rawi ask --act api-documenter "Generate API documentation for these routes:" < src/routes/api.js
# Create inline documentation
rawi ask --act tech-writer "Add JSDoc comments to this function:" < src/utils.js
Terminal window
# Suggest improvements
rawi ask --act code-reviewer "How can I refactor this code to be more maintainable?" < src/legacy-code.js
# Convert between patterns
rawi ask --act code-reviewer "Convert this callback-based code to use async/await:" < src/callbacks.js
# Optimize performance
rawi ask --act code-reviewer "How can I optimize this function for better performance?" < src/slow-function.js
Terminal window
# Use coding assistant template
rawi ask --act code-reviewer "Help me implement a user authentication system"
# Use code reviewer template
rawi ask --act code-reviewer "Review this code for security and best practices" < src/new-feature.ts
# Use debugging assistant template
rawi ask --act debugging-expert "My React component isn't re-rendering when props change"
Terminal window
# Start a development profile
rawi ask "I'm working on implementing user authentication. Let's start." --profile auth-dev
# Continue the profile throughout development
rawi ask "Now I need to add password validation" --profile auth-dev
rawi ask "How should I handle password reset?" --profile auth-dev
# Review session for documentation
rawi history --session <session-id-auth-dev> --format markdown > auth-implementation.md

Create a pre-commit hook to review changes:

.git/hooks/pre-commit
#!/bin/bash
git diff --cached | rawi ask "Quick review of these staged changes for obvious issues" --quiet
Terminal window
# In your CI pipeline
# Generate test reports
rawi ask --act data-analyst "Analyze this test output and suggest improvements:" < test-results.txt
# Security review
rawi ask --act security-expert "Review these changes for security vulnerabilities:" < <(git diff HEAD~1)
  1. Provide Context

    Terminal window
    rawi ask --act debugging-expert "In the context of a Node.js Express API, how should I handle this error?" < error.log
  2. Be Specific

    Terminal window
    rawi ask --act code-reviewer "Optimize this TypeScript function for handling large arrays (>10k items):" < src/processor.ts
  3. Include Relevant Files

    Terminal window
    cat src/component.tsx src/api-client.ts | rawi ask --act code-reviewer "How should I modify this component to work with the new API?"
  • Use descriptive session names: feature-auth, bug-fix-login, refactor-utils
  • Keep sessions focused on specific tasks or features
  • Export session history for documentation or team sharing

Create custom templates for your development workflow:

Terminal window
# Use existing templates for project-specific needs
rawi ask --act code-reviewer "Review this React/TypeScript code focusing on: 1) TypeScript best practices, 2) React patterns, 3) Performance implications, 4) Security concerns" < src/component.tsx
Terminal window
# Export session for team review
rawi history --session feature-auth --format json > auth-development-session.json
# Share specific conversation
rawi history --last 5 --format markdown | pbcopy
  1. Initial Review

    Terminal window
    git diff main | rawi ask --act code-reviewer "Initial code review - highlight major concerns"
  2. Detailed Analysis

    Terminal window
    rawi ask --act security-expert "Detailed security and performance review:" < changed-files.diff
  3. Documentation

    Terminal window
    rawi ask "Generate PR description based on these changes:" < git-diff.txt

Add Rawi commands to your VS Code tasks:

{
"version": "2.0.0",
"tasks": [
{
"label": "Review Current File",
"type": "shell",
"command": "rawi ask 'Review this file for issues:' < ${file}"
}
]
}

Add to your .vimrc:

" Send current file to Rawi for review
command! RawiReview !rawi ask "Review this code:" < %

Part of the Rawi Documentation Wiki rawi ask —batch “src/routes/*.js” —act api-documentation-expert “Generate API documentation for all route files”

git log —oneline —since=“1 month ago” | rawi ask —act technical-writer “Create a changelog from these git commits”

### Refactoring Assistance
```bash
# Suggest improvements
cat src/legacy-code.js | rawi ask --act software-architect "How can I refactor this code to be more maintainable and follow modern best practices?"
# Convert between patterns
cat src/callbacks.js | rawi ask --act javascript-expert "Convert this callback-based code to use async/await with proper error handling"
# Optimize performance
cat src/slow-function.js | rawi ask --act performance-expert "How can I optimize this function for better performance?"
# Modernize code
cat src/old-react-component.js | rawi ask --act react-expert "Convert this class component to a modern functional component with hooks"
Terminal window
# 1. Planning phase
rawi ask --new-session --act software-architect "I need to implement user authentication with JWT tokens in a Node.js/Express API"
# 2. Design decisions
rawi ask "What's the best approach for token refresh and security?"
# 3. Implementation guidance
rawi ask --act backend-engineer "Show me how to implement JWT middleware for Express"
# 4. Testing strategy
rawi ask --act qa-engineer "Create comprehensive test cases for this authentication system"
# 5. Documentation
rawi ask --act technical-writer "Document this authentication system for other developers"
#!/bin/bash
# comprehensive-review.sh - Complete code review workflow
BRANCH="${1:-main}"
OUTPUT_DIR="reviews/$(date +%Y%m%d)"
mkdir -p "$OUTPUT_DIR"
echo "🔍 Starting comprehensive code review..."
# 1. Overall diff analysis
git diff "$BRANCH" | rawi ask --act software-architect \
"Analyze these changes for architectural impact and design consistency" \
> "$OUTPUT_DIR/architecture-review.md"
# 2. Security review
git diff "$BRANCH" --name-only | while read -r file; do
if [[ "$file" =~ \.(js|ts|py|java|php)$ ]]; then
echo "🔒 Security review: $file"
cat "$file" | rawi ask --act security-expert \
"Review this code for security vulnerabilities and best practices" \
> "$OUTPUT_DIR/security-$(basename "$file").md"
fi
done
# 3. Performance analysis
git diff "$BRANCH" --name-only | grep -E '\.(js|ts|py)$' | while read -r file; do
if grep -q "loop\|for\|while\|map\|filter\|reduce" "$file"; then
echo "⚡ Performance review: $file"
cat "$file" | rawi ask --act performance-expert \
"Analyze this code for performance bottlenecks and optimization opportunities" \
> "$OUTPUT_DIR/performance-$(basename "$file").md"
fi
done
# 4. Generate summary
rawi ask --act project-manager \
"Based on the review files in $OUTPUT_DIR, create a summary of key issues and recommendations" \
> "$OUTPUT_DIR/review-summary.md"
echo "✅ Code review complete. Results in $OUTPUT_DIR/"
Terminal window
# Smart commit message generation
generate_commit_message() {
git diff --cached | rawi ask --act git-expert \
"Generate a conventional commit message for these changes. Format: type(scope): description"
}
# Pre-commit hook
#!/bin/bash
# .git/hooks/pre-commit
echo "🤖 AI-powered pre-commit checks..."
# Check for potential issues
git diff --cached | rawi ask --act code-reviewer \
"Quick scan: any obvious issues or security concerns in these changes?" \
--profile dev-quick
# Check commit message quality if provided
if [[ -f .git/COMMIT_EDITMSG ]]; then
COMMIT_MSG=$(cat .git/COMMIT_EDITMSG)
if [[ ${#COMMIT_MSG} -lt 10 ]]; then
echo "💡 Suggested commit message:"
generate_commit_message
fi
fi
Terminal window
# Test generation
generate_tests() {
local source_file="$1"
local test_framework="${2:-jest}"
cat "$source_file" | rawi ask --act qa-engineer \
"Generate comprehensive $test_framework tests for this code including:
1. Unit tests for all functions
2. Edge cases and error scenarios
3. Integration test suggestions
4. Mock data examples" \
> "tests/$(basename "$source_file" .js).test.js"
}
# Test review and improvement
improve_tests() {
local test_file="$1"
cat "$test_file" | rawi ask --act qa-engineer \
"Review these tests and suggest improvements:
1. Missing test cases
2. Better assertions
3. Test organization
4. Performance considerations" \
> "$test_file.review"
}
Terminal window
# VS Code tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "AI Code Review",
"type": "shell",
"command": "cat ${file} | rawi ask --act code-reviewer 'Review this code'",
"group": "build",
"presentation": {
"echo": true,
"reveal": "always",
"panel": "new"
}
}
]
}
# GitHub Actions workflow
name: AI Code Review
on: [pull_request]
jobs:
ai-review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Rawi
run: npm install -g rawi
- name: AI Code Review
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: |
git diff origin/main...HEAD | rawi ask --act code-reviewer \
"Review this PR for production readiness" > ai-review.md
- name: Comment PR
uses: actions/github-script@v5
with:
script: |
const fs = require('fs');
const review = fs.readFileSync('ai-review.md', 'utf8');
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `## 🤖 AI Code Review\n\n${review}`
});
#!/bin/bash
# dev-assistant.sh - Daily development helper
case "$1" in
"start")
echo "🚀 Starting development session..."
rawi ask --new-session --act software-engineer \
"Starting work on feature: $2. What should I consider first?"
;;
"review")
echo "👀 Reviewing current changes..."
git diff | rawi ask --act code-reviewer \
"Review my current changes before commit"
;;
"debug")
echo "🐛 Debug assistance..."
if [[ -f "$2" ]]; then
cat "$2" | rawi ask --act debugging-expert \
"Help me debug this code. What could be wrong?"
else
rawi ask --act debugging-expert "$2"
fi
;;
"test")
echo "🧪 Test generation..."
if [[ -f "$2" ]]; then
generate_tests "$2"
fi
;;
"docs")
echo "📚 Documentation generation..."
if [[ -f "$2" ]]; then
cat "$2" | rawi ask --act technical-writer \
"Generate documentation for this code"
fi
;;
*)
echo "Usage: $0 {start|review|debug|test|docs} [file/description]"
;;
esac
  1. Provide Context

    Terminal window
    rawi ask --act debugging-expert "In a Node.js Express API using MongoDB, why might this query be slow?" < slow-query.js
  2. Be Specific About Requirements

    Terminal window
    rawi ask --act code-reviewer "Review this React TypeScript component for accessibility, performance, and TypeScript best practices" < Component.tsx
  3. Include Tech Stack Information

    Terminal window
    rawi ask --act full-stack-developer "How should I structure this feature in a Next.js 13 app with Prisma and TypeScript?" < requirements.txt
Terminal window
# Feature-based sessions
rawi ask --new-session --session user-auth "Implementing user authentication system"
# Bug-fixing sessions
rawi ask --new-session --session bug-login "Debugging login issues in production"
# Refactoring sessions
rawi ask --new-session --session refactor-api "Refactoring API endpoints for better performance"
Terminal window
# Different profiles for different contexts
rawi configure --profile work-review --provider anthropic --model claude-3-5-sonnet # For thorough reviews
rawi configure --profile quick-dev --provider openai --model gpt-3.5-turbo # For quick questions
rawi configure --profile local-dev --provider ollama --model codellama # For offline development
Terminal window
# Export development session for team review
rawi history --session feature-auth --export --format markdown > feature-auth-development.md
# Share code review findings
rawi history --search "security" --last 10 --export > security-findings.md
# Generate team knowledge base
rawi ask --act knowledge-manager "Create a knowledge base entry from this development session" < session-export.md
Terminal window
# Team code review template
review_template() {
cat "$1" | rawi ask --act code-reviewer \
"Review this code according to our team standards:
1. Follow our coding conventions
2. Check for security vulnerabilities
3. Ensure proper error handling
4. Verify test coverage needs
5. Check performance implications
Provide specific, actionable feedback."
}

Large file processing:

Terminal window
# Process large files in chunks
split -l 100 large-file.js chunk_
for chunk in chunk_*; do
cat "$chunk" | rawi ask --act code-reviewer "Review this code section"
done

API rate limits:

Terminal window
# Add delays between requests
for file in src/*.js; do
cat "$file" | rawi ask --act code-reviewer "Quick review" > "reviews/$(basename "$file").md"
sleep 2 # Avoid rate limits
done

Context preservation:

Terminal window
# Use sessions for related questions
SESSION_ID=$(rawi ask --new-session "Starting feature development" --get-session-id)
rawi ask --session "$SESSION_ID" "Continue with implementation details"