npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ai-session-archiver

v1.3.0

Published

Archive Codex, OpenCode, and Claude Code sessions to Obsidian vault

Downloads

81

Readme

AI Session Archiver

npm version License: MIT

Archive AI coding assistant sessions to your Obsidian vault

🇰🇷 한국어

AI Session Archiver is a CLI tool that reads local session logs from AI coding assistants (Codex, OpenCode, Claude Code) and converts them into structured Obsidian notes — automatically extracting goals, learnings, troubleshooting, and key concepts.

How It Works

A local post-processor that runs after a session ends:

AI coding session ends
        ↓
ai-session-archiver reads local log files (JSONL / SQLite)
        ↓
LLM analysis (Claude Haiku)  ←  ANTHROPIC_API_KEY set
  or heuristic fallback       ←  no API key / --offline
        ↓
Markdown note saved to Obsidian vault

LLM mode (default when ANTHROPIC_API_KEY is set): Claude Haiku analyzes the session transcript and extracts goals, learnings, troubleshooting items, and tags — accurately, in any language.

Offline mode (no API key or --offline flag): fully local heuristic analysis, no external calls.

The most convenient setup is to hook it into Claude Code's Stop event, so archiving happens automatically after every turn.

Quick Start

# Install globally
npm install -g ai-session-archiver

# One-time setup: registers Stop hook + installs /archive command for Claude Code
ai-session-archiver install --vault ~/Obsidian

# Optional: set your Anthropic API key for LLM-powered analysis
export ANTHROPIC_API_KEY=sk-ant-...

That's it. From now on:

  • Auto: Every Claude Code turn archives the session automatically (Stop hook)
  • On demand: Type /archive in any Claude Code session to archive interactively

Supported Providers

| Provider | Data Location | Status | |----------|--------------|--------| | Claude Code | ~/.claude/projects/**/*.jsonl | Fully supported | | Codex | ~/.codex/sessions/**/*.jsonl | Fully supported | | OpenCode | ~/.local/share/opencode/opencode.db | Fully supported |

Claude Code Integration (Recommended)

Run one command to get both auto-archiving and the /archive slash command:

ai-session-archiver install --vault ~/Obsidian

This does two things at once:

1. Registers a Stop hook — archives every Claude Code session automatically

Adds to ~/.claude/settings.json:

{
  "hooks": {
    "Stop": [
      {
        "matcher": "",
        "hooks": [
          {
            "type": "command",
            "command": "ai-session-archiver hook --vault ~/Obsidian --output \"10-Sessions\""
          }
        ]
      }
    ]
  }
}

2. Installs /archive command — interactive archiving inside Claude Code

Adds ~/.claude/commands/archive.md so Claude knows how to use the archiver. Now you can say:

/archive                          → archives the most recent Claude Code session
/archive opencode                 → archives the most recent OpenCode session
/archive codex <session-id>       → archives a specific Codex session
/archive --dry-run                → preview without saving
/archive all recent               → archives 5 most recent sessions across all providers

Claude picks the right session and runs the command for you — no need to remember IDs or flags.

Skip individual steps

ai-session-archiver install --vault ~/Obsidian --skip-hook     # command only
ai-session-archiver install --vault ~/Obsidian --skip-command  # hook only
ai-session-archiver setup-hook --vault ~/Obsidian              # hook only (legacy)

Manual hook invocation

echo '{"session_id":"<id>","stop_hook_active":false}' | ai-session-archiver hook --vault ~/Obsidian

To remove everything: delete the Stop hook entry from ~/.claude/settings.json and remove ~/.claude/commands/archive.md.

All Commands

providers — Check availability

ai-session-archiver providers
Installed Providers:
====================
Claude Code (claude-code)
  Status: ✓ Available
OpenCode (opencode)
  Status: ✓ Available
Codex (codex)
  Status: ✓ Available

sessions — List sessions

# All providers
ai-session-archiver sessions

# Filter by provider
ai-session-archiver sessions --provider claude-code

# Limit results
ai-session-archiver sessions --limit 20
Provider     | Session ID                           | Msgs | Last Updated
-------------|--------------------------------------|------|-------------
claude-code  | 66bc677a-3624-495f-8e3b-effead6db2f0 |   20 | 2026. 5. 10.
codex        | 019dd95f-1bc1-7460-a7d4-657769bb4e23 |  110 | 2026. 4. 29.
opencode     | ses_23ae81207ffeYyyce881Gsr3BE        |  187 | 2026. 4. 26.

