Skip to content

Instantly share code, notes, and snippets.

@thoroc
Created September 12, 2025 14:51
Show Gist options
  • Save thoroc/2ae5c7b7c8fa1622e71fb281a5394539 to your computer and use it in GitHub Desktop.
Save thoroc/2ae5c7b7c8fa1622e71fb281a5394539 to your computer and use it in GitHub Desktop.
OpenCode extras
description
Stage and commit changes with conventional commit message

You are tasked with staging and committing changes in a repository using conventional commit message format.

First, detect the version control system: !if [ -d ".git" ]; then echo "git"; elif [ -d ".jj" ]; then echo "jujutsu"; else echo "none"; fi

If git is detected:

  1. Show current status: !git status --porcelain
  2. Stage all changes: !git add .
  3. Create a conventional commit message following this format:
    • <type>[optional scope]: <description>
    • Types: feat, fix, docs, style, refactor, perf, test, build, ci, chore
    • Keep description under 72 characters, imperative mood
    • Examples: "feat: add user authentication", "fix(api): resolve timeout issue"

If jujutsu is detected:

  1. Show current status: !jj status
  2. Create a conventional commit message and commit with: !jj commit -m "<message>"

If no VCS is detected, inform the user that this directory is not a git or jujutsu repository.

Based on the staged changes, analyze what was modified and suggest an appropriate conventional commit type and description. Then execute the commit with the conventional message format.

description
List all session summaries in the .sessions directory

List all session summary files in the .sessions directory and provide a brief overview.

Session Summary Files

Find all session summary files in .sessions directory: !find .sessions -maxdepth 1 -name "session-summary-*.md" -type f 2>/dev/null | sort -r || echo "No .sessions directory found"

File Details

For each session summary file found, show:

  • Filename and creation timestamp
  • File size and last modified date
  • Brief excerpt from the first few lines

!if [ -d ".sessions" ]; then for file in $(find .sessions -maxdepth 1 -name "session-summary-*.md" -type f | sort -r); do echo "## $file"; ls -la "$file"; echo "### Preview:"; head -10 "$file" | tail -8; echo "---"; done; else echo "No .sessions directory found in current working directory"; fi

Current Directory Context

Working directory: !pwd Sessions directory: !ls -la .sessions 2>/dev/null || echo ".sessions directory does not exist" Total session files: !find .sessions -maxdepth 1 -name "session-summary-*.md" -type f 2>/dev/null | wc -l

If no session summary files are found, suggest:

  1. Creating a .sessions directory: mkdir .sessions
  2. Running /session-save to create one for the current session and save it in .sessions
description
Resume an OpenCode session from a markdown summary file

Resume an OpenCode session using context from a previously generated session summary file.

Find Available Session Summaries

List available session summary files in the .sessions directory: !ls -la .sessions/session-summary-*.md 2>/dev/null | head -10 || echo "No session summary files found in .sessions directory"

Select Summary File

If multiple summary files exist, you should ask the user which one to use, or use the most recent one by default.

Most recent summary file: !ls -t .sessions/session-summary-*.md 2>/dev/null | head -1 || echo "none"

Load and Process Summary

  1. Read the summary file: Load the content of the selected session summary file

  2. Parse the context: Extract key information from the summary including:

    • Previous working directory and git status
    • Tasks that were completed
    • Current state of files and changes
    • Tools and technologies used
    • Key decisions and context
    • Next steps and TODOs
  3. Set up context:

    • Verify current directory matches the summary (or note differences)
    • Check current git status: !git status --porcelain 2>/dev/null || echo "Not a git repository"
    • Compare current state with the summary to identify what has changed
  4. Present session context: Provide a clear summary of:

    • What was accomplished in the previous session
    • Current state vs. previous state
    • Recommended next actions from the summary
    • Any discrepancies between expected and actual current state

Instructions for Resume

After loading the context:

  1. Acknowledge the loaded session: Confirm what session was loaded and key context
  2. Identify changes: Note any differences between the summary and current state
  3. Suggest next steps: Based on the "Next Steps" section from the summary
  4. Ask for direction: Ask the user what they'd like to work on next

Usage

To use this command:

  1. Run /session-resume
  2. If multiple summaries exist, specify which one: /session-resume .sessions/session-summary-YYYY-MM-DD-HHMMSS.md
  3. The assistant will load the context and help you continue where you left off

This command helps maintain continuity across OpenCode sessions by preserving and restoring the working context.

