---
covers:
- src/company.rs
- src/copydir.rs
- src/manifest.rs
- src/agentsmd.rs
- src/project_update.rs
- src/tui.rs
- src/source.rs
---
# Company rules
Status: implemented. Company rules are rule files that an organisation or a project keeps outside the
agent-guides pack. `agentic install` copies them into the project next to the pack rules. A company rule wins
over a pack rule on the same topic ([artifact standard](artifact-standard.md), P2 and ART-K1..K3).
## Purpose
- Keep internal standards (internal systems, hosts, team conventions) out of the public pack (ART-K3).
- Install them with the same command, for every host, and keep them current on `agentic upgrade`.
- Drop the pack rules that a company rule replaces, so the agent does not read two rules on one topic.
The feature is opt-in. Without `settings.company_rules` in `.agentic.json`, install and upgrade work as before.
## Configuration
`.agentic.json`:
```json
{
"settings": {
"company_rules": {
"sources": [
{"path": ".agent/company"},
{"git": "git@gitlab.example.com:group/standards.git", "ref": "main", "subdir": "rules"}
],
"exclude": ["software/backend/testing"]
}
}
}
```
| Key | Meaning |
|---|---|
| `sources[].path` | A directory with rule files, relative to the project or absolute. |
| `sources[].git` | A git URL. `ref` (branch, tag, or commit; default: the remote `HEAD`) and `subdir` (default: the repository root) are optional. |
| `exclude` | Pack rule ids `//` that the install skips. |
CLI (`agentic install`; each flag can repeat):
```bash
agentic install --project-dir /path/to/project --agent-os claude,codex \
--areas software --specializations software.backend \
--company-rules-git 'git@gitlab.example.com:group/standards.git#main:rules' \
--company-rules-path .agent/company \
--company-rules-exclude software/backend/testing
```
- `--company-rules-git [#ref][:subdir]`. For a subdir without a ref, write `#:`.
- `--company-rules-path `.
- `--company-rules-exclude ` (also a comma-separated list).
On a repeated install, CLI sources replace the saved sources, and CLI excludes are added to the saved list.
`agentic upgrade` replays `settings.company_rules` from the manifest. To turn the feature off, remove
`settings.company_rules` from `.agentic.json` and run `agentic upgrade`.
TUI: after the specializations, the optional "Company rules" step asks for a directory and a git repository.
Empty answers keep the feature off. The fields start with the values saved in the project manifest; the saved
`exclude` list stays.
## Source layout
A source holds Markdown rule files, usually one directory per area: `//.md`, for example
`rules/software/api.md` with `subdir: rules`. Install reads every `*.md` file below the source root. It skips
`README.md` files, directories whose names start with `.`, and the top-level `skills/` and `workflows/`
directories (see [Company skills and workflows](#company-skills-and-workflows)). A rule file follows the rule requirements of the
[artifact standard](artifact-standard.md). Frontmatter keys that install reads:
| Key | Effect |
|---|---|
| `paths:` | Scopes the rule. Claude Code loads a rule without `paths:` in every session; install prints a warning for it. |
| `trigger: manual` | The rule stays in `.agent/company/` only; Claude Code gets no copy. |
| `replaces: [//]` | The named pack rules are excluded, as if they were in `exclude`. |
When two sources have the same relative path, the first source wins and install prints a warning.
## Company skills and workflows
A source can also hold skills and workflows next to its rules. Install treats them as pack skills and
workflows of the selected hosts, never as rules:
```text
/
├── software/api.md # rule
├── skills/release-notes/SKILL.md # skill: every file below skills// (scripts, templates)
└── workflows/hotfix.md # workflow: workflows/.md (README.md is skipped)
```
| Source file | Written to | Hosts |
|---|---|---|
| `skills//**` | the skills directory of each host (`.claude/skills`, `.agents/skills`, `.opencode/skills`, ...) and `.agent/skills//` | every host |
| `workflows/.md` | `.agent/workflows/.md` and the workflows directory of each host (`.opencode/commands`, ...) | every host |
| `workflows/.md` | `.claude/commands/.md`: a thin wrapper that runs `@.agent/workflows/.md`, like pack workflows | `claude` |
| both | `AGENTS.md`: `- Company skills: ...` and `- Company workflows: ...` lines with the `description:` of each, below the company rules line, so that Codex and OpenCode models find them | every host |
- A [skill pack](skill-packs.md) skill with the name of a company skill stops the install with an error.
- A skill or workflow with the name of a pack skill or workflow of the selected specializations replaces it on
every host. When the source drops it, `agentic upgrade` restores the pack version.
- Skills and workflows follow the [artifact standard](artifact-standard.md) (skills at most 250 lines,
workflows at most 120 lines and 6 steps).
- The manifest source is `company:/skills//` or `company:/workflows/.md`.
Upgrade, the offline fallback, and the managed-file rules work as for rules.
- When two sources have the same `skills//` or `workflows/.md`, the first source wins.
## What install writes
| File | Hosts | Manifest |
|---|---|---|
| `.agent/company//.md` | every host | `marker: company`, `source: company:/` |
| `.claude/rules/company--.md` | `claude` | same |
| `AGENTS.md`: one line `Company rules in .agent/company/ override agent-guides rules on conflict.` | every host | — |
With `--agents-md keep` the company lines go to the generated guidance files (`.agent/AGENTS.md`,
`AGENTS.override.md`), not to root `AGENTS.md`.
- The source id is the path as configured, or the git URL with `#ref` and `:subdir`. Install hides the user part
of an `https://user:token@host` URL; do not put tokens in URLs anyway, because `settings` keeps the URL.
- A path source that is `.agent/company` itself is used in place: install does not copy or mark its files, and
Claude Code still gets its copies. Files in that directory that carry the agentic marker (copies from other
sources) are not read again.
- Files that you create in `.agent/company/` and that no source provides are never changed or removed. A file of
yours with the same path as a source file is kept too: install prints a warning and skips it. An edited copy
follows the managed-file rules: install skips it, upgrade merges or keeps a backup
([upgrade behavior](agentic-upgrade/README.md)).
- Excluded pack rules are not copied for any host. A repeated `agentic install` removes the excluded pack rules
that an earlier install wrote, unless you edited them. `agentic upgrade` removes them as obsolete artifacts, as
well as company files that a source no longer has.
## Commit only a short AGENTS.md
Some teams commit only a short, hand-written root `AGENTS.md` and keep every generated agentic file local. Use
`--agents-md keep` for that ([details](agentic-reference.md#root-agentsmd-generate-or-keep)):
```bash
agentic install --project-dir . --agent-os claude,codex,opencode --areas software \
--specializations software.backend --agents-md keep \
--company-rules-git https://gitlab.example.com/group/standards.git
```
1. Write root `AGENTS.md` yourself: a pointer to the company standards, the check commands (`make test`,
`make lint`), and other project facts. agentic never changes this file in `keep` mode.
2. agentic writes the generated guidance to `.agent/AGENTS.md` and to `AGENTS.override.md` for Codex. Each
starts with the text of your root `AGENTS.md`. `.claude/CLAUDE.md` imports `.agent/AGENTS.md`, and the OpenCode plugin
`.opencode/plugins/agentic-agents-md.ts` adds it to every OpenCode request.
3. Add the generated paths to `.gitignore`. Install prints the list. A typical list:
```gitignore
.agent/*
!.agent/company
.agents/
.claude/*
!.claude/rules/
.claude/rules/*
!.claude/rules/company-*
.codex/
.opencode/
AGENTS.override.md
.agentic.json
MEMORY.md
REVIEW_PIPELINE.md
CLAUDE.md
```
Keep the `!` lines only for files that the project commits, such as company rules from a git submodule in
`.agent/company`.
4. Each developer runs the same `agentic install` command once. `agentic upgrade` replays the saved mode from
the local `.agentic.json`.
## Git sources
The source type, the git spec parser, the git cache, and the file walk live in `src/source.rs`. Company rules
share them with [skill packs](skill-packs.md); company rules use the cache directory `company`.
- A `ref` that starts with `-` or holds whitespace or control characters, and a URL that starts with `-`, are
refused before git runs. Git gets `--` before the remote and the ref.
- A `subdir` that is a symbolic link (or has one in its path) is treated as not found, so files outside the
checkout never reach the project.
- Install fetches into `~/.cache/agentic/company/` (`$XDG_CACHE_HOME` when set) with the `git` CLI:
`git fetch --depth 1 origin `, then a checkout of `FETCH_HEAD`. The project gets copies; the cache is only
read.
- Git never asks for credentials: install sets `GIT_TERMINAL_PROMPT=0`, `GCM_INTERACTIVE=never`, and, when
`GIT_SSH_COMMAND` is not set, `ssh -o BatchMode=yes`. Use an SSH key or a credential helper.
- When the fetch fails (offline, no access), install uses the cached copy and prints a warning. Without a cached
copy, install prints a warning and keeps the files that the source installed before, so an offline upgrade
removes nothing.
## Duplicate report
After `agentic install` and `agentic upgrade` with company sources, agentic runs the embedded
`scripts/check_artifacts.py --project --json` with `python3` (3.11+) and prints:
```text
=== Company rules vs pack rules ===
- .agent/company/software/testing.md covers pack rule .agent/rules/testing.md: add `replaces: [software/backend/testing]` to it, or install with --company-rules-exclude software/backend/testing
```
The report lists ART-K1 (topic overlap, `replaces:` errors) and ART-K2 (restated statements) findings. It never
fails the install. Without `python3`, agentic prints `Company rules duplicate check skipped: ...`. The full check
of company rules (ART-C*, ART-R*) is `python3 scripts/check_artifacts.py --project ` in an agent-guides
checkout.
## Check
- `cargo test --test cli company_rules`: path source, git source with ref and subdir from a local bare
repository, `exclude` and `replaces:`, upgrade replay of a new commit, offline fallback, the `AGENTS.md` line,
preserved user files, and the duplicate report.
- `cargo test --bin agentic company`: parsing of git specs, settings, frontmatter, and URL redaction.