REPO_POLICIES: .gitignore and .dockerignore
check / check (push) Canceled after 0s

Moves the warning not to copy .gitignore patterns into .dockerignore
next to the .dockerignore rule, splits the two long paragraphs into
lists, and cuts the history "since consuming repos receive the file
and not the tracker"; every pattern rule stays.

Model: opus-5-5
This commit is contained in:
clawbot committed 2026-11-16 23:50:06 +00:00
1 parent 64b8139d44
commit 2bc68d1f1e
1 file changed
+37 -32
+37 -32
View File
@@ -645,6 +645,8 @@ style conventions are in separate documents:
`if: github.ref_name == 'main'`, so the run from the feature branch `if: github.ref_name == 'main'`, so the run from the feature branch
publishes nothing. publishes nothing.
# `.gitignore` and `.dockerignore`
- `.gitignore` should be comprehensive from the start: - `.gitignore` should be comprehensive from the start:
- OS files (`.DS_Store`) - OS files (`.DS_Store`)
- editor files (`.swp`, `*~`) - editor files (`.swp`, `*~`)
@@ -657,47 +659,50 @@ style conventions are in separate documents:
`https://git.eeqj.de/sneak/prompts/raw/branch/main/.gitignore` when setting `https://git.eeqj.de/sneak/prompts/raw/branch/main/.gitignore` when setting
up a new repo. A repo's `.gitignore` is the standard file followed by the up a new repo. A repo's `.gitignore` is the standard file followed by the
repo's own entries, such as its binaries. A re-vendor replaces the standard repo's own entries, such as its binaries. A re-vendor replaces the standard
part and keeps those entries. These patterns are written to `.gitignore`'s part and keeps those entries.
own semantics, in which an unanchored pattern already matches at every
depth. They are not a `.dockerignore` and must not be transplanted into one
unmodified.
- **`.dockerignore` does not use `.gitignore` semantics, and copying patterns - **`.dockerignore` does not use `.gitignore` semantics, and copying patterns
across unmodified leaves secrets in the build context.** Docker matches with across unmodified leaves secrets in the build context.** The standard
`.gitignore` patterns are written to `.gitignore`'s own semantics, in which an
unanchored pattern already matches at every depth. They must not be
transplanted into a `.dockerignore` unmodified. Docker matches with
`moby/patternmatcher`: `filepath.Match` semantics plus a `**` extension. So `moby/patternmatcher`: `filepath.Match` semantics plus a `**` extension. So
`*` does not cross `/`, and a pattern without a leading `**/` is anchored at `*` does not cross `/`, and a pattern without a leading `**/` is anchored at
the build-context root. A `.dockerignore` listing `.env`, `*.pem` and `*.key` the build-context root.
therefore excludes only the copies at the repository root. `config/.env` and - A `.dockerignore` listing `.env`, `*.pem` and `*.key` therefore excludes
`certs/server.key` still reach the context and can land in an image layer. only the copies at the repository root. `config/.env` and
Such a `.dockerignore` is more dangerous than a short file with no secret `certs/server.key` still reach the context and can land in an image layer.
patterns at all, because it reads as solved and stops anyone looking. Give Such a `.dockerignore` is more dangerous than a short file with no secret
every depth-independent pattern the `**/` prefix, and leave only genuinely patterns at all, because it reads as solved and stops anyone looking.
root-anchored entries unprefixed. Those are `.claude`, `.yarn/*`, - Give every depth-independent pattern the `**/` prefix, and leave only
`!.yarn/releases`, and the repo's own host-built binary. The binary is written genuinely root-anchored entries unprefixed. Those are `.claude`,
`/myapp` and never `**/myapp`, which would also match `cmd/myapp/` and delete `.yarn/*`, `!.yarn/releases`, and the repo's own host-built binary. The
the package directory from the context. Matching is case-sensitive, and an binary is written `/myapp` and never `**/myapp`, which would also match
all-caps copy of each pattern still misses `Server.Key`. So secret names use `cmd/myapp/` and delete the package directory from the context.
character ranges: `**/*.[kK][eE][yY]`, `**/*.[pP][eE][mM]`, and likewise for - Matching is case-sensitive, and an all-caps copy of each pattern still
`.envrc` and the extensionless SSH keys. Where such a pattern also catches misses `Server.Key`. So secret names use character ranges:
something the build needs, re-include it with a negation `**/*.[kK][eE][yY]`, `**/*.[pP][eE][mM]`, and likewise for `.envrc` and
(`!docs/example.env`). Deleting the pattern reopens the exposure for every the extensionless SSH keys.
other file it covers. Fetch the standard `.dockerignore` from - Where such a pattern also catches something the build needs, re-include it
`https://git.eeqj.de/sneak/prompts/raw/branch/main/.dockerignore` and extend with a negation (`!docs/example.env`). Deleting the pattern reopens the
it with the repo's own artifacts. exposure for every other file it covers.
- Fetch the standard `.dockerignore` from
`https://git.eeqj.de/sneak/prompts/raw/branch/main/.dockerignore` and
extend it with the repo's own artifacts.
- **In-repo agent scratch belongs in both files, written to each file's own - **In-repo agent scratch belongs in both files, written to each file's own
semantics.** `.claude/` holds one worktree per in-flight agent, an entire semantics.** `.claude/` holds one worktree per in-flight agent, an entire
additional checkout of the repo. Under `COPY . .` the build context therefore additional checkout of the repo. Under `COPY . .` the build context therefore
inflates by a multiple of the repo, and another session's unreviewed work can inflates by a multiple of the repo, and another session's unreviewed work can
be copied into an image layer. In `.gitignore` the entry is `.claude/`, be copied into an image layer.
unanchored. In `.dockerignore` it is `.claude`, anchored and with **no** `**/` - In `.gitignore` the entry is `.claude/`, unanchored.
prefix, because the prefixed form would also delete any nested directory of - In `.dockerignore` it is `.claude`, anchored and with **no** `**/` prefix,
that name from the build. Anchoring carries a known gap. The canonical because the prefixed form would also delete any nested directory of that
`.dockerignore` states the gap in its own comment, since consuming repos name from the build.
receive the file and not the tracker. The gap is that the directory is created - Anchoring carries a known gap, which the canonical `.dockerignore` states
in the agent's working directory. A repo running agents in subdirectories in its own comment. The directory is created in the agent's working
therefore still ships `services/api/.claude/` and must add its own anchored directory. A repo running agents in subdirectories therefore still ships
entry there. `services/api/.claude/` and must add its own anchored entry there.
- **Verify `.dockerignore` by enumerating the image, not by reading the - **Verify `.dockerignore` by enumerating the image, not by reading the
patterns.** Plant files at the root _and_ at least two directories deep. Build patterns.** Plant files at the root _and_ at least two directories deep. Build