Skip to content

Context and Prompts

NebulaRaven edited this page Aug 13, 2026 · 1 revision

Context and Prompts

简体中文 · Home

Prompt modes

GrayCode includes Code, Design, Plan, Ask, and Review. Each mode can define its system prompt, dynamic context, assembly method, and tool policy. Edit, copy, remove, or add modes under Settings → Prompts.

Assembly methods

Legacy templates

Legacy templates are simple and backward-compatible:

  • template is the stable system prompt.
  • dynamicTemplate is generated per request and is not stored in real chat history.

If you only need to change the assistant's role, tone, or default behavior, this is normally sufficient.

Prompt entries

Prompt entries provide precise control over system, user, and assistant content and the position of real chat history. Normal entries can be enabled, copied, and reordered. The Chat History entry marks where real history is inserted and is not sent as an ordinary message.

Placing strong constraints after history can reinforce them; keeping stable content before history can improve caching. More entries are not automatically better—avoid injecting the same rule more than once.

Dynamic context strategies

  • single sends only the newest dynamic context. It suits ordinary questions and short tasks and uses fewer tokens.
  • preserve retains context from earlier turns near its original position. It helps when a long task depends on what the assistant saw in each turn and may improve prefix caching such as Anthropic Prompt Caching or DeepSeek KVCache, at the cost of a longer context.

Use single by default. Choose preserve when each turn's file tree, open tabs, or diagnostics truly matter. Switch back or enable automatic summarization if the context grows too large.

Available context

Settings → Context controls which information can be generated:

  • Workspace file tree and maximum depth
  • Open tabs and active editor
  • VS Code diagnostics, severity, and limits
  • Pinned files and directories
  • Custom ignore patterns
  • Current TODOs, time, system, and workspace information

Settings determine whether content can be generated; variables in the active prompt determine whether it is included in a request.

Template variables

Variables use the {{$NAME}} form. Common static variables include:

  • {{$ENVIRONMENT}} for operating system, timezone, language, and workspace path.
  • {{$TOOLS}} for built-in tool instructions.
  • {{$MCP_TOOLS}} for connected MCP tools.
  • {{$MEMORY}} for persistent-memory guidance.
  • {{$CONTEXT_BADGE_FORMAT}} for input context-badge semantics.

Common dynamic variables include {{$TODO_LIST}}, {{$WORKSPACE_FILES}}, {{$OPEN_TABS}}, {{$ACTIVE_EDITOR}}, {{$DIAGNOSTICS}}, {{$PINNED_FILES}}, and {{$SKILLS}}.

If custom prompts behave incorrectly after an upgrade, restore the defaults first and reintroduce custom content incrementally.

Focus the current turn

Add files, folders, editor selections, attachments, pinned files, and Skill badges directly to the input. Explicitly providing the relevant scope is usually better than injecting the entire workspace: it saves tokens and produces answers that are easier to verify.

Clone this wiki locally