-
Notifications
You must be signed in to change notification settings - Fork 5
feat(prompts): let users save their own prompts to the library - #2056
Draft
manzke wants to merge 1 commit into
Draft
feat(prompts): let users save their own prompts to the library #2056manzke wants to merge 1 commit into
manzke wants to merge 1 commit into
Conversation
Adds user-owned prompts alongside the admin-curated library: any authenticated (non-anonymous) user can save a prompt as private or shared, edit/delete their own, and see others' shared prompts. - New GET/POST/PUT/DELETE /api/user-prompts, storing one JSON file per prompt under contents/data/user-prompts/<userId>/<promptId>.json, gated behind the existing promptsLibrary feature flag. - New "Save a new prompt" button + modal on the Prompts page; own/shared prompts merge into the existing grid with Mine/Shared badges and edit/delete for owned prompts. - Covers the data-model half of #1038 (owner, visibility, createdBy/ lastModifiedBy tracking). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KGoQpnovDaVSVSGA9fsiyX
@github-actions
github-actions
Bot
added
documentation
Improvements or additions to documentation
backend
api
i18n
frontend
testing
labels
Jul 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #1037 ("Support to save a prompt to the prompt library"). Also covers the data-model half of
#1038 (owner, visibility, createdBy/lastModifiedBy tracking) — see scoping note below.
Today
contents/prompts/*.jsonis exclusively an admin-curated resource. This adds a parallel,user-owned layer: any authenticated (non-anonymous) user can save their own prompt directly from
the Prompts page, mark it private (only them) or shared (every authenticated user), and
edit/delete their own prompts later.
Backend
server/utils/userPromptsStore.js— one JSON file per prompt undercontents/data/user-prompts/<userId>/<promptId>.json, separate from the admin-curated libraryand not subject to
contentAdminAuth.userId(an OIDC subject/local username/LDAP username/proxyheader value) is treated as untrusted input — validated against the same safe-filename allowlist
TokenStorageService.jsalready uses for its per-user token files, then re-checked to stay insideits parent directory before any fs call (mirrors that module's existing path-safety pattern).
server/validators/userPromptInputSchema.js— a small Zod schema for the create/updatepayload (name/description/prompt/category/visibility). Deliberately simpler than
promptConfigSchema.js: no localization, variables, or output schema for v1.server/routes/userPromptsRoutes.js—GET/POST/PUT/DELETE /api/user-prompts, gated behindauthenticatedOnly(rejects anonymous sessions) and the existingpromptsLibraryfeature flag(already default-on, so no migration needed).
GETreturns the caller's own prompts plus everyother user's
sharedprompts, each taggedmine: true|false. Ownership on update/delete isenforced by construction — the store only ever reads/writes inside the caller's own directory, so
a
promptIdbelonging to someone else's directory simply 404s.server/tests/userPromptsStore.test.js— Jest tests covering create/list/update/delete,private-vs-shared visibility, and rejection of path-traversal-shaped
userId/promptIdvalues.Frontend
client/src/features/prompts/components/UserPromptFormModal.jsx— create/edit form(name/description/prompt/visibility).
client/src/features/prompts/pages/PromptsList.jsx— new "Save a new prompt" button (hidden foranonymous sessions), own/shared user prompts merged into the existing grid with "Mine"/"Shared"
badges, and edit/delete controls on the user's own prompt cards.
client/src/api/endpoints/prompts.js—fetchUserPrompts/createUserPrompt/updateUserPrompt/deleteUserPrompt.en/detranslation strings underpages.promptsList.userPrompts.*andcommon.saving.Scoping notes (see
docs/prompts.mdfor the full write-up)simpler than admin-curated prompts for v1.
sharedprompts in this PR (an open question raised on Support to save a prompt to the prompt library #1037 'simplementation-plan comment) — flagging as a candidate follow-up, not blocking this slice.
authenticatedOnlyelsewhere in the codebase.Test plan
server/tests/userPromptsStore.test.js) — 8/8 passing, includingpath-traversal rejection for both
userIdandpromptId.npx eslinton all changed/new files — 0 errors (only pre-existing warnings elsewhere inPromptsList.jsxthat predate this change).npx prettier --check— clean.vite build) succeeds with no errors.node server/server.js, all 4 clusterworkers ready, migrations unaffected).
local admin per CLAUDE.md): create private → list → update to shared → delete → list empty
again. Also verified: anonymous
GET /api/user-prompts→ 401; a path-traversal-shapedpromptIdonDELETE→ 400; a request missingname/prompt→ 400.🤖 Generated with Claude Code
https://claude.ai/code/session_01KGoQpnovDaVSVSGA9fsiyX
Generated by Claude Code