[FEATURE] Project-level guardrails file automatically suffixed to every message
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
Claude Code needs a mechanism to automatically suffix project-level behavioural rules to every user message — not prefix, suffix — so the rules carry recency weight and take priority over the coding context that precedes them in the conversation.
Memory files are loaded once at session start and lose weight as the conversation grows. When a project has critical behavioural rules — such as "answer only, do not implement unless explicitly instructed" — those rules get diluted by conversation history and stop being reliably followed in long sessions.
The UserPromptSubmit hook exists but requires shell setup and produces a lower-priority system tag. It does not solve the recency problem.
Prefix vs Suffix matters: If the guardrail is prepended to the message, the coding context that follows it overrides it. If it is suffixed — appended at the end — it carries higher recency weight and the model treats it as the most current instruction, taking priority over earlier conversation history.
Proposed Solution
A project-level guardrails file (e.g. .claude/guardrails.md or a field in .claude/settings.json) whose contents are automatically suffixed to every user message throughout the session.
Example
Developer adds to .claude/guardrails.md:
RULE: When the user asks a question, answer only. Do not implement, edit files, commit, or push anything unless explicitly instructed in this message.
Every message the developer sends automatically becomes:
[developer's message]
RULE: When the user asks a question, answer only. Do not implement, edit files, commit, or push anything unless explicitly instructed in this message.
The suffix ensures the rule is the last thing Claude reads before responding — giving it maximum priority over the coding context.
Why Suffix Specifically
Recency bias means the model gives higher weight to content that appears later in the context. Behavioural rules suffixed to every message will consistently outweigh earlier conversation content. This is the only reliable way to enforce project-level behavioural guardrails in long coding sessions.
Alternative Solutions
None that is reliable without the user manually appending rules to every single message.
Priority
High - Significant impact on productivity
Feature Category
API and model interactions
Use Case Example
_No response_
Additional Context
_No response_
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