Skip to content

feat(import): make claude-code import idempotent via source.external_id - #17

Merged
takashi-matsuyama merged 1 commit into
mainfrom
feat/import-idempotent
May 31, 2026
Merged

takashi-matsuyama merged 1 commit into
mainfrom
feat/import-idempotent

Conversation

@takashi-matsuyama

Copy link
Copy Markdown
Member

What

Makes basou import claude-code idempotent. Re-running an import — to keep a
project's provenance in sync — no longer creates duplicate sessions.

Why

Imported sessions are minted fresh Basou ids on every run, so without a stable
key, re-importing the same Claude transcript produced a duplicate session. The
Claude session id (the transcript filename) is that stable key.

How

  • Adds an optional source.external_id to the session + import schemas
    (additive; absent for live claude-code-adapter runs).
  • The transform records the Claude session id there and in the session label.
  • The importer collects existing external_ids up front and skips any
    transcript already present. Sessions imported before external_id existed
    are recognized via their claude-code import <id> label, so prior imports
    are not duplicated.
  • Skip reasons are reported separately ("already imported" vs "no actions").

Tests

  • Transform: external_id from the records' sessionId; explicit externalId
    option wins.
  • CLI: re-import is idempotent; a label-only (pre-external_id) session dedups.
  • typecheck / build / full test suite / lint all green.

🤖 Generated with Claude Code

Re-running `basou import claude-code` no longer duplicates sessions: each
imported session records the originating Claude session id in
`session.source.external_id`, and the importer skips any transcript whose id
is already present.

- Add optional `source.external_id` to the session and import schemas
  (additive; absent for live runs).
- The transform stores the Claude session id (filename / sessionId) there
  and in the session label.
- Import builds the set of existing external_ids and skips matches. Sessions
  imported before external_id existed are recognized via their
  `claude-code import <id>` label, so prior imports are not duplicated.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@takashi-matsuyama
takashi-matsuyama merged commit ffcdd06 into main May 31, 2026
7 checks passed
@takashi-matsuyama
takashi-matsuyama deleted the feat/import-idempotent branch May 31, 2026 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant