From b3ef7f2640c41671ab5f988354105cf9ccb69897 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 20:57:04 +0000 Subject: [PATCH 1/5] feat: tell agents to confirm destructive commands Add agent help to each command that removes something, so that an agent asks the user before it runs the command. Add agent help to `push` and `pull`, so that an agent uses `--force` only when the user asks for it. These rules were in the Prismic skill before. Humans do not see this text. The shared AGENTS text does not change. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01L1dGD553PK5SyWPuV2R36u --- src/commands/field-remove.ts | 4 ++++ src/commands/locale-remove.ts | 4 ++++ src/commands/logout.ts | 4 ++++ src/commands/preview-remove.ts | 4 ++++ src/commands/pull.ts | 4 ++++ src/commands/push.ts | 4 ++++ src/commands/slice-disconnect.ts | 4 ++++ src/commands/slice-remove-variation.ts | 4 ++++ src/commands/slice-remove.ts | 4 ++++ src/commands/sync.ts | 4 ++++ src/commands/token-delete.ts | 4 ++++ src/commands/type-remove-tab.ts | 4 ++++ src/commands/type-remove.ts | 4 ++++ src/commands/webhook-remove.ts | 4 ++++ test/pull.test.ts | 17 +++++++++++++++++ test/push.test.ts | 13 +++++++++++++ test/slice-remove.test.ts | 15 +++++++++++++++ test/token-delete.test.ts | 15 +++++++++++++++ 18 files changed, 116 insertions(+) diff --git a/src/commands/field-remove.ts b/src/commands/field-remove.ts index b9443395..a4e8e115 100644 --- a/src/commands/field-remove.ts +++ b/src/commands/field-remove.ts @@ -4,6 +4,10 @@ import { createCommand, type CommandConfig } from "../lib/command"; const config = { name: "prismic field remove", description: "Remove a field from a slice or custom type.", + agents: ` + This command removes a field and its settings from a slice or custom type. + Ask the user before you run it. + `, positionals: { id: { description: "Field ID", required: true }, }, diff --git a/src/commands/locale-remove.ts b/src/commands/locale-remove.ts index d22e3489..c71a2763 100644 --- a/src/commands/locale-remove.ts +++ b/src/commands/locale-remove.ts @@ -11,6 +11,10 @@ const config = { By default, this command reads the repository from prismic.config.json at the project root. `, + agents: ` + This command removes a locale from the Prismic repository. Ask the user + before you run it. + `, positionals: { code: { description: "Locale code (e.g. en-us, fr-fr)", required: true }, }, diff --git a/src/commands/logout.ts b/src/commands/logout.ts index a92f21a5..25767044 100644 --- a/src/commands/logout.ts +++ b/src/commands/logout.ts @@ -12,6 +12,10 @@ import { forgetTrackedUser, recordLogout } from "../tracking"; const config = { name: "prismic logout", description: "Log out of Prismic.", + agents: ` + This command logs the user out and revokes their session. Ask the user + before you run it. + `, } satisfies CommandConfig; export default createCommand(config, async () => { diff --git a/src/commands/preview-remove.ts b/src/commands/preview-remove.ts index 5e4bc232..655d0031 100644 --- a/src/commands/preview-remove.ts +++ b/src/commands/preview-remove.ts @@ -11,6 +11,10 @@ const config = { By default, this command reads the repository from prismic.config.json at the project root. `, + agents: ` + This command removes a preview configuration from the Prismic repository. + Ask the user before you run it. + `, positionals: { url: { description: "Preview URL to remove", required: true }, }, diff --git a/src/commands/pull.ts b/src/commands/pull.ts index 62c25ccd..9bf75638 100644 --- a/src/commands/pull.ts +++ b/src/commands/pull.ts @@ -17,6 +17,10 @@ const config = { Run \`prismic docs view cli#pull-models-from-prismic\` for details. `, + agents: ` + Use --force only when the user asks for it. It discards uncommitted + local model changes. + `, options: { force: { type: "boolean", diff --git a/src/commands/push.ts b/src/commands/push.ts index ef572a2c..f428fe39 100644 --- a/src/commands/push.ts +++ b/src/commands/push.ts @@ -27,6 +27,10 @@ const config = { Run \`prismic docs view cli#push-models-to-prismic\` for details. `, + agents: ` + Use --force only when the user asks for it. It lets push delete remote + models and skips the git check. + `, options: { force: { type: "boolean", diff --git a/src/commands/slice-disconnect.ts b/src/commands/slice-disconnect.ts index d5ba931c..322519e7 100644 --- a/src/commands/slice-disconnect.ts +++ b/src/commands/slice-disconnect.ts @@ -6,6 +6,10 @@ import { CommandError, createCommand, type CommandConfig } from "../lib/command" const config = { name: "prismic slice disconnect", description: "Disconnect a slice from a type's slice zone.", + agents: ` + This command removes a slice from a type's slice zone. Ask the user before + you run it. + `, positionals: { id: { description: "ID of the slice", required: true }, }, diff --git a/src/commands/slice-remove-variation.ts b/src/commands/slice-remove-variation.ts index 78d2f864..372a31e8 100644 --- a/src/commands/slice-remove-variation.ts +++ b/src/commands/slice-remove-variation.ts @@ -4,6 +4,10 @@ import { CommandError, createCommand, type CommandConfig } from "../lib/command" const config = { name: "prismic slice remove-variation", description: "Remove a variation from a slice.", + agents: ` + This command removes a variation from a slice. Ask the user before you run + it. + `, positionals: { id: { description: "ID of the variation", required: true }, }, diff --git a/src/commands/slice-remove.ts b/src/commands/slice-remove.ts index d0b3018d..839c457f 100644 --- a/src/commands/slice-remove.ts +++ b/src/commands/slice-remove.ts @@ -4,6 +4,10 @@ import { createCommand, type CommandConfig } from "../lib/command"; const config = { name: "prismic slice remove", description: "Remove a slice.", + agents: ` + This command deletes the slice's folder, including its component. Ask the + user before you run it. + `, positionals: { id: { description: "ID of the slice", required: true }, }, diff --git a/src/commands/sync.ts b/src/commands/sync.ts index 83477a4c..fc2294a3 100644 --- a/src/commands/sync.ts +++ b/src/commands/sync.ts @@ -21,6 +21,10 @@ const config = { For one-time pulls, use \`prismic pull\`. `, + agents: ` + This command overwrites and deletes local model files to match Prismic, with + no git check. Ask the user before you run it. + `, options: { watch: { type: "boolean", diff --git a/src/commands/token-delete.ts b/src/commands/token-delete.ts index bd50a1d3..d771d99e 100644 --- a/src/commands/token-delete.ts +++ b/src/commands/token-delete.ts @@ -16,6 +16,10 @@ const config = { By default, this command reads the repository from prismic.config.json at the project root. `, + agents: ` + This command deletes a token, and anything that uses it loses access. Ask + the user before you run it. + `, positionals: { token: { description: "Token value", required: true }, }, diff --git a/src/commands/type-remove-tab.ts b/src/commands/type-remove-tab.ts index ca5eb224..bd32c678 100644 --- a/src/commands/type-remove-tab.ts +++ b/src/commands/type-remove-tab.ts @@ -4,6 +4,10 @@ import { CommandError, createCommand, type CommandConfig } from "../lib/command" const config = { name: "prismic type remove-tab", description: "Remove a tab from a content type.", + agents: ` + This command removes a tab and all its fields from a content type. Ask the + user before you run it. + `, positionals: { name: { description: "Name of the tab", required: true }, }, diff --git a/src/commands/type-remove.ts b/src/commands/type-remove.ts index 0bf81800..e40dc65a 100644 --- a/src/commands/type-remove.ts +++ b/src/commands/type-remove.ts @@ -4,6 +4,10 @@ import { createCommand, type CommandConfig } from "../lib/command"; const config = { name: "prismic type remove", description: "Remove a content type.", + agents: ` + This command deletes the content type's folder and its route. Ask the user + before you run it. + `, positionals: { id: { description: "ID of the content type", required: true }, }, diff --git a/src/commands/webhook-remove.ts b/src/commands/webhook-remove.ts index cbc5ac6d..807b4f68 100644 --- a/src/commands/webhook-remove.ts +++ b/src/commands/webhook-remove.ts @@ -11,6 +11,10 @@ const config = { By default, this command reads the repository from prismic.config.json at the project root. `, + agents: ` + This command deletes a webhook from the Prismic repository. Ask the user + before you run it. + `, positionals: { url: { description: "Webhook URL", required: true }, }, diff --git a/test/pull.test.ts b/test/pull.test.ts index a6285659..449b4e52 100644 --- a/test/pull.test.ts +++ b/test/pull.test.ts @@ -32,6 +32,23 @@ it("supports --help", { concurrent: false }, async ({ expect, prismic }) => { expect(stdout).toContain("prismic docs view cli#pull-models-from-prismic"); }); +it( + "shows the AGENTS text in help only when an agent is detected", + { concurrent: false }, + async ({ expect, prismic }) => { + const agentHelp = ( + await prismic("pull", ["--help"], { nodeOptions: { env: { AI_AGENT: "test-agent" } } }) + ).stdout; + const humanHelp = (await prismic("pull", ["--help"])).stdout; + expect(agentHelp).toContain("Use --force only when the user asks for it."); + expect(agentHelp.indexOf("Use --force only when the user asks for it.")).toBeLessThan( + agentHelp.indexOf("USAGE"), + ); + expect(humanHelp).not.toContain("AGENTS"); + expect(humanHelp).not.toContain("Use --force only when the user asks for it."); + }, +); + it( "pulls slices and custom types from remote", { concurrent: false }, diff --git a/test/push.test.ts b/test/push.test.ts index 7ff93bbd..81ab1801 100644 --- a/test/push.test.ts +++ b/test/push.test.ts @@ -19,6 +19,19 @@ it("supports --help", async ({ expect, prismic }) => { expect(stdout).toContain("prismic docs view cli#push-models-to-prismic"); }); +it("shows the AGENTS text in help only when an agent is detected", async ({ expect, prismic }) => { + const agentHelp = ( + await prismic("push", ["--help"], { nodeOptions: { env: { AI_AGENT: "test-agent" } } }) + ).stdout; + const humanHelp = (await prismic("push", ["--help"])).stdout; + expect(agentHelp).toContain("Use --force only when the user asks for it."); + expect(agentHelp.indexOf("Use --force only when the user asks for it.")).toBeLessThan( + agentHelp.indexOf("USAGE"), + ); + expect(humanHelp).not.toContain("AGENTS"); + expect(humanHelp).not.toContain("Use --force only when the user asks for it."); +}); + describe("with an isolated repository", () => { it.scoped({ isolateRepo: true }); diff --git a/test/slice-remove.test.ts b/test/slice-remove.test.ts index 95b80811..21e9090c 100644 --- a/test/slice-remove.test.ts +++ b/test/slice-remove.test.ts @@ -6,6 +6,21 @@ it("supports --help", async ({ expect, prismic }) => { expect(stdout).toContain("prismic slice remove [options]"); }); +it("shows the AGENTS text in help only when an agent is detected", async ({ expect, prismic }) => { + const agentHelp = ( + await prismic("slice", ["remove", "--help"], { + nodeOptions: { env: { AI_AGENT: "test-agent" } }, + }) + ).stdout; + const humanHelp = (await prismic("slice", ["remove", "--help"])).stdout; + expect(agentHelp).toContain("This command deletes the slice's folder"); + expect(agentHelp.indexOf("This command deletes the slice's folder")).toBeLessThan( + agentHelp.indexOf("USAGE"), + ); + expect(humanHelp).not.toContain("AGENTS"); + expect(humanHelp).not.toContain("This command deletes the slice's folder"); +}); + it("removes a slice", async ({ expect, prismic, project }) => { const slice = buildSlice(); await writeLocalSlice(project, slice); diff --git a/test/token-delete.test.ts b/test/token-delete.test.ts index 7134a3d7..2e3cda0a 100644 --- a/test/token-delete.test.ts +++ b/test/token-delete.test.ts @@ -7,6 +7,21 @@ it("supports --help", async ({ expect, prismic }) => { expect(stdout).toContain("prismic token delete [options]"); }); +it("shows the AGENTS text in help only when an agent is detected", async ({ expect, prismic }) => { + const agentHelp = ( + await prismic("token", ["delete", "--help"], { + nodeOptions: { env: { AI_AGENT: "test-agent" } }, + }) + ).stdout; + const humanHelp = (await prismic("token", ["delete", "--help"])).stdout; + expect(agentHelp).toContain("This command deletes a token"); + expect(agentHelp.indexOf("This command deletes a token")).toBeLessThan( + agentHelp.indexOf("USAGE"), + ); + expect(humanHelp).not.toContain("AGENTS"); + expect(humanHelp).not.toContain("This command deletes a token"); +}); + it("deletes an access token", async ({ expect, prismic, repo, token, host }) => { const created = await createAccessToken({ repo, token, host }); From 1cfd05d00bac7caae8d91a92955c69378661fe05 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 21:04:51 +0000 Subject: [PATCH 2/5] feat: ask before destructive commands unless the user asked to force them Change the agent help of the 12 removal commands. Agents must now ask before they run the command, also when the user asked for the removal. They can skip the question only when the user asked to force it. Update the slice remove and token delete help tests to check the new sentence. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01L1dGD553PK5SyWPuV2R36u --- src/commands/field-remove.ts | 2 +- src/commands/locale-remove.ts | 4 ++-- src/commands/logout.ts | 4 ++-- src/commands/preview-remove.ts | 2 +- src/commands/slice-disconnect.ts | 4 ++-- src/commands/slice-remove-variation.ts | 4 ++-- src/commands/slice-remove.ts | 4 ++-- src/commands/sync.ts | 2 +- src/commands/token-delete.ts | 4 ++-- src/commands/type-remove-tab.ts | 4 ++-- src/commands/type-remove.ts | 4 ++-- src/commands/webhook-remove.ts | 4 ++-- test/slice-remove.test.ts | 6 +++--- test/token-delete.test.ts | 6 +++--- 14 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/commands/field-remove.ts b/src/commands/field-remove.ts index a4e8e115..c1d3573c 100644 --- a/src/commands/field-remove.ts +++ b/src/commands/field-remove.ts @@ -6,7 +6,7 @@ const config = { description: "Remove a field from a slice or custom type.", agents: ` This command removes a field and its settings from a slice or custom type. - Ask the user before you run it. + Unless the user asked to force it, ask before you run it. `, positionals: { id: { description: "Field ID", required: true }, diff --git a/src/commands/locale-remove.ts b/src/commands/locale-remove.ts index c71a2763..c10928b2 100644 --- a/src/commands/locale-remove.ts +++ b/src/commands/locale-remove.ts @@ -12,8 +12,8 @@ const config = { project root. `, agents: ` - This command removes a locale from the Prismic repository. Ask the user - before you run it. + This command removes a locale from the Prismic repository. Unless the user + asked to force it, ask before you run it. `, positionals: { code: { description: "Locale code (e.g. en-us, fr-fr)", required: true }, diff --git a/src/commands/logout.ts b/src/commands/logout.ts index 25767044..f4d95754 100644 --- a/src/commands/logout.ts +++ b/src/commands/logout.ts @@ -13,8 +13,8 @@ const config = { name: "prismic logout", description: "Log out of Prismic.", agents: ` - This command logs the user out and revokes their session. Ask the user - before you run it. + This command logs the user out and revokes their session. Unless the user + asked to force it, ask before you run it. `, } satisfies CommandConfig; diff --git a/src/commands/preview-remove.ts b/src/commands/preview-remove.ts index 655d0031..0b27e815 100644 --- a/src/commands/preview-remove.ts +++ b/src/commands/preview-remove.ts @@ -13,7 +13,7 @@ const config = { `, agents: ` This command removes a preview configuration from the Prismic repository. - Ask the user before you run it. + Unless the user asked to force it, ask before you run it. `, positionals: { url: { description: "Preview URL to remove", required: true }, diff --git a/src/commands/slice-disconnect.ts b/src/commands/slice-disconnect.ts index 322519e7..5f44f95c 100644 --- a/src/commands/slice-disconnect.ts +++ b/src/commands/slice-disconnect.ts @@ -7,8 +7,8 @@ const config = { name: "prismic slice disconnect", description: "Disconnect a slice from a type's slice zone.", agents: ` - This command removes a slice from a type's slice zone. Ask the user before - you run it. + This command removes a slice from a type's slice zone. Unless the user asked + to force it, ask before you run it. `, positionals: { id: { description: "ID of the slice", required: true }, diff --git a/src/commands/slice-remove-variation.ts b/src/commands/slice-remove-variation.ts index 372a31e8..81e1f881 100644 --- a/src/commands/slice-remove-variation.ts +++ b/src/commands/slice-remove-variation.ts @@ -5,8 +5,8 @@ const config = { name: "prismic slice remove-variation", description: "Remove a variation from a slice.", agents: ` - This command removes a variation from a slice. Ask the user before you run - it. + This command removes a variation from a slice. Unless the user asked to force + it, ask before you run it. `, positionals: { id: { description: "ID of the variation", required: true }, diff --git a/src/commands/slice-remove.ts b/src/commands/slice-remove.ts index 839c457f..2690a920 100644 --- a/src/commands/slice-remove.ts +++ b/src/commands/slice-remove.ts @@ -5,8 +5,8 @@ const config = { name: "prismic slice remove", description: "Remove a slice.", agents: ` - This command deletes the slice's folder, including its component. Ask the - user before you run it. + This command deletes the slice's folder, including its component. Unless the + user asked to force it, ask before you run it. `, positionals: { id: { description: "ID of the slice", required: true }, diff --git a/src/commands/sync.ts b/src/commands/sync.ts index fc2294a3..5ee4954a 100644 --- a/src/commands/sync.ts +++ b/src/commands/sync.ts @@ -23,7 +23,7 @@ const config = { `, agents: ` This command overwrites and deletes local model files to match Prismic, with - no git check. Ask the user before you run it. + no git check. Unless the user asked to force it, ask before you run it. `, options: { watch: { diff --git a/src/commands/token-delete.ts b/src/commands/token-delete.ts index d771d99e..09c789e4 100644 --- a/src/commands/token-delete.ts +++ b/src/commands/token-delete.ts @@ -17,8 +17,8 @@ const config = { project root. `, agents: ` - This command deletes a token, and anything that uses it loses access. Ask - the user before you run it. + This command deletes a token, and anything that uses it loses access. Unless + the user asked to force it, ask before you run it. `, positionals: { token: { description: "Token value", required: true }, diff --git a/src/commands/type-remove-tab.ts b/src/commands/type-remove-tab.ts index bd32c678..3670c984 100644 --- a/src/commands/type-remove-tab.ts +++ b/src/commands/type-remove-tab.ts @@ -5,8 +5,8 @@ const config = { name: "prismic type remove-tab", description: "Remove a tab from a content type.", agents: ` - This command removes a tab and all its fields from a content type. Ask the - user before you run it. + This command removes a tab and all its fields from a content type. Unless the + user asked to force it, ask before you run it. `, positionals: { name: { description: "Name of the tab", required: true }, diff --git a/src/commands/type-remove.ts b/src/commands/type-remove.ts index e40dc65a..bf739913 100644 --- a/src/commands/type-remove.ts +++ b/src/commands/type-remove.ts @@ -5,8 +5,8 @@ const config = { name: "prismic type remove", description: "Remove a content type.", agents: ` - This command deletes the content type's folder and its route. Ask the user - before you run it. + This command deletes the content type's folder and its route. Unless the user + asked to force it, ask before you run it. `, positionals: { id: { description: "ID of the content type", required: true }, diff --git a/src/commands/webhook-remove.ts b/src/commands/webhook-remove.ts index 807b4f68..f7e245e1 100644 --- a/src/commands/webhook-remove.ts +++ b/src/commands/webhook-remove.ts @@ -12,8 +12,8 @@ const config = { project root. `, agents: ` - This command deletes a webhook from the Prismic repository. Ask the user - before you run it. + This command deletes a webhook from the Prismic repository. Unless the user + asked to force it, ask before you run it. `, positionals: { url: { description: "Webhook URL", required: true }, diff --git a/test/slice-remove.test.ts b/test/slice-remove.test.ts index 21e9090c..0fa8575d 100644 --- a/test/slice-remove.test.ts +++ b/test/slice-remove.test.ts @@ -13,12 +13,12 @@ it("shows the AGENTS text in help only when an agent is detected", async ({ expe }) ).stdout; const humanHelp = (await prismic("slice", ["remove", "--help"])).stdout; - expect(agentHelp).toContain("This command deletes the slice's folder"); - expect(agentHelp.indexOf("This command deletes the slice's folder")).toBeLessThan( + expect(agentHelp).toContain("asked to force it, ask before you run it."); + expect(agentHelp.indexOf("asked to force it, ask before you run it.")).toBeLessThan( agentHelp.indexOf("USAGE"), ); expect(humanHelp).not.toContain("AGENTS"); - expect(humanHelp).not.toContain("This command deletes the slice's folder"); + expect(humanHelp).not.toContain("asked to force it, ask before you run it."); }); it("removes a slice", async ({ expect, prismic, project }) => { diff --git a/test/token-delete.test.ts b/test/token-delete.test.ts index 2e3cda0a..23482f57 100644 --- a/test/token-delete.test.ts +++ b/test/token-delete.test.ts @@ -14,12 +14,12 @@ it("shows the AGENTS text in help only when an agent is detected", async ({ expe }) ).stdout; const humanHelp = (await prismic("token", ["delete", "--help"])).stdout; - expect(agentHelp).toContain("This command deletes a token"); - expect(agentHelp.indexOf("This command deletes a token")).toBeLessThan( + expect(agentHelp).toContain("asked to force it, ask before you run it."); + expect(agentHelp.indexOf("asked to force it, ask before you run it.")).toBeLessThan( agentHelp.indexOf("USAGE"), ); expect(humanHelp).not.toContain("AGENTS"); - expect(humanHelp).not.toContain("This command deletes a token"); + expect(humanHelp).not.toContain("asked to force it, ask before you run it."); }); it("deletes an access token", async ({ expect, prismic, repo, token, host }) => { From 172fcd4405e99697184457ad8a65609c7bf3d793 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 21:05:18 +0000 Subject: [PATCH 3/5] test: check only each command's own agent help text The shared AGENTS behavior is already tested in index and init tests: the section shows only for agents, before USAGE. The new tests now only check the text that each command adds. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01L1dGD553PK5SyWPuV2R36u --- test/pull.test.ts | 15 ++++----------- test/push.test.ts | 15 ++++----------- test/slice-remove.test.ts | 17 ++++------------- test/token-delete.test.ts | 17 ++++------------- 4 files changed, 16 insertions(+), 48 deletions(-) diff --git a/test/pull.test.ts b/test/pull.test.ts index 449b4e52..87dbb13c 100644 --- a/test/pull.test.ts +++ b/test/pull.test.ts @@ -33,19 +33,12 @@ it("supports --help", { concurrent: false }, async ({ expect, prismic }) => { }); it( - "shows the AGENTS text in help only when an agent is detected", + "tells agents to use --force only when the user asks", { concurrent: false }, async ({ expect, prismic }) => { - const agentHelp = ( - await prismic("pull", ["--help"], { nodeOptions: { env: { AI_AGENT: "test-agent" } } }) - ).stdout; - const humanHelp = (await prismic("pull", ["--help"])).stdout; - expect(agentHelp).toContain("Use --force only when the user asks for it."); - expect(agentHelp.indexOf("Use --force only when the user asks for it.")).toBeLessThan( - agentHelp.indexOf("USAGE"), - ); - expect(humanHelp).not.toContain("AGENTS"); - expect(humanHelp).not.toContain("Use --force only when the user asks for it."); + const agent = { nodeOptions: { env: { AI_AGENT: "test-agent" } } }; + const { stdout } = await prismic("pull", ["--help"], agent); + expect(stdout).toContain("Use --force only when the user asks for it."); }, ); diff --git a/test/push.test.ts b/test/push.test.ts index 81ab1801..d83bac1a 100644 --- a/test/push.test.ts +++ b/test/push.test.ts @@ -19,17 +19,10 @@ it("supports --help", async ({ expect, prismic }) => { expect(stdout).toContain("prismic docs view cli#push-models-to-prismic"); }); -it("shows the AGENTS text in help only when an agent is detected", async ({ expect, prismic }) => { - const agentHelp = ( - await prismic("push", ["--help"], { nodeOptions: { env: { AI_AGENT: "test-agent" } } }) - ).stdout; - const humanHelp = (await prismic("push", ["--help"])).stdout; - expect(agentHelp).toContain("Use --force only when the user asks for it."); - expect(agentHelp.indexOf("Use --force only when the user asks for it.")).toBeLessThan( - agentHelp.indexOf("USAGE"), - ); - expect(humanHelp).not.toContain("AGENTS"); - expect(humanHelp).not.toContain("Use --force only when the user asks for it."); +it("tells agents to use --force only when the user asks", async ({ expect, prismic }) => { + const agent = { nodeOptions: { env: { AI_AGENT: "test-agent" } } }; + const { stdout } = await prismic("push", ["--help"], agent); + expect(stdout).toContain("Use --force only when the user asks for it."); }); describe("with an isolated repository", () => { diff --git a/test/slice-remove.test.ts b/test/slice-remove.test.ts index 0fa8575d..c932713b 100644 --- a/test/slice-remove.test.ts +++ b/test/slice-remove.test.ts @@ -6,19 +6,10 @@ it("supports --help", async ({ expect, prismic }) => { expect(stdout).toContain("prismic slice remove [options]"); }); -it("shows the AGENTS text in help only when an agent is detected", async ({ expect, prismic }) => { - const agentHelp = ( - await prismic("slice", ["remove", "--help"], { - nodeOptions: { env: { AI_AGENT: "test-agent" } }, - }) - ).stdout; - const humanHelp = (await prismic("slice", ["remove", "--help"])).stdout; - expect(agentHelp).toContain("asked to force it, ask before you run it."); - expect(agentHelp.indexOf("asked to force it, ask before you run it.")).toBeLessThan( - agentHelp.indexOf("USAGE"), - ); - expect(humanHelp).not.toContain("AGENTS"); - expect(humanHelp).not.toContain("asked to force it, ask before you run it."); +it("tells agents to ask before removing", async ({ expect, prismic }) => { + const agent = { nodeOptions: { env: { AI_AGENT: "test-agent" } } }; + const { stdout } = await prismic("slice", ["remove", "--help"], agent); + expect(stdout).toContain("asked to force it, ask before you run it."); }); it("removes a slice", async ({ expect, prismic, project }) => { diff --git a/test/token-delete.test.ts b/test/token-delete.test.ts index 23482f57..59adee05 100644 --- a/test/token-delete.test.ts +++ b/test/token-delete.test.ts @@ -7,19 +7,10 @@ it("supports --help", async ({ expect, prismic }) => { expect(stdout).toContain("prismic token delete [options]"); }); -it("shows the AGENTS text in help only when an agent is detected", async ({ expect, prismic }) => { - const agentHelp = ( - await prismic("token", ["delete", "--help"], { - nodeOptions: { env: { AI_AGENT: "test-agent" } }, - }) - ).stdout; - const humanHelp = (await prismic("token", ["delete", "--help"])).stdout; - expect(agentHelp).toContain("asked to force it, ask before you run it."); - expect(agentHelp.indexOf("asked to force it, ask before you run it.")).toBeLessThan( - agentHelp.indexOf("USAGE"), - ); - expect(humanHelp).not.toContain("AGENTS"); - expect(humanHelp).not.toContain("asked to force it, ask before you run it."); +it("tells agents to ask before deleting", async ({ expect, prismic }) => { + const agent = { nodeOptions: { env: { AI_AGENT: "test-agent" } } }; + const { stdout } = await prismic("token", ["delete", "--help"], agent); + expect(stdout).toContain("asked to force it, ask before you run it."); }); it("deletes an access token", async ({ expect, prismic, repo, token, host }) => { From 09fb654baad1857e2f70b40606444cac1a072a37 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 21:29:17 +0000 Subject: [PATCH 4/5] fix: do not ask agents to confirm logout Logout is not destructive. A user who wants to log out can log out. Remove the agent help text that told agents to ask first. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01L1dGD553PK5SyWPuV2R36u --- src/commands/logout.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/commands/logout.ts b/src/commands/logout.ts index f4d95754..a92f21a5 100644 --- a/src/commands/logout.ts +++ b/src/commands/logout.ts @@ -12,10 +12,6 @@ import { forgetTrackedUser, recordLogout } from "../tracking"; const config = { name: "prismic logout", description: "Log out of Prismic.", - agents: ` - This command logs the user out and revokes their session. Unless the user - asked to force it, ask before you run it. - `, } satisfies CommandConfig; export default createCommand(config, async () => { From 3ebb56251da9b7fe0466c279592507fe3df62a63 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 21:42:26 +0000 Subject: [PATCH 5/5] fix: limit agent guidance to commands with a --force option Remove the agent help text from the removal commands and from sync. These commands have no --force option, and they can remove things without extra guidance. Keep the text on push and pull, which have a --force option. Remove the tests of the removed text. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01L1dGD553PK5SyWPuV2R36u --- src/commands/field-remove.ts | 4 ---- src/commands/locale-remove.ts | 4 ---- src/commands/preview-remove.ts | 4 ---- src/commands/slice-disconnect.ts | 4 ---- src/commands/slice-remove-variation.ts | 4 ---- src/commands/slice-remove.ts | 4 ---- src/commands/sync.ts | 4 ---- src/commands/token-delete.ts | 4 ---- src/commands/type-remove-tab.ts | 4 ---- src/commands/type-remove.ts | 4 ---- src/commands/webhook-remove.ts | 4 ---- test/slice-remove.test.ts | 6 ------ test/token-delete.test.ts | 6 ------ 13 files changed, 56 deletions(-) diff --git a/src/commands/field-remove.ts b/src/commands/field-remove.ts index c1d3573c..b9443395 100644 --- a/src/commands/field-remove.ts +++ b/src/commands/field-remove.ts @@ -4,10 +4,6 @@ import { createCommand, type CommandConfig } from "../lib/command"; const config = { name: "prismic field remove", description: "Remove a field from a slice or custom type.", - agents: ` - This command removes a field and its settings from a slice or custom type. - Unless the user asked to force it, ask before you run it. - `, positionals: { id: { description: "Field ID", required: true }, }, diff --git a/src/commands/locale-remove.ts b/src/commands/locale-remove.ts index c10928b2..d22e3489 100644 --- a/src/commands/locale-remove.ts +++ b/src/commands/locale-remove.ts @@ -11,10 +11,6 @@ const config = { By default, this command reads the repository from prismic.config.json at the project root. `, - agents: ` - This command removes a locale from the Prismic repository. Unless the user - asked to force it, ask before you run it. - `, positionals: { code: { description: "Locale code (e.g. en-us, fr-fr)", required: true }, }, diff --git a/src/commands/preview-remove.ts b/src/commands/preview-remove.ts index 0b27e815..5e4bc232 100644 --- a/src/commands/preview-remove.ts +++ b/src/commands/preview-remove.ts @@ -11,10 +11,6 @@ const config = { By default, this command reads the repository from prismic.config.json at the project root. `, - agents: ` - This command removes a preview configuration from the Prismic repository. - Unless the user asked to force it, ask before you run it. - `, positionals: { url: { description: "Preview URL to remove", required: true }, }, diff --git a/src/commands/slice-disconnect.ts b/src/commands/slice-disconnect.ts index 5f44f95c..d5ba931c 100644 --- a/src/commands/slice-disconnect.ts +++ b/src/commands/slice-disconnect.ts @@ -6,10 +6,6 @@ import { CommandError, createCommand, type CommandConfig } from "../lib/command" const config = { name: "prismic slice disconnect", description: "Disconnect a slice from a type's slice zone.", - agents: ` - This command removes a slice from a type's slice zone. Unless the user asked - to force it, ask before you run it. - `, positionals: { id: { description: "ID of the slice", required: true }, }, diff --git a/src/commands/slice-remove-variation.ts b/src/commands/slice-remove-variation.ts index 81e1f881..78d2f864 100644 --- a/src/commands/slice-remove-variation.ts +++ b/src/commands/slice-remove-variation.ts @@ -4,10 +4,6 @@ import { CommandError, createCommand, type CommandConfig } from "../lib/command" const config = { name: "prismic slice remove-variation", description: "Remove a variation from a slice.", - agents: ` - This command removes a variation from a slice. Unless the user asked to force - it, ask before you run it. - `, positionals: { id: { description: "ID of the variation", required: true }, }, diff --git a/src/commands/slice-remove.ts b/src/commands/slice-remove.ts index 2690a920..d0b3018d 100644 --- a/src/commands/slice-remove.ts +++ b/src/commands/slice-remove.ts @@ -4,10 +4,6 @@ import { createCommand, type CommandConfig } from "../lib/command"; const config = { name: "prismic slice remove", description: "Remove a slice.", - agents: ` - This command deletes the slice's folder, including its component. Unless the - user asked to force it, ask before you run it. - `, positionals: { id: { description: "ID of the slice", required: true }, }, diff --git a/src/commands/sync.ts b/src/commands/sync.ts index 5ee4954a..83477a4c 100644 --- a/src/commands/sync.ts +++ b/src/commands/sync.ts @@ -21,10 +21,6 @@ const config = { For one-time pulls, use \`prismic pull\`. `, - agents: ` - This command overwrites and deletes local model files to match Prismic, with - no git check. Unless the user asked to force it, ask before you run it. - `, options: { watch: { type: "boolean", diff --git a/src/commands/token-delete.ts b/src/commands/token-delete.ts index 09c789e4..bd50a1d3 100644 --- a/src/commands/token-delete.ts +++ b/src/commands/token-delete.ts @@ -16,10 +16,6 @@ const config = { By default, this command reads the repository from prismic.config.json at the project root. `, - agents: ` - This command deletes a token, and anything that uses it loses access. Unless - the user asked to force it, ask before you run it. - `, positionals: { token: { description: "Token value", required: true }, }, diff --git a/src/commands/type-remove-tab.ts b/src/commands/type-remove-tab.ts index 3670c984..ca5eb224 100644 --- a/src/commands/type-remove-tab.ts +++ b/src/commands/type-remove-tab.ts @@ -4,10 +4,6 @@ import { CommandError, createCommand, type CommandConfig } from "../lib/command" const config = { name: "prismic type remove-tab", description: "Remove a tab from a content type.", - agents: ` - This command removes a tab and all its fields from a content type. Unless the - user asked to force it, ask before you run it. - `, positionals: { name: { description: "Name of the tab", required: true }, }, diff --git a/src/commands/type-remove.ts b/src/commands/type-remove.ts index bf739913..0bf81800 100644 --- a/src/commands/type-remove.ts +++ b/src/commands/type-remove.ts @@ -4,10 +4,6 @@ import { createCommand, type CommandConfig } from "../lib/command"; const config = { name: "prismic type remove", description: "Remove a content type.", - agents: ` - This command deletes the content type's folder and its route. Unless the user - asked to force it, ask before you run it. - `, positionals: { id: { description: "ID of the content type", required: true }, }, diff --git a/src/commands/webhook-remove.ts b/src/commands/webhook-remove.ts index f7e245e1..cbc5ac6d 100644 --- a/src/commands/webhook-remove.ts +++ b/src/commands/webhook-remove.ts @@ -11,10 +11,6 @@ const config = { By default, this command reads the repository from prismic.config.json at the project root. `, - agents: ` - This command deletes a webhook from the Prismic repository. Unless the user - asked to force it, ask before you run it. - `, positionals: { url: { description: "Webhook URL", required: true }, }, diff --git a/test/slice-remove.test.ts b/test/slice-remove.test.ts index c932713b..95b80811 100644 --- a/test/slice-remove.test.ts +++ b/test/slice-remove.test.ts @@ -6,12 +6,6 @@ it("supports --help", async ({ expect, prismic }) => { expect(stdout).toContain("prismic slice remove [options]"); }); -it("tells agents to ask before removing", async ({ expect, prismic }) => { - const agent = { nodeOptions: { env: { AI_AGENT: "test-agent" } } }; - const { stdout } = await prismic("slice", ["remove", "--help"], agent); - expect(stdout).toContain("asked to force it, ask before you run it."); -}); - it("removes a slice", async ({ expect, prismic, project }) => { const slice = buildSlice(); await writeLocalSlice(project, slice); diff --git a/test/token-delete.test.ts b/test/token-delete.test.ts index 59adee05..7134a3d7 100644 --- a/test/token-delete.test.ts +++ b/test/token-delete.test.ts @@ -7,12 +7,6 @@ it("supports --help", async ({ expect, prismic }) => { expect(stdout).toContain("prismic token delete [options]"); }); -it("tells agents to ask before deleting", async ({ expect, prismic }) => { - const agent = { nodeOptions: { env: { AI_AGENT: "test-agent" } } }; - const { stdout } = await prismic("token", ["delete", "--help"], agent); - expect(stdout).toContain("asked to force it, ask before you run it."); -}); - it("deletes an access token", async ({ expect, prismic, repo, token, host }) => { const created = await createAccessToken({ repo, token, host });