AgentSkillsCN

session-export

生成结构化的 AI 会话摘要,包括任务信息、所用模型以及已采取的操作,并以 Markdown 文件形式保存。

SKILL.md
--- frontmatter
name: session-export
description: Generate a structured AI session summary including task info, models used, and actions taken, saved as a Markdown file.

Session Export Skill

You are a Documentation Archivist. Your goal is to capture the context and value of this session and persist it into a clean, local Markdown file.

Output Format

You must generate the content using this exact structure. The JSON block allows for future machine parsing, while the <details> tag keeps it clean for human readers.

markdown
# Session Summary

> [!NOTE]
> This summary was auto-generated by OpenCode.

<details open><summary><strong>AI Session Data</strong></summary>
<p>

```json
{
  "info": {
    "title": "<brief task description>",
    "agent": "opencode",
    "models": ["<model(s) used>"]
  },
  "summary": [
    "<action 1>",
    "<action 2>",
    ...
  ]
}
</p> </details>

detailed-notes

(Optional: Add any code snippets or specific warnings here if relevant)

Workflow

1. Export Session Data

Get session data using OpenCode CLI:

bash
opencode export [sessionID]

Returns JSON with session info including models used. Use current session if no sessionID provided.

2. Context Analysis

Scan the conversation history. You do not need external CLI tools.

  • Identify the Primary Goal (Title).
  • List the Key Actions taken (Chronological order).
  • Identify the Models used (if available in context, otherwise default to "unknown").

3. Generate Summary JSON

From exported data and conversation context, create summary:

  • title: 2-5 word task description (lowercase)
  • agent: always "opencode"
  • models: array from export data
  • summary: array of terse action statements
    • Use past tense ("added", "fixed", "created")
    • Start with "user requested..." or "user asked..."
    • Chronological order
    • Attempt to keep the summary to a max of 25 turns ("user requested", "agent did")
    • NEVER include sensitive data: API keys, credentials, secrets, tokens, passwords, env vars

4. Security Sanitization (CRITICAL)

Before writing the file, you MUST scan your generated summary for secrets. NEVER include:

  • API keys, tokens, secrets (e.g., sk-proj-...).
  • Passwords or credentials.
  • Real environment variable values (use <REDACTED> or $ENV_VAR).
  • Internal hostnames or IP addresses.

5. Write to File

  • Target File: session_summary.md (or user-specified filename).
  • Action: Create or Overwrite.
  • Do not output the JSON to the chat console. Write it to the file system.

Example Summary

For a session where user asked to add dark mode:

json
{
  "info": {
    "title": "dark mode implementation",
    "agent": "opencode",
    "models": ["claude-3-5-sonnet"]
  },
  "summary": [
    "user requested dark mode toggle in settings",
    "agent explored existing theme system",
    "agent created ThemeContext for state management",
    "agent added DarkModeToggle component",
    "agent updated CSS variables for dark theme",
    "agent ran tests and fixed 2 failures"
  ]
}