Claude context
Every time you catch Claude making the same mistake twice, explain the same convention in chat, or
hand a teammate a mental map they did not have, that is knowledge worth encoding. This page covers
what belongs in a repository's .claude/ directory, where to put it, and how to land it alongside
the code it describes.
Audience: Bitwarden engineers adding or changing Claude context in any Bitwarden repository.
Decide where the knowledge belongs
Ask whether the knowledge is specific to one codebase or generic enough to work across repositories.
- If it is specific to one codebase, put it in that repository's
.claude/directory, for example how a new module is added or how the feature-flag system works. - If it applies across repositories, put it in bitwarden/ai-plugins, in the plugin that component placement points to.
When unsure, keep it in the repository. Promoting it to ai-plugins later is easier than pulling it
back; see the
ai-plugins contributing guide
when you are ready.
Choose a scope
Claude loads every CLAUDE.md and CLAUDE.local.md by
walking up from the working directory,
checking both CLAUDE.md and .claude/CLAUDE.md in each ancestor. Files below the working
directory, including nested .claude/skills/, load lazily when Claude reads into that subtree. Use
that hierarchy:
- Applies everywhere in the repository:
CLAUDE.mdor.claude/CLAUDE.mdat the repository root, or.claude/skills/. Several repositories use the.claude/location rather than a root file, so check which one your repository already has before adding another. - Applies only within one app, library, utility, or subtree: a nested
CLAUDE.mdor.claude/skills/in that directory.
Push rules as deep as they will go. Keeping app-specific rules local saves context for everyone else's sessions, not just yours.
For rules that apply only to certain file types, use
.claude/rules/<name>.md with a paths: frontmatter glob
instead of a nested CLAUDE.md.
Choose a shape
| You want to | Use |
|---|---|
| State a rule Claude must always follow in its scope | CLAUDE.md |
| State a rule that applies only to certain file globs | .claude/rules/<name>.md with paths: frontmatter |
| Teach a procedure Claude invokes on demand | .claude/skills/<name>/SKILL.md |
| Give Claude a specialized subagent with its own context | .claude/agents/<name>.md, with name and description required in the YAML frontmatter |
| Add a user-invocable slash command | .claude/commands/<name>.md |
| Trigger a shell script on a Claude Code event | .claude/hooks/<name>.sh, registered per developer in .claude/settings.local.json |
If Claude only needs it sometimes, it is a skill. Once a CLAUDE.md loads it stays in context for
the rest of the session, so keep each one lean, especially the root.
Claude Code registers hooks from the committed .claude/settings.json as well, but our convention
is to commit only the hook script and leave registration to each developer's gitignored
.claude/settings.local.json. A merged pull request should never start executing shell commands in
a teammate's session, so hooks stay opt-in.
Security conventions
Skills and agents that touch vault data, authentication, or cryptography must use Bitwarden's
core vocabulary (Vault Data, Protected Data, Secure
Channel, and so on) and restate the zero-knowledge invariant inline. Subagents run in a fresh
context and do not inherit a repository's CLAUDE.md, so include the relevant definitions directly
in the agent's system prompt.
What good contributions look like
- Grounded in the code. Real files, real patterns, real commands. If it could apply to any
repository, it belongs in
ai-plugins. - Describes the what and the why, not the who. Avoid team-persona framing. Describe the domain and its constraints; the team is an implementation detail.
- Short and specific. 2,000 words of general advice is not a skill.
- Active voice and direct language. "Invoke this skill when...", not "This skill may be invoked when...".
- Reviewed like code. Teams of domain experts own
.claude/in their areas, shaping how Claude behaves for everyone who works there, so treat changes with the same seriousness as source.
Anti-patterns
- Team-persona agents, such as "Team ABC engineer". If a team's process is unique enough to warrant a persona, that is an SDLC signal to address rather than a persona to encode.
- Root-level rules that only matter in one subtree. If a rule only ever applies to a single
subtree, it belongs in a nested
CLAUDE.mdnext to that subtree. - Duplicating
ai-pluginscontent. Check the existing plugin skills before writing a new one. - Generic advice disguised as repository-local knowledge. "Write good tests" is not repository-specific. "Our integration tests must hit a real database because..." is.
Build a contribution
The Claude Code ecosystem moves quickly, so last session's habits may already be out of date.
-
Refresh on the canonical documentation before you begin:
- How Claude Code works for the mental model.
- Best practices for Claude Code for what Anthropic recommends.
- Extend Claude Code for what you can build.
- The complete guide to building skills for Claude, essential reading before authoring a skill.
-
Survey the landscape. Skim the target repository's
.claude/tree and bitwarden/ai-plugins, then match the voice you find. Your contribution should read like its neighbors. -
Build iteratively. When authoring a skill, start with
skill-creatorfrom Anthropic's official plugin marketplace:/skill-creator:skill-creatorIt runs a draft, test, review, and refine loop with benchmark statistics and a side-by-side reviewer, so the skill has been exercised against concrete inputs before you open the pull request. For agents, commands, hooks, and
CLAUDE.mdentries, adapt an existing one in the repository rather than inventing a new structure. -
Validate before you push. Run a local Bitwarden Claude Code review, which writes findings to files so you can fix them before pushing without posting anything to GitHub:
/bitwarden-code-review:code-review-localA diff that touches
CLAUDE.md, a skill, an agent, a command, a hook, or.claude/settings picks up a Claude-configuration pass over frontmatter, structure, prompt quality, and config-specific security issues such as a committedsettings.local.jsonor an agent granted broader tool access than it needs. The automated review on your pull request always runs that pass; installclaude-config-validatorto get it locally too. -
Open the pull request with the
ai-reviewlabel. YouSHOULDleave the label on, especially as you push commits that are not merge commits. While it is on, Claude reviews the pull request on every push, drafts included. Without it, a non-draft pull request gets one automatic review and no more. AI Code Review explains when each review runs.