Skip to content

Commit b980be1

Browse files
theMicksterCopilot
andcommitted
Create contributing guide for Claude tooling
Co-authored-by: Copilot <copilot@github.com>
1 parent 9c6b63b commit b980be1

1 file changed

Lines changed: 130 additions & 0 deletions

File tree

.claude/CONTRIBUTING.md

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
# Contributing Claude Context to This Repo
2+
3+
Every time you catch Claude making the same mistake twice, explain the same convention in chat, or
4+
hand a teammate a mental map they didn't have — that's knowledge worth encoding. This guide covers
5+
what belongs in this repo's `.claude/`, where to put it, and how to land it alongside the code it
6+
describes.
7+
8+
## When to contribute here vs. elsewhere
9+
10+
Ask: **is this knowledge specific to this codebase, or generic enough to work across repos?**
11+
12+
- **Specific to this codebase** → contribute here, in `.claude/`. Example: "how we add a new module
13+
in this codebase," "how our feature-flag system works."
14+
- **Generic, reusable across repos**
15+
[`bitwarden/ai-plugins`](https://github.com/bitwarden/ai-plugins) — persona plugins (e.g., a
16+
code-review agent), tool integrations, or shared utilities.
17+
18+
When unsure, keep it here. Promoting up to `ai-plugins` later is easier than pulling it back — see
19+
its [CONTRIBUTING.md](https://github.com/bitwarden/ai-plugins/blob/main/CONTRIBUTING.md) when you're
20+
ready.
21+
22+
## Choose scope, then shape
23+
24+
### 1. Scope — where does it apply?
25+
26+
Claude loads every `CLAUDE.md` and `CLAUDE.local.md` by
27+
[walking up from the working directory](https://code.claude.com/docs/en/memory#how-claude-md-files-load)
28+
— looking in each ancestor directly, not in a nested `.claude/` subdirectory. Files below the
29+
working directory (including nested `.claude/skills/`) are loaded lazily when Claude reads into that
30+
subtree. Use that hierarchy:
31+
32+
- **Applies everywhere in this repo** → root `CLAUDE.md` or `.claude/skills/`
33+
- **Applies only within one app, library, utility, or subtree** → nested `CLAUDE.md` or
34+
`.claude/skills/` in that directory
35+
36+
Push rules as deep as they'll go — keeping app-specific rules local saves context for everyone
37+
else's sessions, not just yours.
38+
39+
For rules that should apply only to certain file types, use
40+
[`.claude/rules/<name>.md` with a `paths:` frontmatter glob](https://code.claude.com/docs/en/memory#organize-rules-with-claude/rules/)
41+
instead of a nested `CLAUDE.md`.
42+
43+
### 2. Shape — how should Claude use it?
44+
45+
| You want to… | Use |
46+
| ------------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
47+
| State a rule Claude must always follow in its scope | `CLAUDE.md` |
48+
| State a rule that applies only to certain file globs | `.claude/rules/<name>.md` with `paths:` frontmatter |
49+
| Teach a procedure Claude invokes on demand | `.claude/skills/<name>/SKILL.md` |
50+
| Give Claude a specialized subagent with its own context | `.claude/agents/<name>.md` (YAML frontmatter; `name` + `description` required) |
51+
| Add a user-invocable slash command | `.claude/commands/<name>.md` |
52+
| Trigger a shell script on a Claude Code event | _We have them, but no strict project enforcement yet — register yours in `settings.local.json`._ |
53+
54+
Rule of thumb: **if Claude only needs it sometimes, it's a skill.** Once a `CLAUDE.md` loads, it
55+
stays in context for the rest of the session — keep each one lean, especially the root.
56+
57+
## Security conventions
58+
59+
Skills and agents that touch vault data, authentication, or cryptography must use Bitwarden's
60+
[Core Vocabulary](https://contributing.bitwarden.com/architecture/security/definitions) (Vault Data,
61+
Protected Data, Secure Channel, etc.) and re-state the zero-knowledge invariant inline. **Subagents
62+
run in a fresh context** and do not inherit this repo's `CLAUDE.md` — include the relevant
63+
definitions directly in the agent's system prompt.
64+
65+
## What good contributions look like
66+
67+
- **Grounded in the code.** Real files, real patterns, real commands. If it could apply to any repo,
68+
it belongs in `ai-plugins`.
69+
- **Describes the "what" and "why," not the "who."** Avoid team-persona framing. Describe the domain
70+
and its constraints; the team is an implementation detail.
71+
- **Short and specific.** 2,000 words of general advice isn't a skill.
72+
- **Active voice, direct language.** "Invoke this skill when..." — not "This skill may be invoked
73+
when..."
74+
- **Reviewed like code.** Teams of domain experts own `.claude/` in their areas — they're the ones
75+
shaping how Claude behaves for everyone who works there, so treat changes with the same
76+
seriousness as source.
77+
78+
## Anti-patterns
79+
80+
- **Team-persona agents** ("Team ABC engineer"). If a team's process is unique enough to warrant a
81+
persona, that's an SDLC signal to address, not a persona to encode.
82+
- **Root-level rules that only matter in one subtree.** If the rule only ever applies to a single
83+
subtree, then the rule belongs in a nested `CLAUDE.md` next to that subtree.
84+
- **Duplicating `ai-plugins` content.** Check existing plugin skills before writing a new one.
85+
- **Generic advice disguised as repo-local knowledge.** "Write good tests" isn't repo-specific. "Our
86+
integration tests must hit a real database because…" is.
87+
88+
## Building a contribution
89+
90+
The Claude Code ecosystem moves fast — last session's habits may already be out of date. Here's the
91+
workflow we follow.
92+
93+
### 1. Start with the canonical docs
94+
95+
A quick refresh before you begin goes a long way — the rules shift more often than you'd think:
96+
97+
- [How Claude Code Works](https://code.claude.com/docs/en/how-claude-code-works) — the mental model.
98+
- [Best Practices for Claude Code](https://code.claude.com/docs/en/best-practices) — what Anthropic
99+
recommends.
100+
- [Extend Claude Code](https://code.claude.com/docs/en/features-overview) — what you can build
101+
(skills, agents, commands, hooks).
102+
- [The Complete Guide to Building Skills for Claude](https://resources.anthropic.com/hubfs/The-Complete-Guide-to-Building-Skill-for-Claude.pdf) -
103+
a must read for skill building
104+
105+
### 2. Survey the landscape
106+
107+
A quick skim of both goes a long way:
108+
109+
- This repo's [`.claude/`](.) tree.
110+
- [`bitwarden/ai-plugins`](https://github.com/bitwarden/ai-plugins).
111+
112+
Try to match the voice you see. "Invoke when the user asks to X" — not "This skill may be invoked
113+
when X." Direct, active, specific. Your contribution should read like the neighbors.
114+
115+
### 3. Build iteratively
116+
117+
When you're authoring a skill, start with `/skill-creator:skill-creator`. It runs an iterative loop
118+
— draft → test against evaluations → review outputs → refine — with benchmark stats and a
119+
side-by-side reviewer. You end up with a skill that's been exercised against concrete inputs before
120+
you open the PR.
121+
122+
For agents, commands, hooks, and `CLAUDE.md` entries, start from an existing one in the repo and
123+
adapt it. No need to invent a new structure when a neighbor already solves the shape problem.
124+
125+
### 4. Validate before you push
126+
127+
- Run a local Bitwarden Claude Code review with `/bitwarden-code-review:code-review-local` — it
128+
writes findings to files so you can fix them before pushing, without posting anything to GitHub.
129+
- When you raise the PR, apply the `ai-review` label. Our reusable GitHub workflow watches for it
130+
and runs a Claude Code review automatically; without the label, the review doesn't fire.

0 commit comments

Comments
 (0)