Skip to content

Sync and recovery

The trailguide project sync command restores your repository’s vendor snapshots, regenerates the guidance your agents read, and installs your repository’s skills. Run it after adding a source, changing what you include from it, its pins, or its ref, changing skills.installFor, or to restore vendored files.

Sync takes each source from the library release or commit recorded for it, its lock, so it never moves a source. To move to newer versions, run trailguide project update, which previews every change and applies it only after you confirm, offering to pin each major rule change or retirement instead. See Update rules and skills.

This page explains how to run sync, what it changes, and what to do when files are missing, outdated, or left by an interrupted update. It also explains when trailguide project build or trailguide project check is enough. For how Trailguide chooses and combines the rules and skills from each source, see How sources work.

  • trailguide project sync: Restore each source at its recorded revision, or take a new source at its newest one. Sync validates the vendored files, regenerates agent guidance, and installs skills into the target folders.
  • trailguide project update: Move each source along its ref, previewing newer versions, new rules and skills, level changes, retirements, and new commits, and apply them after you confirm. Pinned rules, library sources whose ref names a tag or commit, and sources whose ref names a commit don’t move. Update then does everything sync does.
  • trailguide project build: Apply changes to your authored rules and skills or your exceptions using the files you already have. Build regenerates guidance and installed skills without contacting a repository.
  • trailguide project check: Find out whether generated guidance, installed skills, the managed Trailguide guide, and the AGENTS.md section are up to date. Check validates stored inputs and output, reports problems, and leaves files unchanged.

You do not need to run build after a successful sync or update; both already generate the guidance. Run check when you want to verify consistency without making changes.

After installing Trailguide and setting up your project, run:

Terminal window
trailguide project sync

In a Git repository, project commands find the nearest repository root and use its .trailguide/config.yaml. Outside Git, run commands from the repository root. Custom configuration locations are not supported. The paths below are relative to .trailguide/, except the target folders, .claude/skills/ and .agents/skills/, which are relative to the repository root.

File or directoryWhat it containsWhat the commands do
config.yamlYour sources, the agents to install skills for, the skills and rules you include, pins, exceptions, forks, and aliases, and, for a library of library schema version 2, its manifest.Build and check read it without changing it. Sync moves a configuration of version 2 to version 3, as trailguide project migrate does, raising minTrailguideVersion from a release build. Update reads it, and writes a pin when you keep a rule at its current version, or an exclusion when you decline a new rule or skill.
library.yamlA library’s manifest.Project commands never read it.
README.mdThe managed Trailguide guide, a short page about the Trailguide directory.Init, build, and sync refresh an older, unedited guide. Check verifies it without changing it.
RULES.md and SKILLS.mdThe index of rule groups agents start from, and the index of installed skills, present only when the project installs skills.Sync, update, and build replace them. Check compares them with the expected output.
rules/, skills/, and assets/Rules, replacements, skills, and shared assets authored in this repository.Sync, build, and check preserve these files. Sync and update add rules/<group-id>/_group.yaml only when your authored rules in a rule group would otherwise lose the rule group’s metadata; see Keep the rule group of an authored rule. Update replaces a forked rule only when you pass --update-fork or answer yes when a terminal asks whether to replace it, and merges a source’s changes into a forked skill only when you pass --merge-fork or answer yes when a terminal asks whether to merge them.
vendor/One vendor snapshot per source: the original files of the included rule and skill versions, and their records.Sync and update replace this directory. Build and check validate it without changing it.
generated/Resolved rules, rule group pages, the full guide in GUIDE.md, and installed-skills.json.Sync, update, and build replace this directory. Check compares it with the expected output.
.claude/skills/<name>/ and .agents/skills/<name>/Installed copies of skills, one folder per skill.Sync, update, and build write, replace, and remove the skill folders Trailguide owns, and leave every other folder alone. Check compares them with the expected output. See Who owns the target folders.
../AGENTS.mdYour instructions for agents, with a section Trailguide maintains.Together with their other files, init, sync, update, and build add or refresh the section between the trailguide:begin and trailguide:end markers, and never change the rest. Check verifies the section. See Where agents start.

Replacement includes removing files that no longer belong in the output, such as removed rules, old index pages, unused library folders, and the installed folders of skills the project no longer installs. Files you add or edit inside vendor/, generated/, or an installed skill folder can be replaced or removed. Keep your changes in configuration and authored content.

For the complete directory layout, see Project files.

