doc/development/agent_principles/_index.md
GitLab distills development conventions from doc/development/ into principle
files that AI agents load when they plan or implement changes. The resulting
code follows the conventions a human reviewer would expect.
Use this page if your team maintains documentation under doc/development/
and wants AI principles distilled from it.
For the operational runbook (CI variables, service account auth, schedule
recovery), see
.ai/principles/README.md
in the repository.
A scheduled CI job on gitlab-org/gitlab runs every week and performs the
following steps:
.ai/principles/manifest.yml to determine which documentation files
each principle is derived from..ai/principles/distilled/.Distillation runs server-side. The agent reads source files from the branch the sync runs against (the default branch for the weekly schedule).
The script that drives the sync is the
gitlab-ai-principles-distiller
gem.
Use this procedure when your team owns documentation under doc/development/
and you want distilled principles generated from it.
A principle group (for example, Database, Frontend, Testing) typically
contains several related principles that share a group: label in the
manifest. Each principle in the group becomes one distilled file.
Split a group into multiple principles when:
file_filters:.For example, the Database group contains database-fundamentals,
database-migrations, database-schema, and database-queries.
doc/development/.database-migrations,
database-schema, database-queries all share the database- prefix
and the group: Database label..ai/principles/manifest.yml under the
principles: key. For the schema, see
Manifest reference. At a minimum, you need
description, group, and sources..ai/
CODEOWNERS rule routes the review to the AI-tooling maintainers..ai/principles/distilled/<slug>.md. To trigger an earlier run, ask
an AI-tooling maintainer to start the schedule manually.The distillation prompt converts source documentation into imperative
rules when generating the distilled file. Authors of documentation under
doc/development/ do not need to phrase content as DO NOT rules.
Source documentation produces better distillations when it:
For the full prompt that drives the distiller, see
.ai/principles/distillation_prompt.md.
For baseline rules, which the distiller preserves verbatim, see Baseline files.
A baseline file at .ai/principles/baselines/<slug>.md holds rules that
your team relies on but that are not (yet) captured in the public
documentation under doc/development/. The distiller copies baseline
content verbatim into the generated principle file, alongside the rules
distilled from source documentation.
Add a baseline rule when:
db/schema_migrations/ are
auto-generated and do not require a trailing newline" relies on a
generator's behavior rather than a published guideline.doc/development/. Use the baseline as a holding area until the
convention lands in the public documentation.Promote baseline rules into source documentation when possible. A rule
in doc/development/ is reviewable by a wider audience, gets indexed by
search, and benefits projects outside the principles sync.
When the sync regenerates a principle, the distiller receives:
sources: in the
manifest entry.The distillation prompt instructs the distiller to:
The result is written to .ai/principles/distilled/<slug>.md.
Because baseline content is preserved verbatim, write it in the form the agent consumes:
DO NOT and positive
rules with an action verb (Use, Prefer, Ensure, Include, Add, Set,
Follow, Freeze, Pass, Wrap).true in specs; they are already enabled by
default."### Section name) headings to mirror
the structure of distilled files.A minimal baseline file for a hypothetical database-migrations
principle:
### Schema migrations
- Files in `db/schema_migrations/` are auto-generated and do not require
a trailing newline. DO NOT flag missing newlines on review.
### Batched background migration YAML
When creating `db/docs/batched_background_migrations/<name>.yml`, the
YAML must include:
- `migration_job_name: <BBM class name in CamelCase>`
- `description: <one-line description>`
- `feature_category: <category symbol>`
- `milestone: '<X.Y>'`
- `gitlab_schema: <gitlab_main | gitlab_ci | gitlab_main_user | gitlab_main_org>`
The sync job opens a merge request whenever a principle's source documentation changes. The merge request:
When you review one of these merge requests, focus on three questions:
If the distillation produces noise or invents rules, the right fix is usually in the source documentation. Tighten the wording in the source so the distiller has less room to interpret.
The sync detects drift by comparing checksums. If your manifest entry references documentation that has not changed after the last sync, no distillation runs. To force the first generation, either:
--force against
your principle.Open a merge request that:
.ai/principles/baselines/<slug>.md that contains
the rule you want the agent to follow.The next sync run picks up the change.
Revert the auto-generated merge request through the standard GitLab revert flow. The next sync run regenerates the file from the current source documentation.
.ai/principles/manifest.yml..ai/principles/README.md
for the operational runbook.gems/gitlab-ai-principles-distiller
for the gem that drives the sync.