Skip to content

Restore two-way agent config sync with standardized bootstrap - #6

Merged
GoatInAHat merged 1 commit into
mainfrom
claude/minimal-universal-template-om1w16
Aug 31, 2026
Merged

GoatInAHat merged 1 commit into
mainfrom
claude/minimal-universal-template-om1w16

Conversation

@GoatInAHat

Copy link
Copy Markdown
Owner

Follow-up to #5, which trimmed too far: it dropped the write-once-use-everywhere propagation. This restores that functionality in consolidated form and closes the gaps that kept it from being genuinely cross-environment. Only canonical and standard files are tracked (18 files); everything harness-specific stays generated per checkout and gitignored.

Two-way sync, one script. .agents/sync.py replaces the old sync.py + check-skills.py + bootstrap.sh and now converges both directions:

  • Canon → harnesses: renders MCP configs and skill symlinks for 11 harnesses from .agents/skills/ and .agents/mcp/servers.json; the rest read AGENTS.md + .agents/skills/ natively.
  • Harnesses → canon: a skill directory dropped in .claude/skills/, or an MCP server added through any one harness (claude mcp add, a hand edit to any rendered config, all dialects including the Codex TOML), is adopted into .agents/ and rendered back out to every other harness.
  • Enforcement: .agents/setup installs a native git pre-commit hook running sync.py check — no pre-commit framework, no pip — so a commit fails until local state and canon converge. CI runs the same check plus a full --all render.

Standardized bootstrap in every environment. One entry point, .agents/setup (stdlib Python only — no network or installs required for the core, so it can't fail in restricted sandboxes), reached through committed native hooks:

Environment Committed hook
Claude Code (web + local) SessionStart in .claude/settings.json
Codespaces / Ona / devcontainers postCreateCommand
Cursor cloud agents .cursor/environment.json install
Copilot coding agent .github/workflows/copilot-setup-steps.yml
Amp orbs runs .agents/setup by convention
Codex cloud / Jules / Devin one-line paste into their setup-script field (they read the canon natively)

Slimmer where it counts. Instructions agents load: 45-line AGENTS.md (plus committed one-line CLAUDE.md/GEMINI.md imports), down from 125 lines + two more doc files describing the same machinery. One .agents/README.md holds the machinery reference. Dropped: the model-mix enforcement hook (restrictive), the pre-commit framework dependency, and the standalone skills checker (folded into sync.py).

Shipped contents. No skills and no MCP servers preinstalled (servers.json is {}). .agents/setup installs rtk best-effort and runs rtk init for detected agents, so command output is compressed before agents read it.

Tested end to end in a scratch clone: full --all render (all outputs parse, JSON + TOML), render idempotency, adoption of a server added via .mcp.json and via the opencode dialect (local command form), tools allowlist roundtrip (enabled_tools/includeTools), skill adoption with folded YAML frontmatter (moved to canon, symlinked back, hash-locked), drift detection and lock, skill removal pruning, identical-duplicate dedupe, hook-blocked commit while unconverged and hook-passed commit after, and a clean git status after rendering (nothing untracked, nothing tracked).

🤖 Generated with Claude Code

https://claude.ai/code/session_017NWDrWeqhFGvENtps4UNf7


Generated by Claude Code

Bring back the .agents/ canon and the per-checkout, gitignored harness
adapters, consolidated: one sync.py now owns rendering, skill symlinks,
the skills lock, and validation. The sync is two-way — a skill or MCP
server installed through any one harness is adopted into .agents/ and
rendered for every other — enforced by a dependency-free git pre-commit
hook that .agents/setup installs.

Bootstrap is standardized across environments: committed native hooks
for devcontainers, Claude Code (SessionStart), Cursor cloud, Copilot's
coding agent, and Amp all call the same .agents/setup, which needs only
stdlib Python. setup also installs rtk, best-effort, to compress the
command output agents read. Instructions consolidate into AGENTS.md
(with one-line CLAUDE.md/GEMINI.md imports) plus one .agents/README.md;
no skills or MCP servers ship preinstalled.

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

chatgpt-codex-connector Bot commented Aug 31, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-08-31T20:03:55.095860Z a428222 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@GoatInAHat
GoatInAHat merged commit 8db9287 into main Aug 31, 2026
1 check passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a428222162

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .agents/sync.py
Comment on lines +377 to +381
if name in servers or name in found or not isinstance(entry, dict):
continue
config = normalize(entry)
if isinstance(config.get("url"), str) or isinstance(config.get("command"), str):
found[name] = (config, rel)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve canonical MCP deletions during reverse sync

When a server is removed from .agents/mcp/servers.json while any previously rendered adapter still contains it, foreign_servers() classifies that stale entry as a new foreign server, and absorb() immediately writes it back into the canonical file. This also contaminates branches when an ignored adapter survives a checkout, so the documented edit-and-sync workflow cannot delete or rename a server without manually removing every generated adapter first. Track the last rendered state or otherwise distinguish stale generated entries from genuinely new harness additions.

AGENTS.md reference: AGENTS.md:L28-L32

Useful? React with 👍 / 👎.

Comment thread .agents/sync.py
Comment on lines +435 to +440
adopted_servers, _ = foreign_servers(servers)
for name, (config, rel) in adopted_servers.items():
servers[name] = config
print(f"Adopted MCP server {name!r} from {rel} into .agents/mcp/servers.json")
if adopted_servers:
atomic_write(SERVERS_PATH, json_document(servers))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Reject inline credentials before adopting MCP entries

When a harness-local MCP entry contains literal credentials in fields such as env or headers, this loop copies the entire ignored configuration into the tracked .agents/mcp/servers.json without validation or redaction. Commands such as an MCP installer commonly persist supplied environment values, so an automatic setup followed by a normal commit can expose those secrets; adoption should reject literal credential values or require environment-variable references before writing the canonical file.

AGENTS.md reference: AGENTS.md:L22-L22

Useful? React with 👍 / 👎.

Comment thread .agents/sync.py
Comment on lines +690 to +695
foreign, problems = foreign_servers(servers)
failures.extend(
f"{rel}: MCP server {name!r} not in .agents/mcp/servers.json (run .agents/sync.py)"
for name, (_, rel) in foreign.items()
)
failures.extend(problems)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Compare existing adapters with rendered output

When an existing canonical server's command, URL, arguments, or tools are edited but the generated adapter is not rerendered, check() passes because foreign_servers() only reports names absent from the canon and the later validation parses newly generated strings in memory rather than the adapter on disk. The pre-commit hook therefore permits an unconverged checkout whose active harness continues using stale settings; compare every existing generated file with its expected render while still allowing adapters for undetected harnesses to be absent.

AGENTS.md reference: AGENTS.md:L36-L38

Useful? React with 👍 / 👎.

@GoatInAHat
GoatInAHat deleted the claude/minimal-universal-template-om1w16 branch August 31, 2026 21:03
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.

2 participants