npm run dev- Start development servernpm run build- Production build with GeoLite2 downloadnpm run lint- Run ESLintnpm test- Run all testsjest path/to/test.test.ts- Run single test filenpm run test:watch- Run tests in watch modenpm run test:mongo- Run MongoDB-specific tests
A comprehensive session management tool that integrates with your tmux + neovim workflow.
oc start [name] [dir]- Start new OpenCode sessionoc stop- Stop current OpenCode sessionoc list- List all sessions with IDs, dates, and message countsoc switch <id>- Switch to session by ID (supports partial IDs)oc new [name] [context]- Create new session with contextoc status- Show current session statusoc save [name]- Save current session context to fileoc load <name>- Load session context from fileoc cleanup [days]- Clean up old sessions (default: 7 days)oc stats- Show session statistics and usage patternsoc help- Show detailed help
<leader>oo- Toggle OpenCode connection<leader>oa- Ask OpenCode with context<leader>of- Ask about current file (@file context)<leader>on- New OpenCode session<leader>oe- Explain code at cursor (@cursor context)<leader>or- Review current file<leader>od- Document selection (visual mode)<leader>ob- Bug analysis<leader>op- Performance optimization<leader>ot- Generate tests<leader>oR- Refactor selection (visual mode)<leader>oc- Add comments<leader>os- Suggest improvements<leader>oq- Quick explain word under cursor<leader>oh- OpenCode help
<leader>ol- List OpenCode sessions<leader>oS- Save current session context<leader>ox- Stop OpenCode session<leader>oL- Load session context (prompts for name)<leader>oN- Create new session (prompts for name/context)<leader>oT- Show session statistics
- Auto-naming: Sessions are automatically named based on tmux session and project directory
- Context saving: Captures project structure, git history, and session metadata
- Tmux integration: Seamlessly works with existing
idescript and pane management - Database queries: Direct SQLite access to OpenCode's session database
Note: OpenCode 1.x stores its database at
~/.local/share/opencode/opencode.db(older installs used~/.opencode/opencode.db).
-
Start a focused coding session:
oc start bug-fix ~/myproject # Opens OpenCode in tmux split, focused on specific directory
-
Save and restore session context:
oc save current-work # Later... oc load current-work -
Session management:
oc list # See all sessions oc switch e97702d0 # Switch to specific session (partial ID works) oc stats # View usage statistics
-
Cleanup old sessions:
oc cleanup 14 # Remove context files older than 14 days
/Users/1uk4/dotfiles/bin/oc- Main session manager script/Users/1uk4/dotfiles/bin/oc-demo- Demo data generator~/.opencode/sessions/*.ctx- Saved session contexts
- Use absolute imports with
@/alias:import { Component } from '@/src/components/Component' - Group imports: external libraries first, then internal modules
- Separate type imports when needed
- Use strict TypeScript with Zod schemas for validation
- Define schemas in
/schemasdirectory, infer types:type Game = z.infer<typeof gameSchema> - PascalCase for components:
UserProfileDialog,GameCreationCard - Use descriptive, feature-based naming conventions
- Always use try-catch in API routes and services
- Return structured responses:
{ success: boolean, data?: T, error?: string } - Use toast notifications for user-facing errors
- Log errors with context:
console.error('Error creating game:', error)
- API Routes:
/src/app/api/[feature]/[action]/route.ts(Next.js 13+ App Router) - Services:
/services/[Feature]/[feature].service.ts(business logic) - Use session-based auth:
const session = await getServerSession()(never pass userId in requests) - Hooks use
useAuthenticatedQuery/useAuthenticatedMutationwith React Query - All API calls use standardized format with
apimiddleware