Development Workflow
This guide shows how to integrate Rawi into your development workflow for code review, documentation, and problem-solving.
Overview
Section titled “Overview”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
Basic Development Setup
Section titled “Basic Development Setup”1. Configure Development Profile
Section titled “1. Configure Development Profile”# Create a development-specific profilerawi configure --profile dev --provider openai
# For budget-conscious developmentrawi configure --profile dev-budget --provider openai --model gpt-3.5-turbo
# For privacy-focused developmentrawi configure --profile dev-local --provider ollama --model codellama2. Enable Shell Integration
Section titled “2. Enable Shell Integration”# Add to your shell configuration (interactive setup)rawi configureCommon Development Tasks
Section titled “Common Development Tasks”Code Review
Section titled “Code Review”# Review a specific filerawi ask --act code-reviewer "Review this code for potential issues:" < src/utils.ts
# Review git diffgit diff | rawi ask --act code-reviewer "Analyze these changes for potential issues"
# Review pull requestgh pr diff 123 | rawi ask --act code-reviewer "Review this PR for code quality and security"Bug Investigation
Section titled “Bug Investigation”# Analyze error logsrawi ask "Help me understand this error:" < error.log
# Debug function behaviorrawi ask --act debugging-expert "Why might this function be returning unexpected results?" < src/buggy-function.js
# Analyze stack tracerawi ask --act debugging-expert "Explain this stack trace and suggest fixes:" < stack-trace.txtCommand Generation for Development
Section titled “Command Generation for Development”# Development server managementrawi exec "start development server on port 3000"rawi exec "run tests in watch mode"rawi exec "build production bundle"
# Git operationsrawi 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 managementrawi exec "install TypeScript as dev dependency"rawi exec "update all npm packages to latest versions"rawi exec "remove unused dependencies"
# Build and deployrawi exec "run linter and fix auto-fixable issues"rawi exec "generate production build with source maps"rawi exec "deploy to staging environment"Documentation Generation
Section titled “Documentation Generation”# Generate README contentrawi ask --act tech-writer "Create a README for this project" < package.json
# Document API endpointsrawi ask --act api-documenter "Generate API documentation for these routes:" < src/routes/api.js
# Create inline documentationrawi ask --act tech-writer "Add JSDoc comments to this function:" < src/utils.jsRefactoring Assistance
Section titled “Refactoring Assistance”# Suggest improvementsrawi ask --act code-reviewer "How can I refactor this code to be more maintainable?" < src/legacy-code.js
# Convert between patternsrawi ask --act code-reviewer "Convert this callback-based code to use async/await:" < src/callbacks.js
# Optimize performancerawi ask --act code-reviewer "How can I optimize this function for better performance?" < src/slow-function.jsAdvanced Development Workflows
Section titled “Advanced Development Workflows”Using Act Templates for Development
Section titled “Using Act Templates for Development”# Use coding assistant templaterawi ask --act code-reviewer "Help me implement a user authentication system"
# Use code reviewer templaterawi ask --act code-reviewer "Review this code for security and best practices" < src/new-feature.ts
# Use debugging assistant templaterawi ask --act debugging-expert "My React component isn't re-rendering when props change"Profile-Based Development
Section titled “Profile-Based Development”# Start a development profilerawi ask "I'm working on implementing user authentication. Let's start." --profile auth-dev
# Continue the profile throughout developmentrawi ask "Now I need to add password validation" --profile auth-devrawi ask "How should I handle password reset?" --profile auth-dev
# Review session for documentationrawi history --session <session-id-auth-dev> --format markdown > auth-implementation.mdIntegration with Git Hooks
Section titled “Integration with Git Hooks”Create a pre-commit hook to review changes:
#!/bin/bashgit diff --cached | rawi ask "Quick review of these staged changes for obvious issues" --quietCI/CD Integration
Section titled “CI/CD Integration”# In your CI pipeline# Generate test reportsrawi ask --act data-analyst "Analyze this test output and suggest improvements:" < test-results.txt
# Security reviewrawi ask --act security-expert "Review these changes for security vulnerabilities:" < <(git diff HEAD~1)Best Practices
Section titled “Best Practices”Effective Prompting for Development
Section titled “Effective Prompting for Development”-
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 -
Be Specific
Terminal window rawi ask --act code-reviewer "Optimize this TypeScript function for handling large arrays (>10k items):" < src/processor.ts -
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?"
Managing Development Sessions
Section titled “Managing Development Sessions”- 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
Template Customization
Section titled “Template Customization”Create custom templates for your development workflow:
# Use existing templates for project-specific needsrawi 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.tsxTeam Collaboration
Section titled “Team Collaboration”Sharing Sessions
Section titled “Sharing Sessions”# Export session for team reviewrawi history --session feature-auth --format json > auth-development-session.json
# Share specific conversationrawi history --last 5 --format markdown | pbcopyCode Review Process
Section titled “Code Review Process”-
Initial Review
Terminal window git diff main | rawi ask --act code-reviewer "Initial code review - highlight major concerns" -
Detailed Analysis
Terminal window rawi ask --act security-expert "Detailed security and performance review:" < changed-files.diff -
Documentation
Terminal window rawi ask "Generate PR description based on these changes:" < git-diff.txt
Integration Examples
Section titled “Integration Examples”VS Code Integration
Section titled “VS Code Integration”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}" } ]}Vim Integration
Section titled “Vim Integration”Add to your .vimrc:
" Send current file to Rawi for reviewcommand! RawiReview !rawi ask "Review this code:" < %Related Documentation
Section titled “Related Documentation”- Commands Reference - All available commands
- Act Templates - Pre-built development templates
- Session Management - Working with conversation sessions
- Shell Integration - Terminal integration setup
- Main Documentation - Return to main wiki
Part of the Rawi Documentation Wiki rawi ask —batch “src/routes/*.js” —act api-documentation-expert “Generate API documentation for all route files”
Generate changelog
Section titled “Generate changelog”git log —oneline —since=“1 month ago” | rawi ask —act technical-writer “Create a changelog from these git commits”
### Refactoring Assistance
```bash# Suggest improvementscat 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 patternscat src/callbacks.js | rawi ask --act javascript-expert "Convert this callback-based code to use async/await with proper error handling"
# Optimize performancecat src/slow-function.js | rawi ask --act performance-expert "How can I optimize this function for better performance?"
# Modernize codecat src/old-react-component.js | rawi ask --act react-expert "Convert this class component to a modern functional component with hooks"Advanced Development Workflows
Section titled “Advanced Development Workflows”Feature Development Workflow
Section titled “Feature Development Workflow”# 1. Planning phaserawi ask --new-session --act software-architect "I need to implement user authentication with JWT tokens in a Node.js/Express API"
# 2. Design decisionsrawi ask "What's the best approach for token refresh and security?"
# 3. Implementation guidancerawi ask --act backend-engineer "Show me how to implement JWT middleware for Express"
# 4. Testing strategyrawi ask --act qa-engineer "Create comprehensive test cases for this authentication system"
# 5. Documentationrawi ask --act technical-writer "Document this authentication system for other developers"Code Review Workflow
Section titled “Code Review Workflow”#!/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 analysisgit diff "$BRANCH" | rawi ask --act software-architect \ "Analyze these changes for architectural impact and design consistency" \ > "$OUTPUT_DIR/architecture-review.md"
# 2. Security reviewgit 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" fidone
# 3. Performance analysisgit 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" fidone
# 4. Generate summaryrawi 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/"Git Integration Workflow
Section titled “Git Integration Workflow”# Smart commit message generationgenerate_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-commitecho "🤖 AI-powered pre-commit checks..."
# Check for potential issuesgit 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 providedif [[ -f .git/COMMIT_EDITMSG ]]; then COMMIT_MSG=$(cat .git/COMMIT_EDITMSG) if [[ ${#COMMIT_MSG} -lt 10 ]]; then echo "💡 Suggested commit message:" generate_commit_message fifiTesting Workflow
Section titled “Testing Workflow”# Test generationgenerate_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 improvementimprove_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"}Integration Patterns
Section titled “Integration Patterns”IDE Integration
Section titled “IDE Integration”# 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" } } ]}CI/CD Integration
Section titled “CI/CD Integration”# GitHub Actions workflowname: AI Code Reviewon: [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}` });Development Scripts
Section titled “Development Scripts”#!/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]" ;;esacBest Practices
Section titled “Best Practices”Effective Prompting for Development
Section titled “Effective Prompting for Development”-
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 -
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 -
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
Session Management for Development
Section titled “Session Management for Development”# Feature-based sessionsrawi ask --new-session --session user-auth "Implementing user authentication system"
# Bug-fixing sessionsrawi ask --new-session --session bug-login "Debugging login issues in production"
# Refactoring sessionsrawi ask --new-session --session refactor-api "Refactoring API endpoints for better performance"Profile Management
Section titled “Profile Management”# Different profiles for different contextsrawi configure --profile work-review --provider anthropic --model claude-3-5-sonnet # For thorough reviewsrawi configure --profile quick-dev --provider openai --model gpt-3.5-turbo # For quick questionsrawi configure --profile local-dev --provider ollama --model codellama # For offline developmentTeam Collaboration
Section titled “Team Collaboration”Sharing Development Insights
Section titled “Sharing Development Insights”# Export development session for team reviewrawi history --session feature-auth --export --format markdown > feature-auth-development.md
# Share code review findingsrawi history --search "security" --last 10 --export > security-findings.md
# Generate team knowledge baserawi ask --act knowledge-manager "Create a knowledge base entry from this development session" < session-export.mdCode Review Standards
Section titled “Code Review Standards”# Team code review templatereview_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."}Troubleshooting Development Workflow
Section titled “Troubleshooting Development Workflow”Common Issues
Section titled “Common Issues”Large file processing:
# Process large files in chunkssplit -l 100 large-file.js chunk_for chunk in chunk_*; do cat "$chunk" | rawi ask --act code-reviewer "Review this code section"doneAPI rate limits:
# Add delays between requestsfor file in src/*.js; do cat "$file" | rawi ask --act code-reviewer "Quick review" > "reviews/$(basename "$file").md" sleep 2 # Avoid rate limitsdoneContext preservation:
# Use sessions for related questionsSESSION_ID=$(rawi ask --new-session "Starting feature development" --get-session-id)rawi ask --session "$SESSION_ID" "Continue with implementation details"