Why --- ADR-0018 left deployed skills tracking the remote default branch with nothing watching for drift. The mechanism that was supposed to cover this, scripts/git-hooks/post-push, could never have worked: git has no client-side post-push hook. install.sh copied it into .git/hooks/ so it looked installed, and it had never once fired. Issue #78 reported it as skipping the gitea plugin; it was skipping everything. Refreshing on push was also the wrong shape. Your install goes stale when someone else merges, so a push of your own is neither necessary nor sufficient for staleness to have occurred. Implementation notes -------------------- kyberforge ships a SessionStart hook (startup matcher only) that runs `apm outdated`, and when anything is behind runs `apm update --yes` and returns reloadSkills:true so the running session picks up redeployed content. It exits silently with no apm.lock.yaml present, which keeps it inert for hosts that installed this plugin natively rather than through apm. Two findings drove the wiring, both verified rather than assumed: - apm resolves ${CLAUDE_PLUGIN_ROOT} against the installed package root, and `apm pack` keeps only *.json from .apm/hooks/. A .../hooks/<script> reference therefore points into the generated mirror where the script does not exist — apm reports "Hook script not found" and deploys a hook aimed at nothing. The reference must be .apm/-relative, and a test pins it. - apm's executable-trust gate is OFF unless apm.yml carries an `executables:` block; until now every hook, bin and MCP primitive a dependency shipped would have deployed unprompted. Root apm.yml now enables it. The allow key is version-pinned by apm's design, so a kyberforge version bump silently blocks the hook until the key is bumped too — called out in the block and the ADR. Also corrects ADR-0018 and AGENTS.md, which named `apm install` as the refresh command. It is not: `apm install` deploys from apm.lock.yaml's pinned commit and does not re-resolve refs. `apm update` does. Impact ------ Session startup costs ~0.7s when current and ~10.4s when six packages are behind. Auto-refresh rewrites apm.lock.yaml, so an unexplained modification to it after opening a session is expected; the emitted notice says so. .claude/settings.json stops being exactly {"hooks": {}} once the hook lands there — the merged entry is apm's own output, and the rule that nothing repo-authored goes in that file is unchanged. .claude/hooks/ and the .claude/apm-hooks.json sidecar are gitignored install output. The hook cannot install itself: dependencies resolve from the remote, so it takes effect only after this merges and `apm update` runs once against the new default branch. scripts/git-hooks/ is now empty. install.sh's copy block is kept and test-git-hooks-install.sh synthesizes its own fixture, so the mechanism stays tested without requiring a dead hook to exist. ADR: 0019 Refs: #78 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01X7GvKuJfy2WrdBmUttV4DT
16 KiB
Working in this repo
This repo is the global AI development configuration repository — the authoritative source for agent definitions, skills, workflows, and prompts across all projects. Built as a homelab tool intended to scale to professional environments.
Structure
plugins/— installable plugin units; each is an apm package (apm.yml+.apm/) carrying skills, agents, hooks, MCP servers, and bundled assets. This repo consumes them through apm, not Claude Code's native plugin install: rootapm.ymldeclares all six asdependencies.apmgit+path entries against the holocron remote, andapm installdeploys them into.claude/skills/and.claude/agents/(both gitignored). External consumers can still install natively viaclaude plugin install <name>@holocron— the marketplace manifests are unchangedproviders/claude-code/— Claude Code adapter (deployed to~/.claude/viainstall.sh)
Edit .apm/, never the flat mirror
Inside a plugin, plugins/<name>/.apm/ is the only hand-edited source for plugin content — the skills, agents, commands, instructions, extensions and hooks a host discovers. Everything in a plugin root that mirrors an .apm/ primitive, plus both plugin.json manifests, is generated:
scripts/sync-plugin-content.shgenerates the flatplugins/<name>/{skills,agents,commands,instructions,extensions}/directories and the mergedplugins/<name>/hooks/hooks.json(ADR-0017)apm packgenerates both per-plugin manifests —plugins/<name>/.claude-plugin/plugin.jsonandplugins/<name>/.github/plugin/plugin.json— and two of the three root marketplace manifests:.claude-plugin/marketplace.json(apm'sclaudeoutput profile) and.agents/plugins/marketplace.json(itscodexprofile, a differently-shaped file) (ADR-0015)scripts/sync-marketplace-mirror.shgenerates the third,.github/plugin/marketplace.json— Copilot CLI's legacy manifest path. No apm output profile targets it: apm ships exactly two marketplace output profiles,claudeandcodex(documented inplugins/kyberforge/.apm/skills/apm-workflow/references/marketplace.md). The mirror is a byte-identical copy of.claude-plugin/marketplace.json, gated by thecheck-marketplace-mirror-syncpre-push hook. Do not expectapm packto refresh it — that assumption is exactly the drift this pair exists to prevent
A plugin root is not wholly generated. Material that is not an .apm/ primitive is hand-authored there and no compiler touches it: README.md, docs/, bin/, sources.md, .mcp.json, plus per-plugin extras like plugins/git/config.example.json, plugins/gitea/references/ and plugins/bin/evals/. Edit those in place — they have no .apm/ source, and looking for one wastes a search. The rule is per-path, not per-directory: plugins/<name>/skills/ is generated, plugins/<name>/docs/ is not. docs/spec/architecture.md carries the same carve-out.
One qualification: "hand-authored, untouched" holds only at the plugin root. A file placed inside a mirrored directory is destroyed — sync_dir runs rm -rf "$dst" before every copy, so a README.md under plugins/<name>/hooks/ or plugins/<name>/skills/ is deleted on the next sync whether or not .apm/ has a counterpart. Put root-level plugin documentation in docs/, never in a mirrored directory.
Nothing labels a generated file as generated — plugins/kyberforge/skills/forge/SKILL.md is byte-identical to its .apm/ original, with no marker in either. Check the path before you edit. An edit to the mirror is discarded by the next sync and is reported as drift by the check-plugin-content-sync pre-push hook, which is the earliest anyone finds out. Details in docs/spec/architecture.md.
Prefer plugin skills over raw shell
This repo dogfoods its own plugins. Before shelling out to git, gitea, or lint tooling directly, check whether an installed skill already owns the operation — it usually does:
- Commits, branches, history, worktrees, remotes →
git-commits,git-branches,git-history,git-worktrees,git-remotes - Pre-commit hook install/config/troubleshooting →
pc-run/pc-author - Issues, PRs, labels, milestones →
gitea-issues,gitea-prs,gitea-labels-milestones; alsogitea-branches,gitea-files,gitea-releases, orgitea-workflowwhen the domain is ambiguous - Vale prose linting →
vale-config/vale-run - This repo's own AGENTS.md →
agentsmd-author/agentsmd-audit
Names are unnamespaced. Under the old claude plugin install these were git:git-commits, kyberforge:skill-audit, and so on; apm install deploys each skill to .claude/skills/<name>/ as a plain project skill, which has no plugin prefix to carry. The <plugin>: form no longer resolves here — it still does in any project that installs holocron natively, so a skill body written for both audiences should name the bare skill. Same for agents: git-orchestrate, not git:git-orchestrate.
Fall back to raw shell only when no skill covers it.
Setup and testing
- Run
apm installto deploy this repo's own skills and agents into.claude/skills/and.claude/agents/. Both are gitignored install output, not authoring source —plugins/<name>/.apm/remains the only place to edit. The six dependencies in rootapm.ymlresolve from the holocron remote, unpinned against the default branch, so a.apm/edit is not visible to the running session until it is pushed andapm updatere-runs (apm installdeploys fromapm.lock.yamland does not re-resolve refs). Needs the network, and needsapm_modules/(which it materializes) left gitignored.apm installalso configures theobsidianMCP server into the repo's.mcp.json, carried over fromplugins/bin/.mcp.json. - Do not add repo-owned keys to
.claude/settings.json. apm treats that file as its own deployed artifact:apm audit --cireplays the install into a scratch tree and diffs, so anything apm would not have written there — anenabledPluginsblock, a realhooksentry — is permanent drift that fails theapm-audit-cipre-push hook. Its committed content is whatever apm last wrote —{"hooks": {}}until kyberforge'sSessionStarthook lands there, after which the merged hook entry is apm's output and belongs in the commit (ADR-0019). What does not change is that nothing repo-authored goes in the file. A hook you want in this repo is authored inplugins/<name>/.apm/hooks/and deployed by apm, never hand-written here. Machine-specific settings go in the gitignored.claude/settings.local.json, which apm does not deploy and the replay does not compare; shared enforcement belongs in.pre-commit-config.yaml. - Keeping the install current is automatic but not free. Because the six dependencies are unpinned, deployed skills go stale whenever anyone merges. kyberforge ships a
SessionStarthook that runsapm outdatedat startup (~0.7s) and, when something is behind, runsapm update --yesand asks the host to re-scan skills (~10.4s). That rewritesapm.lock.yaml, so an unexplained modification to it after opening a session is expected, not a bug — commit or discard it deliberately. Noteapm installalone will not pick up remote changes; it deploys from the lock.apm updateis the command that re-resolves refs. - Install git hooks via
pc-run, wiring all three stages — this repo's.pre-commit-config.yamlhas nodefault_install_hook_types, so a plain install silently skipscommit-msg(Conventional Commits) andpre-push(the 13-hook gate described below). - Install the
apmCLI — four pre-push hooks shell out to it:apm-marketplace-check,apm-audit-ci,apm-pack-check-clean, andcheck-plugin-content-sync(viascripts/sync-plugin-content.sh, which wrapsapm pack).apm-marketplace-checkandapm-pack-check-cleanare bareapm …hook entries andapm-audit-ciis abash -cloop callingapmonce per package, so without it the push dies with an unhelpful "command not found". Useapm-install, orcurl -sSL https://aka.ms/apm-unix | sh; verify withapm --version. - Install
jq— required byscripts/check-manifests.shandscripts/sync-plugin-content.sh, both pre-push. These at least fail loudly (Error: jq is required but not installed). - Install the
valebinary — required by thevale-audit-prefilter-skill/-agentpre-commit hooks. Theirfiles:patterns are.apm/-scoped:^plugins/[^/]+/\.apm/skills/[^/]+/SKILL\.md$and^plugins/[^/]+/\.apm/agents/[^/]+\.agent\.md$. Only the authoring source triggers them — aSKILL.mdin the generated mirror matches neither pattern, so prose findings surface only when you edit the file you are supposed to be editing. Without the binary the hooks fail with a bare "command not found" and no install pointer.brew install vale(macOS),snap install vale(Linux),choco install vale(Windows), or see https://vale.sh/docs/vale-cli/installation/. Novale syncneeded — theKyberforgestyles are committed underplugins/kyberforge/.apm/skills/{skill-audit,agent-audit}/assets/vale/styles/, not downloaded packages (see ADR-0014). valeis also a pre-push dependency, not only pre-commit.check-vale-style-syncruns six glob-coverage probes by invokingvale --config— they are the only assertions in it that catch a.vale.iniglob typo, the failure mode where every text-level check stays clean while vale lints zero files. Missingvaleis therefore a hard failure there. The opt-out isCHECK_VALE_STYLE_SYNC_ALLOW_MISSING_VALE=1, and it is notSKIP=: the hook still runs and still asserts everything verifiable from file text, but the six probes do not, and its summary says so explicitly —Vale style sync check passed (text-level only, vale unavailable): … 0 glob probe(s) verified. Use it only on a machine that genuinely cannot installvale, and read that summary line as "the glob axis was not checked", not as a pass.- Run
bash tests/run-tests.shbefore considering any change done — it runs everytest-*.shscript in the repo plus the bats suite (--bats-onlyfor just bats). First run auto-initializes the bats submodules; no manualgit submodule updateneeded. - A suite that exits 77 because a dependency is missing is reported as SKIPPED, and does not fail an ad-hoc run. The pre-push hook invokes the same script as
--strict(RUN_TESTS_STRICT=1is equivalent), where a skip does fail the push: at pre-push a skip means one of the dependencies above is absent on this machine, so the gate would otherwise report success having run fewer suites than it appears to. Without vale, for instance, three suites skip (test-check-vale-style-sync.sh,test-vale-hooks-consumer.sh,test-vale-wrap.sh) and the strict failure names each one and what to install. tests/run-bats.shderives the set of.batsfiles it expects fromgit ls-files, so a.batsfile deleted from the worktree but still tracked in the index fails the run rather than silently shrinking the suite. Remove one withgit rm(or stage the deletion) when the removal is intentional; an untracked new.batsfile is picked up and needs no ceremony. Both discovery walks (tests/run-bats.shandtests/run-tests.sh) excludeapm_modules/:apm installmaterializes a full copy of every plugin there, and running a dependency's copy of a.batsfile breaks its relative path to the bats helpers — 167 spurious failures before the exclusion landed.- Pushing runs 13 repo-defined pre-push hooks, not just the test suite —
run-testsandcheck-manifests, plus generated-content drift gates (check-plugin-content-sync,check-marketplace-mirror-sync,check-vale-style-sync,check-scope-walkup-sync), artifact validators (check-apm-agents-valid, which runs agent-audit'svalidate.shover every realplugins/*/.apm/agents/*.agent.md), apm's own gates (apm-marketplace-check,apm-audit-ci,apm-pack-check-clean), host validators (validate-plugins,validate-marketplace, both needing theclaudeCLI), andcheck-release-needed. Runpre-commit run --hook-stage pre-push --all-fileslocally — one command, the whole gate. That command reports 15, not 13: pre-commit's ownmetahooks,check-hooks-applyandcheck-useless-excludes, declare nostages:and so run at every stage including this one. apm-audit-cirunsapm audit --cionce per manifest — the root one and each of the six plugin packages — because the root-only invocation audits the marketplace manifest and nothing else, andapm-pack-check-cleandoes not parse plugindependencies:blocks either (verified: a malformed one passesapm pack --check-versions --check-clean --dry-runand failsapm audit --ciin that package's directory). It verifies two things and claims no more: eachapm.ymlparses as a valid APM manifest, and any package declaring dependencies has a consistentapm.lock.yaml. It does not enforce an org policy — apm discovers one from the git remote and only understands github.com and Azure DevOps, so against this repo's self-hosted Gitea remote it printsNo org policy found at unknown; enforcement skipped. Do not "fix" that withpolicy.fetch_failure_default: blockinapm.yml: it was tested and rejected, because with no reachable policy source it makes the hook exit 1 on every push forever.check-apm-agents-validderives its expected agent-file set fromgit ls-files(same pattern astests/run-bats.sh), so an agent file deleted from the worktree but still tracked fails the run, and discovering zero agent files is an error rather than a pass. An untracked new agent file is still validated — the derivation is one-directional on purpose, so uncommitted work is not blocked but also cannot bypass the gate.- Two pre-push hooks need the network, for one shared reason: root
apm.yml'smarketplace.packages[]contains exactly one remote entry (mattpocock-skills,source: mattpocock/skills), and resolving it needs agit ls-remote.apm-marketplace-checkresolves every entry and isalways_run, so it fails withNo cached refs (offline).apm-pack-check-clean(apm pack --check-versions --check-clean --dry-run) re-resolves the same entry and fails withError: Git network timeout during ls-remote. Pinning the entry to an exact version does not remove the call — an exact pin still ls-remotes.--offlinerescues neither. To push without a network, skip both using pre-commit's own mechanism:SKIP=apm-marketplace-check,apm-pack-check-clean git push. Skip those two alone — verified underunshare -rn, the other eleven pre-push hooks pass offline because they are real local checks, and adding one of them toSKIPdisarms it silently.apm-audit-cicallsapmtoo but stays local: its org-policy discovery resolves nothing on this remote before any network call, so it does not join the pair above. - Author commits with
git-commits— it validates Conventional Commits (enforced atcommit-msg) for you.
Key documents
Read CONTEXT.md at the start of every session in this repo.
Read these on demand:
docs/spec/architecture.md— current directory structure, install pipeline, provider modeldocs/adr/— architectural decisions; read before answering design questions or proposing structural changesdocs/ai-constitution.md— full governance evidence base; read when a governance decision needs justificationdocs/research/ai-coding-factory/ai-coding-factory-principles.md— factory design rationale; read when implementing, auditing, or reviewing skills or factory structuredocs/notes/factory-integration-decisions.md— decisions from the factory integration grill; read when making skill authoring or factory design decisions- Governance rules are always in effect —
core/instructions/governance.md(agent rules);docs/research/governance_principles/CONTROLS.md