/docent:docent-onboardingfrom docent
Wire docent into a Go CLI that has no agent surface yet — embedded guides, runtime schema, skill export, and the optional human guide command. Use when adding agent support to a cobra-based CLI or adopting the Agent Guide Standard from scratch.
Ships in docent. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Wire docent into a cobra-based Go CLI so it serves its own agent knowledge: embedded Markdown guides, a runtime-derived command schema, and generated skills — one source of truth, never a hand-maintained twin.
go get github.com/matcra587/docent, or a
go.work pointing at a checkout while developing pre-tag (never commit
go.work).// internal/agentguides/agentguides.go
package agentguides
import (
"embed"
"io/fs"
"github.com/matcra587/docent"
)
//go:embed guides/*.md
var guidesFS embed.FS
// Load parses and validates the embedded guide set.
func Load() (*docent.GuideSet, error) {
sub, err := fs.Sub(guidesFS, "guides")
if err != nil {
return nil, err
}
return docent.LoadGuides(sub)
}
One file per guide under internal/agentguides/guides/, six sections in
order, frontmatter per the standard:
---
slug: safe-mutation
title: Preview every write before sending it
description: Validate a mutation with --dry-run, then submit and verify.
when_to_use: Before any create/edit/delete against a live instance.
commands: [tool item create, tool item edit]
---
## Decide
## Run
## Save
## Preconditions
## Recover
## Next
Conventions that save rework later:
commands: entries are full paths including the root name; a
cross-cutting guide declares commands: [] (whole-tool scope) — never
a token command it does not document.## Preconditions already states "none"; filler prose costs tokens.description + when_to_use compose into the exported skill
description and must fit 1024 characters; front-load trigger words.title, description, when_to_use, each
commands:/aliases: entry) must be single-line — no YAML block
scalars — and guide content may not contain form-feed characters;
both fail validation at load.Mount after the tree is fully assembled — never in init, where later
init functions register commands the schema walk would miss:
guides, err := agentguides.Load()
if err != nil {
return fmt.Errorf("load agent guides: %w", err)
}
tree := docentcobra.Tree(root)
tree.Extensions = map[string]any{ // host contract metadata, host-owned
"auth": map[string]any{"env_var": "TOOL_TOKEN"},
"exit_codes": map[string]any{"validation": 4},
}
cfg := docent.Config{Guides: guides, Command: tree}
root.AddCommand(docentcobra.NewCommand(cfg))
If multiple CLIs export into the same harness skills root, pass
docentcobra.WithSkillNameQualifier("jira") to NewCommand. It exports guide
slug core-contract as jira-core-contract/SKILL.md without changing
agent guide core-contract. Omit the option for unqualified output. The
qualifier applies only to docent's built-in agent-skill and claude-skill
formats; host-supplied extra formats receive the original guide unchanged.
A host with its own agent-contract version sets Config.ContractVersion;
adapters stamp it onto the schema root and the guide index so agents can
pin behavior. Keep it a single line with no colons — emission fails loudly
otherwise.
Optionally add the human door — same guide set, byte-identical output,
host-owned styling (see the _examples/glamour-host dispatch:
charm.land/glamour/v2, buffer-then-render, agents and pipes get raw
Markdown):
root.AddCommand(docentcobra.NewGuideCommand(cfg))
The standard requires agent guide/schema/export to work without
credentials: discovery precedes auth. Cobra runs your root's persistent
hooks around docent's commands, so exempt them:
for c := cmd; c != nil; c = c.Parent() {
if c.Name() == "agent" || c.Name() == "guide" {
return nil // skip credential resolution
}
}
Self-host the contract in your CI — every guide violation class fails
distinctly. Pass the guides/-rooted view, not the raw embed FS (which
is rooted one level up and would validate zero files):
sub, _ := fs.Sub(guidesFS, "guides")
docenttest.Validate(t, sub, tree)
Pin the schema: docenttest.SchemaGolden(t, tree, "testdata/schema.json", *update); mask startup-computed defaults (ephemeral ports, home paths)
with docenttest.MaskFlagDefaults or the pin flakes.
Validate exports: tool agent export --format agent-skill --dir /tmp/s
then bunx skills-ref validate /tmp/s/<slug> — every artifact must
pass. claude-skill answers to Claude Code's schema instead and is
rejected by skills-ref by design.
Validate harness-specific placement without relying on environment
detection: tool agent export --scope user --harness claude-code.
init — the schema silently misses late-registered
commands. ✅ Mount from Execute/main after assembly.agent guide on
keyring-less machines. ✅ Step 4.Config.Out; docent emits plain Markdown.tool agent guide prints a frontmatter index; --section, --all,
schema --path, and export all answer — with no credentials
configured.docenttest.Validate and the schema golden run in CI.agent-skill artifacts pass skills-ref validate.docent-migrate — when the CLI already has a hand-rolled agent
surface to replace.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
Generated from the plugin's indexed repository (matcra587/docent) — no native marketplace selected
npx claudepluginhub p/matcra587-docent