framework docs
AI

ai_sync_context()

Sync AI Assistant Context Files

Copies content from the canonical AI assistant file to all other AI files, adding a warning header to non-canonical files.

Usage

ai_sync_context(config_file = NULL, force = FALSE, verbose = TRUE)

Arguments

config_file
Path to configuration file (default: auto-detect settings.yml/settings.yml)
force
Logical; if TRUE, overwrite even if target is newer (default: FALSE)
verbose
Logical; if TRUE (default), show sync messages

Value

Invisible list with sync results

Details

This function reads the ai.canonical_file setting from settings.yml and copies its content to all other AI assistant instruction files that exist in the project.

The canonical file is copied as-is. Non-canonical files receive a warning header indicating they are auto-synced and should not be edited directly.

Supported files:

  • AGENTS.md - Cross-platform AI assistants
  • CLAUDE.md - Claude Code
  • .github/copilot-instructions.md - GitHub Copilot

Examples

if (FALSE) {
# Sync AI context files
ai_sync_context()
# Force sync even if targets are newer
ai_sync_context(force = TRUE)
# Silent sync (for git hooks)
ai_sync_context(verbose = FALSE)
}