archive — Archive a specific session

ai-session-archiver archive <session-id> --provider <provider>

# Options
-v, --vault <path>      Obsidian vault path (default: ~/Obsidian)
-o, --output <folder>   Output folder inside vault (default: 10-Sessions)
-t, --template <path>   Custom template file
--dry-run               Preview output without saving
--offline               Skip LLM analysis, use heuristic only
# Preview first
ai-session-archiver archive ses_23ae81207ffeYyyce881Gsr3BE \
  --provider opencode \
  --vault ~/Obsidian \
  --dry-run

# Save to vault
ai-session-archiver archive ses_23ae81207ffeYyyce881Gsr3BE \
  --provider opencode \
  --vault ~/Obsidian \
  --output "10-Sessions"

recent — Archive recent sessions in bulk

# Archive the 5 most recent sessions from all providers
ai-session-archiver recent --limit 5 --vault ~/Obsidian

# Only from a specific provider
ai-session-archiver recent --provider codex --limit 3 --vault ~/Obsidian

hook — Run from Claude Code Stop hook

# Reads session_id from stdin (called automatically by Claude Code)
ai-session-archiver hook --vault ~/Obsidian --output "10-Sessions"

setup-hook — Register Claude Code Stop hook

ai-session-archiver setup-hook --vault ~/Obsidian --output "10-Sessions"

Output Format

Each archived session becomes a markdown file in your vault:

Filename: 2026-05-10-typescript-66bc677a-3624.md

---
date: 2026-05-10
session_id: 66bc677a-3624-495f-8e3b-effead6db2f0
tags: [typescript, obsidian, codex, troubleshooting]
concepts:
- [[TypeScript]]
- [[Obsidian]]
- [[Codex]]
---

## Context
Archive AI coding assistant sessions to Obsidian vault

## What I Did
OpenCodeProvider 재구현 / Stop hook 등록 명령어 추가 / vault-writer overwrite 지원

## Key Learnings
- OpenCode는 ~/.local/share/opencode/opencode.db에 SQLite로 저장
- Claude Code Stop hook으로 세션 종료 시 자동 아카이브 가능

## Issues & Solutions
| 문제 | 원인 | 해결 |
|-----|------|------|
| OpenCodeProvider 미동작 | globalThis.session_list 사용 | SQLite 직독으로 재구현 |

## Related
- [[TypeScript]]
- [[Obsidian]]

Template Customization

Available variables

| Variable | Description | |----------|-------------| | {{it.date}} | Session date (YYYY-MM-DD) | | {{it.sessionId}} | Full session ID | | {{it.goal}} | First user message / session context | | {{it.summary}} | Key actions taken | | {{it.learningPoints}} | Bullet list of extracted learnings | | {{it.troubleshooting}} | Table of problems, causes, and solutions | | {{it.concepts}} | Tech concepts as [[wikilinks]] | | {{it.tags}} | Comma-separated tags |

Custom template

---
date: {{it.date}}
id: {{it.sessionId}}
type: dev-session
---

# {{it.goal}}

## Summary
{{it.summary}}

## Learnings
{{it.learningPoints}}

## References
{{it.concepts}}
ai-session-archiver archive <id> --provider claude-code --template ./my-template.md

Installation

npm install -g ai-session-archiver

Requirements: Node.js 18+, sqlite3 CLI (pre-installed on macOS)

Optional: ANTHROPIC_API_KEY — enables LLM-powered analysis (Claude Haiku). Without it, the tool falls back to offline heuristic analysis.

Development

git clone <repo-url>
cd ai-session-archiver
npm install
npm run build
npm run test
npm run test:coverage

Project Structure

src/
├── providers/          Provider adapters (claude-code, codex, opencode)
├── analyzers/          Heuristic session analysis
├── renderers/          Markdown template rendering
├── commands/           CLI command handlers
└── utils/              slugify, vault-writer
templates/              Default and example templates

Roadmap

  • [ ] GitHub Copilot / Cursor / Aider support
  • [x] LLM-powered analysis mode (Claude Haiku, default)
  • [ ] Web UI for browsing archived sessions

License

MIT © Yeji


See PROVIDERS.md for provider-specific setup and troubleshooting.