Adapt agent backup
Local-first personal AI context loop for Code Agent conversations
npx -y skills add yinjialu/context-harness --skill adapt-agent-backupAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 3 stars3 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Implement a new local Code Agent conversation backup adapter in context-harness. Use when asked to add support for backing up another AI coding assistant, adapt a new Agent source, create collectors/hooks/config/tests for a new context-harness source, or prepare a PR that lets context-harness sync a currently unsupported Agent.
The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.
SKILL.md
6.2 KB, as published. Nobody here has run it
Adapt Agent Backup
Use this skill when adding support for a new Code Agent source to context-harness.
First Read
Before editing, read:
docs/agent-backup-adapter-architecture.md- Existing collectors in
context_harness/collectors/ - Existing tests for Codex and Claude Code in
tests/
Workflow
-
Identify the source id.
- Use lowercase kebab-case, for example
my-agent. - Infer the target Agent from the current runtime, app name, CLI name, repository metadata, process environment, or user prompt.
- Derive the id from that Agent name unless the user explicitly provides one.
- Ask the user for the target Agent only if it cannot be inferred with reasonable confidence.
- Use the same id in config, CLI, output directories, state keys, tests, and docs.
- Use lowercase kebab-case, for example
-
Check whether the source is already supported.
- Search for the source id and common aliases in
context_harness/,tests/,skills/,README.md, andREADME.zh-CN.md. - Inspect
context_harness/cli.pysync choices,context_harness/config.py,context_harness/init.py,context_harness/collectors/, andcontext_harness/hooks/. - If support is complete, do not add a duplicate adapter. Instead, verify it with existing tests or a smoke command, then report that the source is already supported.
- If support is partial or broken, repair only the missing or failing pieces and preserve the existing source id and archive/state compatibility.
- Search for the source id and common aliases in
-
Inspect the target Agent's local transcript format.
- Find default transcript paths.
- Identify session id, title, timestamps, roles, user messages, assistant messages, tool/noise events, and internal meta events.
- Check whether the Agent has a reliable stop/session hook. If not, implement manual sync only.
- Use synthetic or anonymized fixtures only.
-
Add config and initialization.
- Update
context_harness/config.pywith a new source inAppConfigandload_config. - Update
context_harness/init.pywith default config andconversations/<source>directory creation.
- Update
-
Add a collector.
- Create
context_harness/collectors/<source>.py. - Parse raw transcript files into
ConversationandMessage. - Ignore bad JSON lines, empty messages, tools, and internal metadata.
- Return
Nonefor sessions with no user-visible conversation. - Reuse
render_conversation,read_state,write_state, and the existingSyncResultpattern. - Support
latest,all_sessions, andsession_path.
- Create
-
Register CLI commands.
- Add the source to
syncchoices incontext_harness/cli.py. - Dispatch to
sync_<source>. - Respect
enabled = falsewith_disabled_result.
- Add the source to
-
Add hooks only when reliable.
- Create
context_harness/hooks/<source>.pyonly if the Agent has a stable hook/config mechanism. - Hook commands should call
sync <source> --hook-stdin. - Preserve unrelated user settings and make hook installation idempotent.
- Register hook install support in
context_harness/cli.py.
- Create
-
Update docs and skills.
- Update
README.mdandREADME.zh-CN.md. - Add the source to the supported local AI coding assistants list in both README files.
- Prefer the target Agent's official product/docs URL for the link.
- Prefer an official favicon/logo URL from the Agent's website or docs for the icon; if no reliable official icon URL exists, use a plain text link instead of adding an unofficial asset.
- Update
skills/init-context/SKILL.mdandskills/sync-conversations/SKILL.md. - Keep skills as workflow instructions; keep behavior in the CLI.
- Update
-
Add focused tests.
- Add fixtures under
tests/fixtures/. - Cover config defaults/custom paths, init directories/default config, collector archive output, skipped unchanged archives, missing source directory, latest mtime behavior, hook
session_pathoverride, noise filtering, bad JSON tolerance, filename stability, CLI sync, disabled source behavior, and hook idempotence if hooks are implemented.
- Add fixtures under
-
Verify.
- Run
uv syncif dependencies are not installed. - Run
uv run pytest. - Manually smoke test
uv run context-harness --context-home <tmp-home> sync <source> --latest 1when a fixture or local sample is available. - Keep changes small and complete; do not refactor unrelated modules.
- Prepare the PR for automated review.
- Add label
agent-backup-adapter. This label marks the PR as an Agent backup adapter and allows repository automation to run adapter-specific checks. - Add label
ai-reviewonly when an explicit Claude AI review is desired. This is a manual shortcut label and does not replaceagent-backup-adapter. - Include
Source id: <source>in the PR body. - Include transcript path/format assumptions, hook support status, verification commands, and remaining risks.
- Optional AI review enhancement: if the repository has Codex GitHub integration enabled, comment
@codex review; if Claude Code GitHub Actions is enabled, either add labelai-reviewor comment@claude review this adapter PR against the adapt-agent-backup checklist. Any one of these is acceptable as an extra AI review signal.
PR Checklist
- The adapter produces Markdown archives in
context_home/conversations/<source>/. - The adapter writes incremental state to
context_home/state/<source>-sync-state.json. - README supported-Agent lists, examples, default config, skills, CLI choices, and tests all use the same source id.
- Real user transcripts, memory, logs, state, and private machine config are not committed.
- PR has label
agent-backup-adapter, and its body includesSource id: <source>. - PR has label
ai-reviewonly when a manual Claude AI review should be requested. - PR description states transcript format assumptions, hook support status, commands run, and remaining risks.
- The diff avoids unrelated rewrites and leaves existing behavior intact outside the new adapter path.