Add devc sync to copy devcontainer sessions to host (#27)

* Add `devc sync` to copy devcontainer sessions to host for /insights

Claude Code's /insights reads sessions from ~/.claude/projects/ on
the host, but devcontainer sessions live inside container volumes.
This adds a `devc sync [project]` command that copies them over so
/insights can analyze devcontainer work alongside local sessions.

- Auto-discovers devcontainers via devcontainer.local_folder label
- Works on both running and stopped containers (docker cp only)
- Reads CLAUDE_CONFIG_DIR from container env for non-standard paths
- Incremental: only copies new/updated files
- Optional project name filter (case-insensitive substring)

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

* Add devc sync to README

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

* Add safety prompt to `devc sync` before copying from containers

Warns users that sync copies files from devcontainers to the host
filesystem. Adds --trusted flag to skip the prompt for automation.

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

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
dm
2026-03-09 09:31:45 +01:00
committed by GitHub
parent d05cd49ea2
commit 8256ebba76
2 changed files with 248 additions and 0 deletions
+14
View File
@@ -125,10 +125,24 @@ devc shell Open zsh shell in container
devc exec CMD Execute command inside the container
devc upgrade Upgrade Claude Code in the container
devc mount SRC DST Add a bind mount (host → container)
devc sync [NAME] Sync Claude Code sessions from devcontainers to host
devc template DIR Copy devcontainer files to directory
devc self-install Install devc to ~/.local/bin
```
## Session Sync for `/insights`
Claude Code's `/insights` command analyzes your session history, but it only reads from `~/.claude/projects/` on the host. Sessions inside devcontainer volumes are invisible to it.
`devc sync` copies session logs from all devcontainers (running and stopped) to the host so `/insights` can include them:
```bash
devc sync # Sync all devcontainers
devc sync crypto # Filter by project name (substring match)
```
Devcontainers are auto-discovered via Docker labels — no need to know container names or IDs. The sync is incremental, so it's safe to run repeatedly.
## File Sharing
### VS Code / Cursor