Commands print human-readable output by default. Add --json when another tool needs one structured response:

Terminal window
trailguide project check --json

Sync, update, and build report counts and sorted lists of added, changed, and removed paths. JSON output includes those lists in added, changed, and removed. When the command first recovered an interrupted one, it says so before the counts, which don’t include the files the recovery restored or finished, and JSON output sets recovered to true, also for an update’s preview, which writes nothing of its own; a declined update says it in its message.

  • Sync, update, and build paths are relative to the Trailguide directory, such as RULES.md, vendor/team/config.yaml, or generated/GUIDE.md, except paths in a target folder, which start with .claude/skills/ or .agents/skills/ and are relative to the repository root. Update also lists config.yaml when it writes a pin or an exclusion, and the files of a fork it replaces, and both list a rules/<group-id>/_group.yaml they add.
  • A change to AGENTS.md is reported on its own line, and in JSON in agents.

When the target folders are linked, as Linked target folders describes, each installed file is listed once, under the folder the link points to.

trailguide project update also reports each rule’s and skill’s change, versions, level, and summary. There is no separate structured summary of added or removed rule groups. To see which revisions changed, review the source records and generated provenance records.

Sync, update, and build also print the alias warning for each skill installed under an alias, and sync, update, and check print the personal skill warning for each personal skill with the name of a skill the repository installs. In JSON output they’re in value.warnings.

Check reports status and problems, including each problem’s path and suggested repair command. It verifies generated guidance, installed skills, the managed Trailguide guide, and the AGENTS.md section without writing any of them. A problem in a target folder has a path relative to the repository root, starting with .claude/skills/ or .agents/skills/.

Check exit codeMeaning
0The files are current.
1Files differ from the expected result, or an input is invalid.
2The command was used incorrectly, such as with an invalid option.

Use the problem reported by trailguide project check to choose a repair:

ProblemWhat to do
Generated guidance is missing or outdated, but vendored files are valid.Run trailguide project build.
Vendored files are missing, modified, or no longer match your configured sources or selectors.Run trailguide project sync. Preserve any edits you intended to keep as authored rules first.
The managed Trailguide guide is missing or outdated.Run trailguide project build or trailguide project sync to refresh it and regenerate guidance. Run trailguide project init to refresh only setup files.
An installed skill folder is missing, edited, or unexpected, or generated/installed-skills.json is stale, and vendored files are valid.Run trailguide project build. If the folders are missing because .gitignore excludes them, also add an exception and commit them; see Who owns the target folders.
The AGENTS.md section is missing or outdated.Run trailguide project build. If build reports that the section was edited, move your text outside the markers and delete the section first.
A reference-not-retained error says the project’s copy of a source lacks a file an installed skill links to, such as after an upgrade from an older Trailguide.Run trailguide project sync. It takes the linked files from the revision .trailguide/lock.json records, without moving the source.
Another reference- error says a skill links to a file the project can’t deliver.Follow the repair in the message: fix the configuration, such as a fork that lacks the file, or ask the source’s maintainer to fix the link. See When a skill links to a file you can’t keep.
Configuration, rule metadata, or skill metadata is invalid.Correct the reported input, then retry the appropriate command.

Run trailguide project check again after repairing the problem.

For each source, Trailguide records its revision, each included rule’s version, each installed skill, and file digests in .trailguide/lock.json. A digest detects whether a file’s contents differ from the recorded copy, and each entry’s integrity detects an entry changed outside Trailguide.

Build and check work offline. They reject missing, changed, or unexpected vendored files, invalid lockfile entries, version records that don’t cover exactly the included rules and skills, and selections that no longer match your configuration. Sync fetches the recorded files again, including replacing locally modified copies.

For skills, check also fails when:

  • An installed copy differs from what sync would write, such as after a hand edit to a file in .claude/skills/build-feature/.
  • A folder that generated/installed-skills.json lists is missing, such as because .gitignore excludes it and it was never committed.
  • generated/installed-skills.json or SKILLS.md doesn’t match the skills the configuration installs.
  • Two skills the repository installs have the same install name, or a target folder has a folder Trailguide would install a skill into but doesn’t own.
  • One of your authored skills cites a rule its library retired. The message names the replacement when there is one.
  • A copy in generated/references/ of a file an installed skill links to is missing or edited, or a vendor snapshot lacks a file an installed skill links to.

Check never reads the contents of target folders Trailguide doesn’t own.

