# feat(import): add hidden 'entire import claude-code' command under labs

`dc13899`→[main](/content/gh/entireio/cli/commits/main/index.html)·

computermode·3w ago·4 files·+115 added/-0 removed

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

## Sessions

dc1cf8d69df4View transcript

[?\
Implement Claude History Import FeatureClaude Code·Opus 4.8·3 steps](/content/gh/entireio/cli/session/897809d4-ecab-4dc6-aa21-97661cb62607#timeline-dc1cf8d69df4/index.html)

## Changes

4

- cmd/entire/cli

- Aimport_cmd.go+70

- Aimport_cmd_test.go+39

- Mlabs.go+5

- Mroot.go+1

```
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70

package cli

import (
	"fmt"
	"time"

"github.com/spf13/cobra"

"github.com/entireio/cli/cmd/entire/cli/importclaude"
	"github.com/entireio/cli/cmd/entire/cli/paths"
)

func newImportCmd() *cobra.Command {
	cmd := &cobra.Command{
		Use:    "import",
		Short:  "Import pre-existing agent history into Entire (experimental)",
		Hidden: true,
		RunE:   func(c *cobra.Command, _ []string) error { return c.Help() },
	}
	cmd.AddCommand(newImportClaudeCodeCmd())
	return cmd
}

func newImportClaudeCodeCmd() *cobra.Command {
	var pathFlag string
	var dryRun bool
	var sessions []string

cmd := &cobra.Command{
		Use:   "claude-code",
		Short: "Import existing Claude Code transcripts as local, read-only checkpoints",
		Long: `Import pre-existing Claude Code transcripts for this repo (the past month)
as local-only, read-only checkpoints. Imported history is searchable and
explainable but is never pushed and not rewindable.`,
		Args: cobra.NoArgs,
		RunE: func(c *cobra.Command, _ []string) error {
			ctx := c.Context()
			repoRoot, err := paths.WorktreeRoot(ctx)
			if err != nil {
				c.SilenceUsage = true
				fmt.Fprintln(c.ErrOrStderr(), "Not a git repository. Run 'entire enable' from within a git repository.")
				return NewSilentError(err)
			}
			repo, err := openRepository(ctx)
			if err != nil {
				return fmt.Errorf("open repository: %w", err)
			}
			defer repo.Close()

res, err := importclaude.Run(ctx, repo, importclaude.Options{
				RepoRoot: repoRoot, OverridePath: pathFlag, SessionFilter: sessions,
				Now: time.Now(), DryRun: dryRun,
			})
			if err != nil {
				return err
			}
			verb := "Imported"
			if dryRun {
				verb = "Would import"
			}
			fmt.Fprintf(c.OutOrStdout(), "%s %d turn(s) from %d session(s) (%d already imported).
",
				verb, res.TurnsImported, res.SessionsScanned, res.TurnsSkipped)
			return nil
			},
		}
	cmd.Flags().StringVar(&pathFlag, "path", "", "Override the Claude projects directory to import from")
	cmd.Flags().BoolVar(&dryRun, "dry-run", false, "Report what would be imported without writing")
	cmd.Flags().StringSliceVar(&sessions, "session", nil, "Import only these session IDs (repeatable)")
	return cmd
}
```

Acmd/entire/cli/import_cmd.go+70

```
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

package cli

import (
	"bytes"
	"os"
	"path/filepath"
	"strings"
	"testing"

"github.com/entireio/cli/cmd/entire/cli/testutil"
)

func TestImportClaudeCode_DryRunReportsCounts(t *testing.T) {
	// Not parallel: uses t.Chdir for CWD-based repo/worktree resolution.
	repoDir := t.TempDir()
	testutil.InitRepo(t, repoDir)
	testutil.WriteFile(t, repoDir, "f.txt", "x")
	testutil.GitAdd(t, repoDir, "f.txt")
	testutil.GitCommit(t, repoDir, "init")
	 t.Chdir(repoDir)

claudeDir := t.TempDir()
	if err := os.WriteFile(filepath.Join(claudeDir, "s.jsonl"),
		[]byte(`{"type":"user","uuid":"u1","message":{"role":"user","content":"hi"}}`+"\n"), 0o644); err != nil {
		t.Fatal(err)
	}

cmd := newImportCmd()
	var out bytes.Buffer
	cmd.SetOut(&out)
	cmd.SetErr(&out)
	cmd.SetArgs([]string{"claude-code", "--path", claudeDir, "--dry-run"})
	if err := cmd.Execute(); err != nil {
		t.Fatalf("execute: %v (out=%q)", err, out.String())
	}
	if !strings.Contains(out.String(), "Would import 1") {
		t.Fatalf("dry-run summary missing count: %q", out.String())
	}
}
```

Acmd/entire/cli/import_cmd_test.go+39

```
24 unmodified lines

25
26
27
28
29
30
31
32
33
34
35

24 unmodified lines

Invocation:  "entire investigate",
		Summary:     "Run a multi-agent investigation against a topic, issue, or seed doc",
	},
	{
		CommandPath: []string{"import", "claude-code"},
		Invocation:  "entire import claude-code",
		Summary:     "Import existing Claude Code transcripts as local, read-only history",
	},
	{
		CommandPath: []string{"tokens"},
		Invocation:  "entire tokens",
```

Mcmd/entire/cli/labs.go+5

```
89 unmodified lines

90
91
92
93
94
95
96

89 unmodified lines

cmd.AddCommand(newDoctorCmd())          // 'doctor' (group: trace/logs/bundle)
	cmd.AddCommand(newLabsCmd())            // 'labs' (experimental workflow discovery)
	cmd.AddCommand(newPluginGroupCmd())     // 'plugin' (managed install/list/remove)
	cmd.AddCommand(newImportCmd())          // 'import' (hidden; import pre-existing agent history)

// Top-level lifecycle and standalone commands.
	cmd.AddCommand(cliReview.NewCommand(buildReviewDeps(newReviewAttachCmd()))) // hidden during maturation; runs configured review skills

```
