Skip to content

feat: add the sync all, sync tools, and sync skills commands - #949

Open
ctawiah wants to merge 1 commit into
ctawiah/route-scopes-1e8afrom
ctawiah/scope-commands-1e8a
Open

ctawiah wants to merge 1 commit into
ctawiah/route-scopes-1e8afrom
ctawiah/scope-commands-1e8a

Conversation

@ctawiah

@ctawiah ctawiah commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Context

The previous PRs made sync, add, and detach work for every scope, but only sync prompts reaches them. This PR adds the commands.

What changes

  • ldcli sync all syncs prompt variations, tools, and skills in one plan, with one conflict pass and one confirmation. It takes --project only, and it has watch.
  • ldcli sync tools and ldcli sync skills sync one kind, and take --project and --key. Each has watch, add, and detach.
  • Only sync prompts has --resolve, because --resolve names variations.
  • The help of sync prompts says that it leaves out tool and skill files that no variation uses. The help of every watch says that it creates a resource from a file with upsert when the file is saved.
  • ldcli sync --help lists the new commands, and its examples use sync all.
  • The analytics event of a sync command gets a scope property, because the command name is add for every kind.

A flag-only session against a stand-in for the LaunchDarkly API:

$ ldcli sync tools add --project demo --key lookup --no-input
Bootstrapped 1 tool file in .launchdarkly.

$ ldcli sync prompts add --project demo --config-key support --key default --no-input
Added 1 variation file in .launchdarkly.

$ ldcli sync prompts --dry-run -o plaintext
Note: 1 standalone tool is not in this plan. Run ldcli sync all to include them.
No changes. 1 in sync.

(lookup changes in LaunchDarkly)

$ ldcli sync tools --yes --no-input -o plaintext
Tools
  pulled   demo/lookup   version 2

1 applied. 1 in sync.

Design notes

  • runCommand(client, scope, buildAction) replaces runPrompt, so every command runs the same code with its own scope. addApplyFlags takes the scope, and attachmentFlagHelp gives the help of the target flags of a tool or skill command.
  • cmd/sync/attachments.go builds sync tools and sync skills from one function that takes the kind.
  • scope_test.go walks every sync command and checks its exact flag set. It also sets each sync flag through an LD_* variable and through the ldcli configuration, and checks that none of them sets a flag.
  • This PR must ship in the same ldcli release as feat: apply tool and skill rows in a sync #941, with the two PRs before it.

Review focus

  • Does the flag set of each command match what it can do? scope_test.go lists them all.
  • Is the help clear for a first-time user?

Verification

  • go test ./... and golangci-lint run (v2.9.0) pass.
  • New tests: TestSyncCommandsHaveExactFlags, TestSyncCommandsReadSyncFlagsOnlyFromTheCommandLine, and TestSyncCommandScopeNamesTheKindOfTheCommand.
  • I built ldcli and ran every new command with flags only against a stand-in for the LaunchDarkly API. The script covers:
    • the empty states and the add errors
    • both notes
    • a shared tool conflict resolved with --key, and convergence after it
    • detach, and the flag errors
  • I also opened the interactive picker in a terminal.

Related changes

This stack builds on #937 to #941, which are merged.

  1. fix: exclude expanded tools from prompt diffs #957: Exclude expanded tools from prompt diffs (ctawiah/fix-prompt-tool-diff-5b1c)
  2. fix: plan a tool or skill row when a variation newly references it #945: Plan a tool or skill row when a variation newly references it (ctawiah/plan-referenced-attachments-1e8a)
  3. feat: keep unused tools and skills, and detach any resource kind #946: Keep unused tools and skills, and detach any resource kind (ctawiah/keep-unused-attachments-1e8a)
  4. feat: add tools and skills from LaunchDarkly #947: Add tools and skills from LaunchDarkly (ctawiah/add-attachments-1e8a)
  5. feat: route sync, add, and detach by scope #948: Route sync, add, and detach by scope (ctawiah/route-scopes-1e8a)
  6. This PR: add the sync all, sync tools, and sync skills commands (ctawiah/scope-commands-1e8a)
  7. feat: create a tool or a skill from the content of an add #950: Create a tool or a skill from the content of an add (ctawiah/create-attachments-1e8a)
  8. feat: add the create flags of sync tools add and sync skills add #951: Add the create flags of sync tools add and sync skills add (ctawiah/create-attachment-flags-1e8a)
  9. refactor: share the selection of a new variation, and check any kind before an add #952: Share the selection of a new variation, and check any kind before an add (ctawiah/share-variation-selection-1e8a)
  10. feat: create a prompt variation from the content of an add #953: Create a prompt variation from the content of an add (ctawiah/create-variations-1e8a)
  11. feat: add the create flags of sync prompts add #954: Add the create flags of sync prompts add (ctawiah/create-variation-flags-1e8a)