Checksums detect changes relative to the stored record. They cannot establish that files are authentic if someone also changed that record. For record fields and rule origins, see Provenance.

The target folders, .claude/skills/ and .agents/skills/, are shared: people and other tools install skills there too. Trailguide owns only the skill folders it installed, as generated/installed-skills.json records them, and treats every other folder as someone else’s:

  • Sync, update, and build write each installed skill to <target>/<install-name>/, replacing the whole folder, and remove the folders of skills the project no longer installs, including after you remove an agent from skills.installFor that was the last to read a folder. An owned folder you edited by hand is replaced or removed like any other output.
  • They never change, remove, or read the contents of a folder Trailguide didn’t install.
  • They create a target folder, such as .claude/skills/, when they first install a skill into it, and remove it when they leave it empty.

Two errors protect folders Trailguide doesn’t own. Each fails before writing anything:

ErrorMeaning and next step
skill-folder-not-managedA target already has a folder with the install name of a skill the repository installs, and Trailguide didn’t install it, such as a hand-copied skill or another tool’s. To let Trailguide manage the skill, move or delete that folder and run the command again. To keep the folder, give the skill an alias or exclude the skill instead.
skill-name-clashTwo skills the repository installs have the same install name, such as fabrica:skills/review and pstack:skills/review, or a skill from a source and an authored skill. Installed folders are named by install name, so both can’t be installed. Give one of them an alias, or exclude it. Trailguide never renames a skill on its own.

When generated/installed-skills.json is missing or was changed outside Trailguide, Trailguide can’t tell which folders it owns, so it treats the folders it would write as not managed. Restore the record from Git, such as with git checkout -- .trailguide/generated/installed-skills.json, then run the command again.