description
Save a markdown summary of the current OpenCode session

Save a comprehensive markdown summary of the current OpenCode session to a file.

The summary should include:

Session Summary Structure

  1. Session Overview

    • Date and time of session
    • Working directory: !pwd
    • Git repository status (if applicable): !git status --porcelain 2>/dev/null || echo "Not a git repository"
  2. Tasks Completed

    • List all major tasks and actions performed
    • Include any code changes, file modifications, or configurations updated
    • Note any commands executed and their outcomes
  3. Current State

    • Files that were created, modified, or deleted
    • Current git status and any uncommitted changes
    • Any ongoing work or incomplete tasks
  4. Tools and Technologies Used

    • Programming languages, frameworks, or tools involved
    • Dependencies added or removed
    • Configuration files modified
  5. Key Decisions and Context

    • Important architectural or design decisions made
    • Rationale behind specific implementation choices
    • Any challenges encountered and how they were resolved
  6. Next Steps

    • Recommended follow-up actions
    • Areas that may need attention in future sessions
    • Any TODOs or pending items

Save Location

Create the .sessions directory if it doesn't exist and save the summary there:

  • Directory: .sessions/ (create if needed): !mkdir -p .sessions
  • Filename format: session-summary-YYYY-MM-DD-HHMMSS.md
  • Current timestamp: !date +"%Y-%m-%d-%H%M%S"

Generate the complete markdown content and save it to: .sessions/session-summary-!date +"%Y-%m-%d-%H%M%S".md

Make the summary detailed enough that someone (including yourself) could understand the context and continue the work effectively in a future session.

description
Update an existing session summary with current findings and progress

Update an existing session summary by comparing the current state with a previously saved session and merging the new findings.

Find Available Session Summaries

List available session summary files in the .sessions directory: !ls -la .sessions/session-summary-*.md 2>/dev/null | head -10 || echo "No session summary files found in .sessions directory"

Select Session to Update

Most recent summary file (default): !ls -t .sessions/session-summary-*.md 2>/dev/null | head -1 || echo "none"

If the user specifies a particular session file, use that one. Otherwise, use the most recent one.

Current Session Context

Capture current session state:

Current State

  • Working directory: !pwd
  • Current git status: !git status --porcelain 2>/dev/null || echo "Not a git repository"
  • Recent git commits since last session: !git log --oneline -5 2>/dev/null || echo "No git history"
  • Modified files: !git diff --name-only HEAD 2>/dev/null || echo "No git changes"

Load and Compare Existing Session

  1. Read the existing session summary: Load the content of the selected session file
  2. Compare states: Identify what has changed since the last session:
    • New files created or modified
    • Git commits added
    • Tasks completed or progressed
    • New challenges encountered

Update Process

  1. Preserve Original Context: Keep the original session overview and initial context
  2. Append New Findings: Add a new section with timestamp for this update
  3. Update Current State: Refresh the current state section with latest information
  4. Merge Tasks: Combine completed tasks from both sessions
  5. Update Next Steps: Revise next steps based on current progress

Updated Session Structure

The updated session should maintain the original structure but include:

New Section: "Session Updates"

  • Update [Current Timestamp]: !date +"%Y-%m-%d %H:%M:%S"
    • Progress made since last session
    • New tasks completed
    • Additional challenges encountered
    • New insights or decisions

Updated Sections:

  • Current State: Refreshed with latest git status and file changes
  • Tasks Completed: Merged list from original + new tasks
  • Next Steps: Updated based on current progress

Save Updated Session

  1. Backup original: Create a backup of the original session file
  2. Save updated version: Overwrite the original session file with updated content
  3. Confirm update: Show summary of what was added/changed

Usage Examples

  1. Update most recent session: /session-update
  2. Update specific session: /session-update .sessions/session-summary-2024-01-15-143022.md
  3. The command will merge current findings with the existing session

Instructions for Update

After identifying the session to update:

  1. Load existing session: Read and parse the existing session summary
  2. Capture current state: Get current git status, recent commits, and changes
  3. Identify differences: Compare current state with the session's "Current State"
  4. Generate update: Create comprehensive update section with new findings
  5. Merge content: Combine original content with new findings
  6. Save updated session: Write the updated session back to the same file
  7. Provide summary: Show user what was updated and added

This command enables continuous session tracking across multiple opencode runs while maintaining a single, evolving session record.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment