Agent Workflow
Agents should start with repo-owned guidance instead of guessing.
If you are still choosing between the human and agent first-run paths, start at the docs overview. This page is the longer operating loop for agents after that initial routing decision.
Canonical agent path
Section titled “Canonical agent path”- Read root
AGENTS.mdorCLAUDE.md; compact installs route to.mdkg/AGENT_START.md. Legacy installs may retain rootAGENT_START.md. - Run
mdkg status. - Inspect the current goal with
mdkg goal current. - Ground the explicitly authorized goal with
mdkg goal next GOAL_ID. - Show and pack one work node with
mdkg show WORK_IDandmdkg pack WORK_ID. - Do work outside mdkg.
- Record evidence with checkpoints, handoffs, or task updates.
- Validate with
mdkg validatebefore closeout.
The selected goal is a hint, not execution authority. Current user instructions
define the assignment; graph history and skills provide context and conventions.
Use mdkg skill search "task topic" and mdkg skill show SKILL_SLUG for focused
procedures, and focused help such as mdkg pack --help for exact flags. Replace
SKILL_SLUG with the relevant skill slug. Do not repeatedly load the entire handbook.
The website’s llms.txt is public discovery, separate
from generated .mdkg/llms.txt and repo-owned instructions. Neither grants
permission to edit a checkout or execute a selected goal.
Copy this into an agent session when you want a repo-scoped implementation run. Replace uppercase placeholders with concrete ids from your repo:
Start with AGENTS.md or CLAUDE.md and follow its router once.Inspect mdkg goal current as a hint; use the explicitly authorized GOAL_ID.Run mdkg goal next GOAL_ID and mdkg show WORK_ID; discover focused skills.Preview context with mdkg pack WORK_ID --dry-run before editing.Use mdkg goal claim GOAL_ID WORK_ID only after accepting the work item.Run the required checks yourself.Record a checkpoint with commands, pass/fail state, known warnings, and boundaries.Do not store raw secrets, tokens, private prompts, provider payloads, or bulky runtime traces in mdkg nodes.Replace WORK_ID and GOAL_ID with ids returned by the read-only routing commands:
mdkg statusmdkg goal currentmdkg goal next GOAL_IDmdkg pack WORK_IDmdkg goal claim GOAL_ID WORK_IDImportant rules:
goal nextis read-only.goal claimmutates active goal state.task startandtask donemutate lifecycle fields.- Required checks are guidance; agents must run them and record evidence.
scope_refsare executable goal scope;context_refsandevidence_refsare not automatically actionable.- Subgraph qids are read-only planning context unless you are working in the owning repo.
- Do not store raw secrets, unredacted prompt text, tokens, provider payloads, or bulky runtime traces in mdkg nodes.
Command boundaries
Section titled “Command boundaries”Read-only commands are safe for initial grounding:
mdkg status
: Summarizes repo health, git state, selected goal state, generated cache state, and optional project DB state.
mdkg goal current
: Shows the selected goal without changing graph state.
mdkg goal next
: Routes to the next actionable item without claiming it.
mdkg show WORK_ID
: Reads one node by id or qid.
Generated-output commands write derived files, not durable source by themselves:
mdkg pack WORK_ID
: Writes or previews a context pack. Review pack visibility before sharing it outside the repo.
Mutating commands change graph lifecycle or evidence:
mdkg goal claim GOAL_ID WORK_ID
: Updates the goal’s active node. Use it only after accepting one scoped item.
mdkg task start TASK_ID
: Marks a task-like node in progress.
mdkg task done TASK_ID --checkpoint "..."
: Marks the task-like node done and writes checkpoint evidence. Use meaningful checkpoint names and include commands, pass/fail state, known warnings, and follow-up refs.
Beginner safety rule: ground context read-only, establish approved scope and ownership, then start the task and do the work. Record checks and evidence before closing it. A fully planned goal’s explicit run authorizes only its declared actions; commits, pushes, publication and cross-project actions require explicit inclusion or separate approval.
Contract-profile metadata
Section titled “Contract-profile metadata”Agent workflow files may include optional generic profile metadata when a downstream runtime needs a clearer semantic mirror:
contract_profileon MANIFEST, WORK, WORK_ORDER, and RECEIPTvalidation_policy_refandevidence_policy_refon MANIFEST, WORK_ORDER, and RECEIPTreceipt_kindandredaction_classon RECEIPT only
These fields are separate from MANIFEST resource_profile, WORK kind,
WORK_ORDER artifact_policy, RECEIPT redaction_policy, and pack/bundle
--profile flags. Generic validation accepts well-shaped custom values with
warnings for unknown profiles, receipt kinds, or redaction classes. Run
mdkg validate or mdkg work validate for generic checks. Consumer validation
profiles are not executed by mdkg; the former validation --profile option is
unsupported, with no compatibility alias.
The bare field name profile is ambiguous and is diagnosed rather than treated
as an alias.
mdkg owns generic mirror fields and validation. Downstream runtimes own policy, queue execution, final receipt normalization, and adoption. Receipt verification checks structural/local-evidence consistency, not external execution, payment, or attestation authenticity.
For 0.6.0, agent manifests use runtime_mode: orchestrated instead of
room_orchestrated. Work contracts no longer require or generate a
pricing_model, and --pricing-model is unsupported. Conversion is explicit:
review authored manifests and replace the old runtime token only where its
meaning is unchanged; move commercial policy to the consumer or intentionally
retain custom fields through a project-owned template. The generic CLI neither
interprets that commercial policy nor rewrites authored files during validation.
Unknown skill frontmatter remains in the source but has no privileged namespace
in discovery, search weighting, metadata rendering, or JSON projections.
Close work with evidence. Use the concrete TASK_ID from the work item you are closing:
mdkg task done TASK_ID --checkpoint "Meaningful milestone"mdkg validateFor a larger implementation goal:
- Claim one scoped node.
- Build context with
mdkg pack WORK_ID. - Make the code, docs, or graph changes outside mdkg.
- Run the checks listed by the goal or task.
- Record a checkpoint with commands, pass/fail state, known warnings, and follow-up refs.
- Route again with
mdkg goal next GOAL_ID.
Multi-repo rule
Section titled “Multi-repo rule”When a parent repo uses subgraphs, mutate the child repo in the child checkout first. Commit accepted child changes before refreshing a parent-owned bundle snapshot. Root-qualified qids help avoid confusing same-number nodes across repos.
Common mistakes
Section titled “Common mistakes”- Starting edits before following the repo’s compact or legacy router, grounding the authorized goal and inspecting one scoped context pack.
- Treating
mdkg goal nextas a claim. It is read-only; usemdkg goal claim GOAL_ID WORK_IDonly after accepting the node. - Closing a task with “tests passed” when no command evidence is recorded. Include commands, pass/fail state, known warnings, and boundaries in the checkpoint.
- Mutating a child repo from a parent orchestration context. Work in the owning repo, commit accepted child changes, then refresh the parent bundle.
- Copying raw prompts, provider payloads, or secrets into checkpoints or handoffs. Keep evidence summarized and refs-only.