agentleFS
nrjdalalnrjdalal/zerostarter/.agents/skills/sync-ignore/SKILL.md

sync-ignore

Skill65 starsChanged 4 days agoMITView on GitHub

Mirror .gitignore to .dockerignore. Use whenever a .gitignore entry is added or removed, or when auditing a bloated Docker build context.

  • Reads credentials

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    After any .gitignore edit, run:

    line 26

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Ignore Sync

.dockerignore does not inherit from .gitignore. Whatever git ignores but .dockerignore misses still enters the Docker build context (COPY . . in the prepare stage of web/next/Dockerfile and api/hono/Dockerfile), and on this repo that has meant gigabytes: web/next/.next alone hit 3GB and .turbo 23GB.

The two files are mirrors

.gitignore is the source of truth and .dockerignore follows it line for line, written by bun run sync:ignore (packages/scripts/src/sync-ignore.ts), so an edit goes to .gitignore alone. Every ignore rule and every shared ! un-ignore (e.g. !.yarn/patches) lives in the shared body of both: same entry, same section, same order, same commit.

The script writes two sanctioned divergences:

  • The **/ prefix. Docker matches each pattern from the build context's root, while git matches a pattern with no slash before its end at any depth (Build context). So .dockerignore writes each folder pattern git matches at any depth with a **/ prefix (node_modules/ becomes **/node_modules/), which keeps every workspace's .next, dist and node_modules out of the context. A pattern git anchors to the root, one with a slash before its end (web/next/content/docs/meta.json), stays as written, and so does a file pattern (.env*, next-env.d.ts), on purpose: the prefix is for folders alone. A folder .gitignore writes with no trailing slash (.vercel) gets its prefix only when its name is in the script's SLASHLESS_FOLDERS.
  • The labeled tail at the end of each file, for a git-only or docker-only override. The script drops .gitignore's tail, from its # git overrides line on, and writes its own DOCKER_TAIL: # docker overrides, .git, and !.env.example. .git stays out of the context since the images build from turbo prune's output, which holds none. A docker-only override goes in DOCKER_TAIL.

.env stays out of the context

Real .env* files never enter the Docker context. Each build mounts the host file as a required BuildKit secret (--mount=type=secret,id=dotenv,target=/app/.env,required=true; compose supplies it via secrets.dotenv.file: .env), so it is validated in full during the build yet never lands in a layer. A diff that re-includes .env* to feed a builder-stage COPY is drift; sync it away.

Sync

After any .gitignore edit, run:

bun run sync:ignore

Done when bun run sync:ignore --check exits 0. The pre-commit hook runs the script whenever .gitignore or the script is staged, and stages .dockerignore; CI runs --check, so a hand edit to .dockerignore fails the pull request.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.