Skip to content

feat: add Claude Code installation target - #21

Merged
karngyan merged 2 commits into
mainfrom
feat/claude-code-install-target
Jul 16, 2026
Merged

feat: add Claude Code installation target#21
karngyan merged 2 commits into
mainfrom
feat/claude-code-install-target

Conversation

@karngyan

Copy link
Copy Markdown
Contributor

Claim

Autophagy can now install a shadow-passed, review-approved mutation as a repo-scoped Claude Code skill, alongside the existing Codex target. Most users run Claude Code; before this the only materializer wrote Codex skills.

A Claude Code install writes exactly one file — <repo>/.claude/skills/autophagy-<id>/SKILL.md — with name/description YAML frontmatter and a Markdown body containing the reviewed instruction, the exact versioned trigger selectors, the exclusions, and an evidence footer citing the exact supporting/counterexample AEP event IDs plus the mutation ID and version.

What changed

  • autophagy-install: introduced an InstallTarget enum (Codex, ClaudeCode) that parameterizes one shared code path — planning, non-overwrite materialization (create_new), symlink-escape refusal, and byte-exact drift-checked rollback are all target-agnostic. The target only selects the skill directory (.agents/skills vs .claude/skills), the registry identifier (codex_repo_skill vs claude_code_repo_skill), and the agent named in the body. plan_codex_skill stays as a thin wrapper and CodexSkillPlan as a type alias, so existing callers are unaffected. The Codex body is byte-for-byte unchanged.
  • Store: migration 0007 recreates mutation_installations (SQLite cannot alter a CHECK in place) with target IN ('codex_repo_skill','claude_code_repo_skill') and a relative_path check that accepts either skill path; existing rows copy forward. The registration validator accepts both targets with their matching path prefix.
  • CLI: mutations install gains --target codex|claude-code, defaulting to codex (existing behavior and --output json shape unchanged; the report now also carries target). mutations uninstall needs no flag — it reconstructs the materializer from the stored audit target.
  • macOS viewer: bumped knownSchemaVersion 6 → 7 so the read-only app treats v7 (the new default) as .supported rather than "newer-than-known".
  • Docs: rewrote docs/guides/shadow-and-installation.md to cover both targets; added ADR 0006 (required because a stored schema changed); updated the schema doc and the ADR 0005 known-version note.

Evidence

  • mise run check passes (fmt, clippy -D warnings + pedantic, cargo test --workspace, pandoc GFM docs, actionlint).
  • swift test for apps/macos passes (25 tests).
  • New tests: install-crate round-trip for Claude Code (deterministic plan, evidence footer with exact event IDs, non-overwrite, symlink-escape refusal, drift refusal, reversible reinstall, distinct-from-Codex plan, registry-id round trip); store-level Claude Code registration/audit/uninstall + unknown-target rejection; CLI-level --target claude-code dry-run JSON asserting target and .claude/skills path.
  • End-to-end smoke on a temp git repo: fixture DB → propose → challenge → replay → shadow → install --target claude-code produced a valid SKILL.md (frontmatter + instruction + selectors + exclusions + evidence footer citing evt_failure_1..3 and evt_success_1, mutation ID, version 0.1.0) → uninstall removed the skill and its directory and transitioned the mutation to retired.

Privacy implications

Preserves the local-first, offline, reversible guarantees. One file is written inside the user-selected Git repository only after the mutation passes challenge/replay/shadow and the user supplies the exact repo-skill-write confirmation phrase. Nothing is written to ~/.claude, global config, hooks, slash commands, or off the machine. The body is deterministic, already-redacted, reviewed content plus the exact evidence identifiers the project requires derived findings to retain. Uninstall removes the file and directory and refuses to touch content whose hash no longer matches.

Note on migrations

Added migration 0007; origin/main currently tops out at 0006. A concurrent PR (synthesis / mutations contract v0.2) may also add a store migration — if so, expect a renumber of 0007 at merge time (rename the file, bump the version/include_str! in migration.rs; the migration-count assertions in store.rs are literal 7s that would also move, while the version-check tests in migration.rs are already computed dynamically).

🤖 Generated with Claude Code

karngyan and others added 2 commits July 17, 2026 02:01
Materialize shadow-passed mutations as repo-scoped Claude Code skills at
.claude/skills/autophagy-<id>/SKILL.md alongside the existing Codex target,
sharing one InstallTarget-parameterized code path for planning, non-overwrite
materialization, symlink-escape refusal, and drift-checked rollback.

The Claude Code body reproduces the reviewed instruction, versioned trigger
selectors, exclusions, and an evidence footer citing exact supporting and
counterexample event IDs plus mutation ID and version. Migration 0007 relaxes
the installation registry CHECK constraints to accept the new target and its
.claude/skills path; uninstall reconstructs the materializer from the stored
target. The CLI gains --target codex|claude-code (defaulting to codex).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015LY7xtercMc3NtLeX2z4YV
- record_uninstall derives the transition reason (and metadata) from the
  stored installation target instead of hardcoding the Codex reason, so a
  Claude Code uninstall now records "Claude Code repo skill uninstalled".
- CLI plain-text install output appends target as the last TSV column rather
  than inserting it mid-row, preserving positional parsers.
- Document the evidence-footer asymmetry (Claude Code only, for Codex
  byte-stability; the DB audit retains evidence IDs for both) in ADR 0006 and
  the installation guide.
- Add a CLI-level real (non-dry-run) install --target claude-code + uninstall
  round-trip test exercising audit-driven target reconstruction, and assert the
  claude-code uninstall reason in the store test.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015LY7xtercMc3NtLeX2z4YV
@karngyan
karngyan merged commit abcf562 into main Jul 16, 2026
2 checks passed
@karngyan
karngyan deleted the feat/claude-code-install-target branch July 16, 2026 20:44
karngyan added a commit that referenced this pull request Jul 16, 2026
PR #21 landed docs/decisions/0006-claude-code-install-target.md, colliding
with the model-synthesis ADR. Renumber to 0007 and update all references.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015LY7xtercMc3NtLeX2z4YV
karngyan added a commit that referenced this pull request Jul 16, 2026
* feat: add local model synthesis providers

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015LY7xtercMc3NtLeX2z4YV

* maint: renumber synthesis ADR to 0007 to avoid collision

PR #21 landed docs/decisions/0006-claude-code-install-target.md, colliding
with the model-synthesis ADR. Renumber to 0007 and update all references.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015LY7xtercMc3NtLeX2z4YV

* fix: address PR #22 review (redirect privacy hole + hygiene)

- remote.rs: disable HTTP redirects (max_redirects(0) + will_error(false)) and
  treat any 3xx as a transport error, so a loopback endpoint cannot 3xx-redirect
  evidence to a non-loopback host past the locality guard. Add mock-server test.
- Add a test asserting the transport-error path never echoes the Bearer key.
- ADR 0007: correct migration reference to 0008_mutation_provenance.
- Prompt test: assert a raw-payload corpus marker is absent from the prompt.
- Tighten the prompt-size bound to <=750 approx tokens to pin the documented figure.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015LY7xtercMc3NtLeX2z4YV

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
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