Add global instructions config for the Studio Code agent - #4255
Merged
Conversation
youknowriad
force-pushed
the
claude/studio-agent-instructions-3d40ed
branch
from
July 21, 2026 12:56
272da85 to
c4d2f99
Compare
Collaborator
📊 Performance Test ResultsComparing a6b2cff vs trunk app-size
site-editor
site-startup
Results are median values from multiple test runs. Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff) |
youknowriad
force-pushed
the
claude/studio-agent-instructions-3d40ed
branch
from
July 22, 2026 09:15
c4d2f99 to
f76382c
Compare
sejas
approved these changes
Jul 22, 2026
Member
There was a problem hiding this comment.
Works great and I like the idea of having global Instructions. This PR will close STU-1725
Some minor suggestions to consider:
- What if we call it AGENTS.md? I know it goes into the instructions, which will steer the agent even more, but it also accomplishes the same goal of customizing the agent.
- The save state is too fast 😆, and it feels uncertain if it worked or not. I suggest following the same pattern as other modals, we could delay the saving action to see the progress button and closing the modal after it finishes. A small success message could be a good alternative.
- Currently we truncate the instructions to USER_INSTRUCTIONS_MAX_LENGTH, but we don't notify about this limitation to the user in the Settings modal. I suggest adding limit to the text area or even a count character or an error message. I know users could edit the file directly, but the UI should set better expectations about the existing limit.
Otherwise LGTM. Thanks for adding this feature!
| Classic | Agentic |
|---|---|
![]() |
![]() |
Instructions file updated:
Instructions in action:
Saving doesn't communicate the success:
agent-sintructions.mp4
Comment on lines
+61
to
+67
| const instructions = | ||
| userInstructions.length > USER_INSTRUCTIONS_MAX_LENGTH | ||
| ? `${ userInstructions.slice( | ||
| 0, | ||
| USER_INSTRUCTIONS_MAX_LENGTH | ||
| ) }\n\n[Note: the global instructions file exceeds the size limit and was truncated here. Let the user know they should shorten it in Studio settings.]` | ||
| : userInstructions; |
Member
There was a problem hiding this comment.
We could consider adding a limit in the Settings text area or some kind of indicator.
…uctions.md) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…nstructions settings Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
youknowriad
force-pushed
the
claude/studio-agent-instructions-3d40ed
branch
from
July 22, 2026 12:38
9cedd19 to
a6b2cff
Compare
youknowriad
enabled auto-merge (squash)
July 22, 2026 13:05
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.


Why
A user asked me for the possibility to move his instructions/context from a conversation to another. I think what we really need ultimately is a wp.com user tied knowledge base, but there's a small thing we could provider users without building all of that, an instructions file config where users can provide global instructions injected in the Studio Code system prompt.
Related issues
How AI was used in this PR
Designed and implemented in a Claude Code session pair-driven by @youknowriad: exploration, implementation, tests, and the eval were AI-authored, with direction and design decisions (file location, remote-session inclusion, dedicated settings tab, local-UI support) made by the human. A four-angle AI cleanup review pass is being applied as a follow-up commit on this branch.
Proposed Changes
Users can now give the Studio Code agent standing, global instructions — preferences that apply to every conversation across all sites, e.g. "always answer in French" or "I prefer light background colors". Until now, such preferences had to be repeated in every session.
~/.studio/knowledge/instructions.md, editable in a new Studio Code settings tab in the classic desktop UI, the agentic UI, and thestudio uiweb UI (served through a small local-server API). Power users can edit the file directly; edits take effect on the next agent message.knowledge/directory is the deliberate seed of a future knowledge base: sibling markdown files with an injected index and on-demand retrieval can be added later without migrating anything.Testing Instructions
npm run cli:build && npm start, open Settings → Studio Code, save an easily observable instruction (e.g. "End every reply with the word BANANA"), start a new Studio Code conversation, and confirm the agent follows it.npm run build:local --workspace=apps/ui && npm run cli:build && node apps/cli/dist/cli/main.mjs ui→ Settings → Studio Code.node apps/cli/dist/cli/main.mjs ai "say hello"picks up the same file.npm test -- packages/common/ai/tests/global-instructions.test.ts apps/cli/ai/tests/system-prompt.test.ts, andnpm run eval -- --filter-pattern "global instructions"(requiresstudio auth login; passed locally).Pre-merge Checklist
🤖 Generated with Claude Code