Skip to content

Add sync-agents script for cross-tool AI agent configuration#5

Merged
kyleve merged 13 commits intomainfrom
sync-agents-script
Apr 4, 2026
Merged

Add sync-agents script for cross-tool AI agent configuration#5
kyleve merged 13 commits intomainfrom
sync-agents-script

Conversation

@kyleve
Copy link
Copy Markdown
Owner

@kyleve kyleve commented Apr 2, 2026

Summary

Adds a sync-agents script (Ruby) that keeps AI agent configuration in sync across Cursor, Codex, and Claude Code from a single source of truth (AGENTS.md files and .agents/skills/).

What it does:

  • Generates CLAUDE.md from each AGENTS.md (Cursor and Codex read AGENTS.md natively).
  • Syncs .agents/skills/ to .claude/skills/ for Claude Code.
  • Manages external skills from GitHub repos, pinned to commit SHAs via .agents/external-skills.json.
  • Runs incrementally — skips files already up to date.

Commands:

  • ./sync-agents — generate CLAUDE.md files and sync skills
  • ./sync-agents --add <url> [name] — add an external skill from GitHub, pinned to the current commit
  • ./sync-agents --install — fetch all external skills from the manifest (skips if present)
  • ./sync-agents --update — re-fetch all external skills at latest commit
  • ./sync-agents --git-add — sync + stage changed files (used by pre-commit hook)

Other changes:

  • Simplify root AGENTS.md and README.md; move module-specific details into nested AGENTS.md files for BroadwayCore, BroadwayUI, and BroadwayCatalog.
  • Remove Plans/ directory.
  • Add convention: shell scripts > ~20 lines should use Ruby.
  • Generated files (CLAUDE.md, .claude/skills/, external skills) are gitignored. ./ide runs ./sync-agents --install to populate them on setup.
  • Pre-commit hook runs ./sync-agents --git-add and SwiftFormat automatically.
  • Install SwiftUI Pro skill from twostraws/swiftui-agent-skill as first external skill.

Test plan

  • Clone fresh, run ./ide — verify CLAUDE.md files and skills are generated
  • Run ./sync-agents with no changes — verify silent no-op
  • Edit an AGENTS.md, run ./sync-agents — verify corresponding CLAUDE.md updates
  • Add a nested AGENTS.md, run ./sync-agents — verify CLAUDE.md created
  • Remove a nested AGENTS.md, run ./sync-agents — verify stale CLAUDE.md cleaned up
  • Run ./sync-agents --install — verify external skills fetched from manifest
  • Run ./sync-agents --install again — verify it skips already-present skills
  • Run ./sync-agents --update — verify skills re-fetched and SHA updated
  • Run ./sync-agents --update again — verify no-op when already at latest
  • Commit a change to AGENTS.md — verify pre-commit hook stages generated files

kyleve added 3 commits April 2, 2026 15:08
…ENTS.md

AGENTS.md is the single source of truth for AI agent instructions. This script
generates CLAUDE.md (for Claude Code) and .cursor/rules/*.mdc (for Cursor) so
directory-scoped instructions work across all three tools. The pre-commit hook
runs it automatically when any AGENTS.md file is staged.

Made-with: Cursor
- Sync .agents/skills/ to .claude/skills/ so skills work across Codex,
  Cursor, and Claude Code from a single source directory.
- Make sync-agents skip work when generated files are already up to date.
- Add --git-add flag to stage generated files, keeping all sync logic
  self-contained. Simplify the pre-commit hook to a one-liner.
- Add skeleton skill for custom container view controllers.

Made-with: Cursor
Cursor added native support for nested AGENTS.md files in subdirectories,
so the script no longer needs to generate .cursor/rules/*.mdc files. The
sync-agents script now only handles CLAUDE.md and .claude/skills/.

Made-with: Cursor
@kyleve
Copy link
Copy Markdown
Owner Author

kyleve commented Apr 2, 2026

@codex review

Copy link
Copy Markdown

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

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: 41ef94b811

ℹ️ 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".

kyleve added 8 commits April 2, 2026 20:34
…nvention

- Use exact full-line match (grep -qxF) for the CLAUDE.md cleanup marker
  instead of substring matching, preventing accidental deletion of hand-
  written files that happen to contain the phrase.
- Stage only files that actually changed instead of globbing all CLAUDE.md
  files in the repo, avoiding accidental commit contamination.
- Add convention to AGENTS.md: shell scripts should stay short (~20 lines),
  use Ruby for longer scripts.

Made-with: Cursor
- Trim directory trees to show only directories and key files, remove
  individual source file listings that go stale as files are added.
- Move module-specific context into nested AGENTS.md files for
  BroadwayCore, BroadwayUI, and BroadwayCatalog.
- Replace tree-drawing characters with plain text across the codebase.

Made-with: Cursor
…skills

Rewrite the bash script in Ruby for readability and portability (per the
project convention for scripts > 20 lines). All existing behavior is
preserved: incremental sync, marker-based cleanup, and --git-add.

New commands:
- --install <github-url> [name]: clone a skill from GitHub into
  .agents/skills/ and record it in .agents/external-skills.json
- --update: re-fetch all external skills from their pinned refs

Install the SwiftUI Pro skill from twostraws/swiftui-agent-skill as the
first external skill.

Made-with: Cursor
- Rename --install to --add (adds a new skill from a GitHub URL)
- New --install fetches all external skills from the manifest, skipping
  any already present (idempotent, like npm ci)
- --update force re-fetches all external skills to latest
- Gitignore external skills in .agents/skills/ via a generated
  .gitignore managed from the manifest; gitignore all of .claude/skills/
- Run ./sync-agents --install in ./ide so skills are fetched on setup

Made-with: Cursor
Generated CLAUDE.md and .claude/skills/ are now fully gitignored and
recreated by ./sync-agents (run automatically by ./ide). Update AGENTS.md
to document all sync-agents commands.

Made-with: Cursor
--add now resolves HEAD to a commit SHA and writes that to the manifest
instead of "main". --update clones the default branch, compares the new
SHA to the pinned one, and only re-fetches if it changed. --install
fetches the exact pinned SHA. Use git-fetch instead of git-clone to
support both branch names and commit SHAs.

Made-with: Cursor
Document all sync-agents commands in the script header. Rewrite the
README to explain the full setup flow, pre-commit hooks, and how to
manage external AI agent skills.

Made-with: Cursor
@kyleve
Copy link
Copy Markdown
Owner Author

kyleve commented Apr 4, 2026

@codex review

Copy link
Copy Markdown

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

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: 2500b51e46

ℹ️ 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".

kyleve added 2 commits April 4, 2026 15:18
Document the two patterns: non-lazy single child containers (add child
in init, view in viewDidLoad, layout in viewWillLayoutSubviews) and
lazy single child containers (setup in viewIsAppearing).

Made-with: Cursor
Address Codex review: use clone_default_branch (fetches HEAD) instead
of hardcoding "main" in --add/--update, and include dotfiles in
dirs_equal? via FNM_DOTMATCH so .claude/skills/ stays in sync.

Made-with: Cursor
@kyleve kyleve merged commit 0697605 into main Apr 4, 2026
2 checks passed
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