Commit the target folders. A .gitignore that excludes them, such as with /.claude/, leaves fresh checkouts without the installed skills, and trailguide project check reports the missing folders. Change the line to /.claude/* and add the exception !/.claude/skills/; Git can’t re-include a folder inside an excluded folder. See Commit the installed skills.

Some projects make one target folder a symbolic link to the other, such as .agents/skills linked to .claude/skills, so that every agent reads the same files. Trailguide detects the link and writes each skill once, into the folder the link points to. The link itself, and a link from a parent folder such as .agents to .claude, must stay inside the project; a link that points outside the project root is refused. Every other symbolic link in a target folder is refused, as elsewhere in the project.

People also install personal skills for themselves, outside any repository, which their agents load in every repository they work in. When a personal skill has the same name as a skill the repository installs, each agent decides which one to use, and some use the personal skill without saying so. Their docs say:

AgentPersonal skill foldersRepository skill folders it shares with TrailguideWhat it does with the pair
Claude Code~/.claude/skills/.claude/skills/Uses the personal skill.
Codex~/.agents/skills/.agents/skills/Shows both.
Grok Build~/.grok/skills/, ~/.agents/skills/, and Claude Code’s.claude/skills/, through its Claude Code compatibilityNot documented.
VS Code~/.copilot/skills/, ~/.claude/skills/, ~/.agents/skills/.claude/skills/, .agents/skills/Not documented.

trailguide project sync, trailguide project update, and trailguide project check read these personal skill folders, and ~/.codex/skills/, which Codex’s current docs no longer list. They warn about each pair, naming both paths and, for each agent that reads both copies, what it does:

Warning: your personal skill ~/.claude/skills/build-feature has the same name as this project's build-feature (fabrica:skills/build-feature, installed at .claude/skills/build-feature).
Claude Code uses your personal skill.
Grok Build reads both, and its docs don't say which it uses.
VS Code reads both, and its docs don't say which it uses.
Rename or remove your personal skill to use the project's.

The warning applies to required skills too: a personal skill wins over the repository’s in the agents that prefer personal skills, and Trailguide only warns. It never writes to your home directory, and the warning never fails a command, so trailguide project check in CI, which has no personal skills, passes as before. With no personal skill of the same name, nothing is printed. SKILLS.md doesn’t tell agents to prefer the repository’s skills.

An authored rule needs its rule group’s metadata, from rules/<group-id>/_group.yaml or a source. Sometimes only a source supplied it, such as when you fork a rule you included by ID and the library later retires it, or you stop including the rule group or remove the source. When a sync or update would leave your authored rules in a rule group with no metadata, it writes the rule group’s _group.yaml to rules/<group-id>/_group.yaml in the same step that replaces vendor/ and generated/, lists the file as added, and prints a warning naming it. The metadata comes from the first source whose entry in lock.json lists the rule group’s metadata, configured sources first: from the library release that now supplies that source’s library-wide files, when it still has the rule group, and otherwise from the last vendored copy, which is also what a source you removed from the configuration supplies. The file is then yours to edit like any authored rule group metadata. A vendored copy must match the digest its lockfile entry lists: when it was changed or deleted since sync wrote it, the command fails without changing anything. Restore it by running trailguide project sync with the previous configuration, then make your change and sync again, or write rules/<group-id>/_group.yaml yourself.

Sync, update, and build keep the previous output while installing replacement files. If installation fails, the command restores the previous directories. The installed skill folders in the target folders are part of the same step: one lock and one recovery journal cover them together with vendor/ and generated/, so recovery restores or finishes them all together. If the process stops during replacement, the next sync, update, or build recovers the previous output before starting its own work. Update installs the pins, exclusions, and basedOn values it writes to config.yaml, each fork it replaces with the newest version, and each forked skill it merges a source’s changes into, in the same step, so recovery restores or finishes config.yaml, the replaced authored rules and their asset directories, the merged skill folders, vendor/, and generated/ together. Likewise, recovery keeps or removes a rules/<group-id>/_group.yaml that sync or update added together with vendor/ and generated/. A failed or interrupted update may leave empty directories under rules/, such as a rule group’s first assets/ directory that replacing a fork created. They’re harmless: every command ignores them, and you can delete them. The AGENTS.md section is part of that step too, so recovery restores or finishes AGENTS.md with the other files.

If the update completed but cleanup was interrupted, the next sync or build finishes deleting the backups. The completed update remains complete.

SituationWhat to do
Another Trailguide command is still writing files.Let it finish before starting another update.
A previous writing process stopped on this machine.Retry sync or build. Trailguide can reclaim its lock and recover the interrupted operation.
Check reports a pending recovery.Run sync or build after any active writer exits. Check reports the problem but does not repair it.
Recovery reports edited output or backups, an incomplete lock, or a damaged journal.Stop automatic retries, verify that no writer is running, and inspect the reported files. Preserve backups and the recovery journal for manual recovery.

A lock records which process owns the update. Trailguide only reclaims a lock when it can establish that the process has stopped on the same machine. Active processes, locks from another machine, and incomplete ownership records block writes.

Recovery refuses to overwrite output or backups edited after an interruption. Follow the reported error instead of deleting recovery files to force the command through.

Sync, update, and build prepare and validate the complete replacement, including every installed skill folder, before installing it. Immediately before replacement, they check that the original input and output files, including the owned skill folders, have not changed. If another process changed them, the update stops.

Trailguide uses these temporary directories beside your configuration, for the target folders too:

DirectoryPurpose
.trailguide-lockAllows only one cooperating Trailguide command to write at a time.
.trailguide-transactionHolds the recovery journal and previous output during replacement. The journal records the update’s progress.
.trailguide-cleanupMarks a completed update whose backups can be deleted.

After completing an update, Trailguide renames the transaction directory to the cleanup directory before deleting backups. It also discards abandoned staging files when no journal or backups exist.

A journal that covers target folders uses a newer format than earlier versions of Trailguide read. An earlier version that finds one stops and asks you to upgrade Trailguide, rather than reporting a damaged journal.

Avoid editing managed directories during an update. Replacing vendor/, generated/, the installed skill folders, and, for update, config.yaml takes separate filesystem operations, so another program can briefly see a mixture of old and new files. Check detects an active update instead of accepting mixed output as consistent.

Cancellation can stop work before replacement starts. Once replacement begins, the command finishes or rolls back before returning.

These protections apply to cooperating Trailguide commands on a local filesystem with normal file-renaming behavior. They do not guarantee recovery from power loss, protection against hostile concurrent file changes, or locking on network filesystems.

All operations reject symbolic links and special files within the directories they inspect, except a link between the target folders, as Linked target folders describes. They also reject regular files with multiple hard links. Ordinary aliases in the project’s parent path, such as macOS /tmp, are supported.

Input resourceLimit
Each file64 MiB.
Each directory tree256 MiB and 30,000 entries.
Each path64 segments.

Reading a source has additional, stricter limits. Output paths must remain distinct after normalization for case-insensitive filesystems.

Fabrica TrailguideMIT licensedPrivacy

Built with Fabrica.