Note

Overview
Exposes multi-scope sync in the CLI: ldcli sync all runs one plan over prompt variations, tools, and skills (shared conflict handling, --project filtering, and watch), while ldcli sync tools and ldcli sync skills sync a single attachment kind with watch, add, and detach.

sync prompts is wired through the same path as the new commands: runPrompt becomes runCommand(client, scope, …), each invocation passes Scope into the sync runner, and addApplyFlags only registers --resolve for the prompts scope. Help text clarifies that prompt-only sync skips unused tool/skill files and that watch can upsert from saved files.

The sync parent command registers the new subcommands, updates top-level examples to favor sync all, and adds a scope field to sync analytics (because subcommands like add share names across kinds). scope_test.go locks down the exact flag set per runnable sync command and asserts sync flags are not populated from config or LD_* env vars.

Reviewed by Cursor Bugbot for commit 210aacc. Bugbot is set up for automated code reviews on this repo. Configure here.

@ctawiah
ctawiah added this pull request to stack #955 October 22, 2026 22:19
@cursor
cursor Bot force-pushed the ctawiah/scope-commands-1e8a branch from 4ea772d to ff7cd20 Compare October 23, 2026 00:13
@ctawiah
ctawiah removed this pull request from stack #955 October 23, 2026 00:15
@ctawiah
ctawiah added this pull request to stack #960 October 23, 2026 00:16
@ctawiah
ctawiah marked this pull request as ready for review October 23, 2026 14:10
@ctawiah
ctawiah requested a review from a team as a code owner October 23, 2026 14:10
@ctawiah
ctawiah requested review from davidbrackbill and nkester-ld and removed request for a team October 23, 2026 14:10
@cursor
cursor Bot force-pushed the ctawiah/scope-commands-1e8a branch 2 times, most recently from 9b4fd56 to 5609c60 Compare October 23, 2026 14:40
@cursor
cursor Bot force-pushed the ctawiah/scope-commands-1e8a branch 2 times, most recently from 44d4bcd to dd47d87 Compare October 23, 2026 14:56
@cursor
cursor Bot force-pushed the ctawiah/scope-commands-1e8a branch from dd47d87 to c152ad6 Compare October 23, 2026 17:07
Comment thread cmd/sync/prompt.go Outdated
Long: "Bootstrap local prompt variations from LaunchDarkly, add more variations, or synchronize changes using the LaunchDarkly manifest. " +
"Sync rechecks state before every write, rerun sync after a change.",
"Sync rechecks state before every write, rerun sync after a change. " +
"Tool and skill files that no prompt variation uses are not in this plan. Use ldcli sync all or ldcli sync tools to sync them.",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

do we want to mention ldcli sync skills here?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Yes, standalone skill files are left out too. It now reads Use ldcli sync all, ldcli sync tools, or ldcli sync skills to sync them. Fixed in 210aacc.

ldcli sync all syncs prompt variations, tools, and skills in one plan,
with one conflict pass and one confirmation. ldcli sync tools and ldcli
sync skills sync one kind, and have their own add and detach. Each new
command has watch. All of them run the sync of sync prompts with another
scope.

sync all takes --project only, so --key is an unknown flag there. Only
sync prompts has --resolve. The help of sync prompts says that it leaves
out tool and skill files that no variation uses, and every watch says
that it creates a resource from a file with upsert when the file is
saved.

A test walks every sync command and checks its exact flags, and checks
that no LD_* variable or configuration value sets a sync flag. The
analytics event of sync gets a scope property, because the command name
is add for every kind.
@cursor
cursor Bot force-pushed the ctawiah/scope-commands-1e8a branch from c152ad6 to 210aacc Compare October 23, 2026 21:17
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