Session Management
Session management in Rawi allows you to maintain persistent conversations with AI, keeping context and conversation history across multiple commands.
What Are Sessions?
Section titled “What Are Sessions?”Sessions are persistent conversations that maintain context between multiple AI interactions. When you start a session, Rawi remembers:
- Previous questions and responses
- Conversation context and topics
- Code snippets and examples discussed
- Follow-up questions and clarifications
Basic Session Commands
Section titled “Basic Session Commands”Starting a New Session
Section titled “Starting a New Session”# Start a new session with your first questionrawi ask --new-session "I'm building a REST API in Node.js"
# Start a named sessionrawi ask --new-session --session my-project "Let's discuss authentication patterns"
Continuing a Session
Section titled “Continuing a Session”# Continue the conversation (Rawi remembers the context)rawi ask "What's the best way to handle JWT tokens?"rawi ask "How do I implement rate limiting?"rawi ask "Can you show me a middleware example?"
Using Specific Sessions
Section titled “Using Specific Sessions”# Continue a specific session by IDrawi ask --session abc123 "Let's continue our API discussion"
# List all your sessionsrawi history --sessions
# Show session detailsrawi history --session abc123 --show
Session Management
Section titled “Session Management”Listing Sessions
Section titled “Listing Sessions”# List all sessionsrawi history --sessions
# List sessions with detailsrawi history --sessions --verbose
# Filter sessions by daterawi history --sessions --since "2024-01-01"
Example output:
Sessions:┌─────────┬────────────────────┬─────────────────────┬───────────┐│ ID │ Started │ Last Updated │ Messages │├─────────┼────────────────────┼─────────────────────┼───────────┤│ abc123 │ 2024-01-15 10:30 │ 2024-01-15 11:45 │ 8 ││ def456 │ 2024-01-14 14:20 │ 2024-01-14 15:30 │ 12 ││ ghi789 │ 2024-01-13 09:15 │ 2024-01-13 10:00 │ 4 │└─────────┴────────────────────┴─────────────────────┴───────────┘
Session Details
Section titled “Session Details”# Show full session conversationrawi history --session abc123 --show
# Export session to filerawi history --session abc123 --export > api-discussion.md
# Search within a sessionrawi history --session abc123 --search "authentication"
Practical Session Examples
Section titled “Practical Session Examples”Code Development Session
Section titled “Code Development Session”# Start a development sessionrawi ask --new-session "I'm building a user authentication system in Express.js"
# Continue developingrawi ask "How do I hash passwords securely?"rawi ask "What's the best way to store JWT tokens?"rawi ask "Can you show me a complete login route?"rawi ask "How do I handle password reset functionality?"
Learning Session
Section titled “Learning Session”# Start learning about a new technologyrawi ask --new-session "I want to learn Docker. Can you explain the basics?"
# Progressive learningrawi ask "What's the difference between images and containers?"rawi ask "How do I create a Dockerfile?"rawi ask "Can you show me a real example?"rawi ask "How do I handle environment variables?"
Debugging Session
Section titled “Debugging Session”# Start with an errorrawi ask --new-session "I'm getting a 'Cannot read property of undefined' error in my React app"
# Iterative debuggingrawi ask "Here's my component code: [paste code]"rawi ask "The error happens when I click the submit button"rawi ask "I tried your suggestion, but now I get a different error"
Session Best Practices
Section titled “Session Best Practices”1. Use Descriptive Starting Questions
Section titled “1. Use Descriptive Starting Questions”Good:
rawi ask --new-session "I'm building a React e-commerce app and need help with state management"
Better context than:
rawi ask --new-session "Help me with React"
2. Keep Sessions Focused
Section titled “2. Keep Sessions Focused”- Use separate sessions for different topics
- Start new sessions when switching projects
- Don’t mix unrelated questions in one session
3. Reference Previous Context
Section titled “3. Reference Previous Context”# Good follow-up questionsrawi ask "Can you modify the authentication code you showed earlier to use bcrypt?"rawi ask "What about the database schema we discussed?"
4. Use Sessions with Templates
Section titled “4. Use Sessions with Templates”# Start a specialized sessionrawi ask --new-session --act software-engineer "I'm designing a microservices architecture"
# Continue with the same expertiserawi ask "How do I handle service-to-service communication?"
Advanced Session Features
Section titled “Advanced Session Features”Session with Profiles
Section titled “Session with Profiles”# Use different profiles for different sessionsrawi ask --new-session --profile work "Let's discuss the API redesign"rawi ask --new-session --profile personal "Help me with my side project"
Session Export and Sharing
Section titled “Session Export and Sharing”# Export session as markdownrawi history --session abc123 --export --format markdown > discussion.md
# Export as JSON for processingrawi history --session abc123 --export --format json > session.json
# Export specific date rangerawi history --since "2024-01-01" --until "2024-01-31" --export
Session Search and Analysis
Section titled “Session Search and Analysis”# Search across all sessionsrawi history --search "authentication JWT"
# Find sessions about specific topicsrawi history --search "React hooks" --sessions-only
# Get session statisticsrawi history --stats
Session Workflow Patterns
Section titled “Session Workflow Patterns”Project-Based Sessions
Section titled “Project-Based Sessions”# Main project sessionrawi ask --new-session --session main-project "Working on the user dashboard feature"
# Feature-specific sessionsrawi ask --new-session --session auth-feature "Implementing OAuth2 integration"rawi ask --new-session --session ui-redesign "Updating the component library"
Daily Development Sessions
Section titled “Daily Development Sessions”# Morning planning sessionrawi ask --new-session --session daily-$(date +%Y%m%d) "Today I'm working on [feature]"
# Reference throughout the dayrawi ask --session daily-$(date +%Y%m%d) "I'm stuck on this implementation"
Code Review Sessions
Section titled “Code Review Sessions”# Start review sessionrawi ask --new-session --act code-reviewer "I need to review this pull request"
# Iterative reviewrawi ask "Here's the first file: [code]"rawi ask "And here's the test file: [code]"rawi ask "What about the overall architecture?"
Session Configuration
Section titled “Session Configuration”Default Session Behavior
Section titled “Default Session Behavior”# Configure default session settingsrawi configure --auto-session true # Auto-create sessionsrawi configure --session-timeout 24h # Session expiry timerawi configure --max-sessions 50 # Maximum stored sessions
Session Cleanup
Section titled “Session Cleanup”# Clean up old sessionsrawi history --cleanup --older-than "30d"
# Archive important sessionsrawi history --session abc123 --archive
Troubleshooting Sessions
Section titled “Troubleshooting Sessions”Common Session Issues
Section titled “Common Session Issues”Session not found:
# List all sessions to find the correct IDrawi history --sessions
Session context lost:
# Check session detailsrawi history --session abc123 --show
Too many sessions:
# Clean up old sessionsrawi history --cleanup
Integration with Other Features
Section titled “Integration with Other Features”Sessions + Shell Integration
Section titled “Sessions + Shell Integration”# Start session with file analysiscat app.js | rawi ask --new-session --act code-reviewer "Review this file"
# Continue session with more filescat tests.js | rawi ask "Now review the tests for the same functionality"
Sessions + Workflows
Section titled “Sessions + Workflows”# Development workflow sessionrawi ask --new-session "Starting feature: user profile management"# ... development continues ...rawi ask "Feature complete, now I need deployment instructions"
See Also
Section titled “See Also”- ask command — Basic AI interactions
- history command — Managing conversation history
- Workflows — Real-world usage patterns
- Shell Integration — Using sessions with shell commands