Skip to content

architecture/map-landscape: C4 system landscape + application-portfolio table over discovered repos #3816

Description

@kyle-sexton

Parent

Refs #3801

Agent Brief

Type: Feature
Summary: A map-landscape skill in the architecture plugin that emits a C4 System Landscape plus an application-portfolio table over a discovered set of repositories, with a thin setup skill owning the consumer's architecture declaration.

Current behavior:
No skill answers "what systems does this organization have, who owns them, what do they run on, and how do they relate". Repository-fleet discovery exists in the fleet-hygiene plugin but feeds cleanup, not an architecture view. No plugin or convention declares where a consumer keeps architecture artifacts.

Desired behavior:
A skill that discovers a set of repositories, then emits two artifacts into the consumer's declared architecture home.

Discovery, by argument (the argument selects the mode):

  1. --repos <path>[,<path>...]: exactly those repositories, no discovery.
  2. --root <dir> (repeatable): discovery. When the repo-fleet-hygiene plugin is installed it owns bounded fleet discovery and canonical-checkout resolution: invoke /repo-fleet-hygiene:audit <root>... --plan-file <memory_dir>/<topic-slug>/fleet-plan.json via the Skill tool (resolve the slug per the topic-docs binding and mkdir -p the slice first), confirm the plan's schema_version is 1, read repositories[], keep only entries whose discovered path lies under a requested root (the collaborator's config-supplied scope is additive, so an unfiltered read can chart the operator's whole configured fleet), and use canonical and remote. When the plugin is absent, or the plan file is missing or carries another schema_version: bundled walk, recurse from each root to depth 5, a .git entry is a repository and is not descended into, skip node_modules, vendor, .venv, canonical checkout = first record of git worktree list --porcelain. Announce the fallback. Announce that the collaborator's audit collects GitHub evidence and may need gh authentication.
  3. Neither argument: stop and name both forms. Never scan the session's working directory.

Facts per repository come from the helper script, run as ${CLAUDE_SKILL_DIR}/scripts/portfolio-facts.sh <repo-path>... (the anchor matters; a bare relative path resolves against the session cwd), never derived by hand. Bash, POSIX awk/grep, no grep -P; one JSON object per repository on stdout: name, path, remote, owner, runtime, target_framework, dependencies[], last_touched, evidence{}; unknown for anything underivable, never a guess. Probes, first hit wins:

  • owner: CODEOWNERS (root, .github/, docs/) default * rule's first owner → owner segment of the origin remote URL → unknown. Never commit authors.
  • runtime: *.csproj/*.fsproj/global.json → dotnet; package.json → node (or bun/deno by lockfile or config); pyproject.toml/requirements*.txt/setup.py → python; go.mod → go; Cargo.toml → rust; pom.xml/build.gradle* → jvm; Gemfile → ruby; composer.json → php; only *.sh/*.ps1 → shell; else unknown. Multiple hits list all, first is primary.
  • target_framework: <TargetFramework(s)> from the first *.csproj; engines.node; requires-python; go directive; rust-version/edition; else unknown.
  • dependencies: PackageReference/ProjectReference includes; dependencies + peerDependencies keys; [project].dependencies / requirements*.txt names; go.mod require block; Cargo.toml [dependencies]; capped at 25, sorted, deduplicated.
  • last_touched: git log -1 --format=%cI on the canonical checkout (local HEAD; nothing fetches).

Relationships are model judgment with cited evidence: an edge A → B exists only when a fact in A names B (dependency name equals B's repository name or package id, a ProjectReference/workspace path resolves into B, or B's remote URL appears in A's tracked config or README); the edge description is the matched string. No cited match, no edge.

Artifact one, <architecture_dir>/landscape.dsl when the dialect is structurizr: a workspace with a model of softwareSystem elements and -> relationships and views { systemLandscape "landscape" { include * autoLayout } }. Or <architecture_dir>/landscape.md when the dialect is mermaid: a C4Context block titled "System Landscape" with no focal system, every repository a System, grouped by Enterprise_Boundary per remote owner when more than one owner is present, Rel lines per the evidence rule, inside a mermaid fence. The skill body states that mermaid has no dedicated landscape diagram type and that upstream marks its C4 syntax experimental (source https://mermaid.js.org/syntax/c4.html, verified 2026-09-06; recheck when a mermaid release adds a landscape type or drops the notice).

Artifact two, <architecture_dir>/portfolio.md: heading, generated-on line (date and discovery source: explicit list / fleet-hygiene plan / bundled walk), one table Repository | Owner | Target framework | Runtime | Dependencies | Last touched (local HEAD), one row per repository sorted by name, unknown rendered as-is, dependencies comma-joined and truncated to 10 with (+N).

Architecture home and dialect resolve from a consumer topic doc <convention-home>/architecture/README.md carrying a fenced YAML block with architecture_dir (repo-relative, no default) and landscape_dialect (structurizr | mermaid, default mermaid). The convention home resolves through the vendored ${CLAUDE_PLUGIN_ROOT}/lib/resolve-convention-home.sh (exit 0 resolved, 1 no pointer, 2 usage, 3 FAIL); the skill runs it and follows the exit code, never parsing the root file. Ladder per key: topic doc → infer from repo evidence (an existing *.dsl → structurizr; an existing docs/architecture/ or architecture/ → that dir) → ask once → landscape_dialect defaults to mermaid; architecture_dir has no silent default: undeclared and unconfirmed (including non-interactive runs) the skill stops and points at /architecture:setup. Inference proposes; only confirmation binds. map-landscape never writes the consumer's root instruction file.

architecture:setup owns the declaration, mirroring plugins/plugin-quality/skills/setup/SKILL.md (minus its retirement records). Frontmatter: user-invocable: true, disable-model-invocation: true, NO metadata block (the cheat-sheet generator excludes every skill named setup and scripts/validate-plugins.sh fails when one carries workflow-stage/summary/cadence), and the double-quoted argument-hint: "check | apply [home=<dir>] [architecture_dir=<path>] [landscape_dialect=<structurizr|mermaid>]" (scripts/validate-plugin-contracts.mjs requires check leading and the body to document both check and apply in code spans). check is read-only: runs the resolver and prints a PASS/FAIL/INFO table with one remediation line per FAIL, covering no pointer line (resolver exit 1), a resolved home with no architecture/README.md, a topic doc with an unknown key or value, and a conforming declaration. apply converges the marked convention-home pointer region in the root instruction file (inside the markers only, preserving unrelated content, only when home= is supplied or a home is confirmed) and the architecture/README.md topic doc at the resolved home. It is idempotent; proposes inferred values and waits for confirmation when arguments are incomplete; runs non-interactively when home=, architecture_dir=, and landscape_dialect= are all supplied; and after writing re-reads and reports the stored values it observed. No retired layers.

Skill content is organization-agnostic: no organization or publisher name appears anywhere in either skill body; no Zachman or TOGAF prose; C4 and Structurizr are named as output formats only.

Key interfaces:

  • /architecture:map-landscape [--repos <a,b>] [--root <dir>]...
  • /repo-fleet-hygiene:audit ... --plan-file <path> (presence-gated; reads schema_version, repositories[].discovered, .canonical, .remote)
  • ${CLAUDE_SKILL_DIR}/scripts/portfolio-facts.sh JSON contract above
  • <convention-home>/architecture/README.md keys architecture_dir, landscape_dialect; contract documented in plugins/architecture/reference/config.md, cited from skills as ${CLAUDE_PLUGIN_ROOT}/reference/config.md (a bare reference/config.md fails skill-quality check 5)
  • /architecture:setup check | apply [home=<dir>] [architecture_dir=<path>] [landscape_dialect=<structurizr|mermaid>]

Files:

  • plugins/architecture/skills/map-landscape/SKILL.md (frontmatter as skills/improve/SKILL.md: description with "Use when:" and a "Skip when:" naming /architecture:improve and /repo-fleet-hygiene:audit, argument-hint, user-invocable: true, explicit disable-model-invocation: false, shell: bash, metadata.workflow-stage: explore, metadata.summary ≤ 100 codepoints; under 200 lines; sections: Repository context, Purpose, Resolve home and dialect, Discover repositories, Collect facts, Draw relationships, Emit artifacts with one minimal fenced example per dialect, What this skill does NOT do, Gotchas. Gotchas carry: the mermaid asymmetry and experimental notice with source and date; the owner ladder; local-HEAD last-touched; the fleet plan is a temp artifact in the memory slice, never committed)
  • plugins/architecture/skills/map-landscape/scripts/portfolio-facts.sh and portfolio-facts.test.sh (fixtures created in mktemp -d by the test: csproj with TargetFramework and two PackageReferences; package.json with engines.node and dependencies; pyproject.toml; go.mod; empty repo; repo with CODEOWNERS; repo with origin remote and no CODEOWNERS; each git init plus one commit; asserts every field, unknown on the empty repo, the dependency cap, the owner ladder order; skill-script shape per docs/conventions/shell-test-helpers/README.md)
  • plugins/architecture/skills/map-landscape/evals/evals.json plus fixtures, every fixture referenced by a case's files[]. Cases: explicit list with the collaborator absent; root with the collaborator installed; root with the collaborator absent; dialect structurizr from a topic doc; no topic doc and no inference evidence; no scope at all
  • plugins/architecture/skills/setup/SKILL.md plus evals/evals.json (setup skills are not evals-exempt). Cases: check with no pointer line (FAIL row plus remediation); check with a conforming doc (all PASS); apply with incomplete arguments proposes and waits; apply with complete arguments writes without prompting and reports the read-back values
  • plugins/architecture/lib/resolve-convention-home.sh: add the path to copies=(...) in scripts/sync-resolve-convention-home.sh, then run the script to copy; never edit the canonical copy in plugins/claude-config/lib/
  • plugins/architecture/reference/config.md (new; modelled on plugins/plugin-quality/reference/config.md, 4-backtick outer fence around the example, keys table stating architecture_dir has no default and landscape_dialect defaults to mermaid, no retired-layers section)
  • plugins/architecture/README.md ("Invoke" block, trigger phrases, a "Consumer configuration" pointer)
  • plugins/architecture/CHANGELOG.md ## [0.7.0] ### Added with a bold "New skill" lead per new skill; plugins/architecture/.claude-plugin/plugin.json version 0.7.0, extended description, keywords + c4, landscape, portfolio; .claude-plugin/marketplace.json tags kept identical to keywords
  • docs/conventions/config-cascade/README.md Implementers table: add the architecture row (path = convention doc <home>/architecture/README.md; layers = team, via pointer line; conformance = new surface under the expression doctrine, no retirement record; keys owned by the plugin's reference/config.md)
  • Regenerate docs/SKILL-CHEAT-SHEET.md and docs/CATALOG.md with scripts/generate-cheatsheet.mjs and scripts/generate-catalog.mjs; never hand-edit

Sanity checks. Run git fetch origin main first (the base ref is also CHECK_SKILL_BASE_REF). All must hold before opening the PR. Commands are given in a fenced block so nothing is markdown-escaped; the dots in the last grep stand for the backticks around the surface name (a backslash-backtick inside grep -E is a buffer-start anchor and never matches):

test -d plugins/architecture/skills/map-landscape && test -f plugins/architecture/skills/setup/SKILL.md
test -f plugins/architecture/lib/resolve-convention-home.sh && grep -q 'plugins/architecture/lib/resolve-convention-home.sh' scripts/sync-resolve-convention-home.sh && bash scripts/sync-resolve-convention-home.sh --check
! grep -qi 'melodic' plugins/architecture/skills/map-landscape/SKILL.md && ! grep -qi 'melodic' plugins/architecture/skills/setup/SKILL.md
! grep -qiE 'zachman|togaf' plugins/architecture/skills/map-landscape/SKILL.md && ! grep -qiE 'zachman|togaf' plugins/architecture/skills/setup/SKILL.md
grep -q 'repo-fleet-hygiene' plugins/architecture/skills/map-landscape/SKILL.md && grep -qi 'plugin is installed' plugins/architecture/skills/map-landscape/SKILL.md && grep -q 'systemLandscape' plugins/architecture/skills/map-landscape/SKILL.md && grep -q 'C4Context' plugins/architecture/skills/map-landscape/SKILL.md
grep -q '^## \[0.7.0\]' plugins/architecture/CHANGELOG.md && grep -q 'map-landscape' plugins/architecture/README.md && grep -q 'map-landscape' docs/SKILL-CHEAT-SHEET.md
grep -qE '^\| *.architecture. *\|' docs/conventions/config-cascade/README.md   # fails on today's main: the word does not occur in that file
bash plugins/architecture/skills/map-landscape/scripts/portfolio-facts.test.sh
shellcheck plugins/architecture/skills/map-landscape/scripts/*.sh
bash scripts/check-changed-skills.sh origin/main
bash scripts/validate-plugins.sh
bash scripts/check-skill-count-claims.sh --check
bash scripts/check-orphaned-fixtures.sh --check
bash scripts/check-changelog-parity.sh --check-bump origin/main && bash scripts/check-changelog-parity.sh --check-preserved origin/main && bash scripts/check-changelog-parity.sh --check-order
npx markdownlint-cli2 <every changed markdown file>   # 0 issues

Acceptance criteria:

  • Running the skill with --repos and the fleet-hygiene plugin absent produces both artifacts over exactly the listed repositories (manual smoke, recorded in the PR body).
  • With the fleet-hygiene plugin installed and --root given instead of an explicit list, the skill invokes its audit with --plan-file and uses the canonical repositories under that root (manual smoke, recorded in the PR body).
  • With neither --repos nor --root, the skill stops and names both forms.
  • The emitted portfolio table has one row per discovered repository and carries all five columns.
  • The emitted landscape view is a C4 System Landscape in the dialect the consumer's topic doc names (Structurizr systemLandscape, or mermaid C4Context with the stated asymmetry) (manual smoke).
  • Both artifacts are written to the declared architecture_dir; with none declared and none confirmed the skill stops and points at /architecture:setup (manual smoke).
  • architecture:setup check reports the declaration state read-only; apply converges the pointer region and topic doc idempotently, runs non-interactively with complete arguments, and reports read-back values.
  • No organization or publisher name, and no Zachman or TOGAF prose, appears in either skill's content.
  • portfolio-facts.test.sh passes and every sanity check above holds.
  • bash scripts/check-changed-skills.sh origin/main passes for both new skills.
  • markdownlint passes on the changed files.
  • The architecture plugin version is 0.7.0 with a matching CHANGELOG entry.
  • The architecture plugin README, reference/config.md, the config-cascade Implementers row, and the regenerated cheat sheet and catalog document the new skills.

Out of scope:

  • Baseline-versus-target gap analysis.
  • Container-level or component-level C4 views.
  • Modifying any discovered repository.
  • Any write to the consumer's root instruction file outside the marked convention-home region.
  • Capability maps and work-breakdown structures.

Amendment note (2026-09-06, planning slice #3807)

This body is the worker's complete contract. The planner's record (docs/topics/cross-repo-landscape/PLAN.md on branch plan/3807-cross-repo-landscape) is contract-tier and never merges, so it is not reachable from a branch cut from main; nothing in it is needed beyond what is here. Changes from the original brief: (1) criterion 2 reworded, /repo-fleet-hygiene:audit stops without a scope, so "no explicit list" means a --root scan root, not no argument, and an explicit list bypasses discovery outright; (2) the "declared architecture home" mechanism did not exist and is created here as a convention doc plus a required architecture:setup skill whose apply converges the pointer region like the pilot's (plugin philosophy: a consumer configuration surface requires setup); (3) mermaid has no landscape diagram type, so the mermaid output is a C4Context with the asymmetry stated; (4) the facts collector is a tested script; (5) the fleet plan read is filtered to the requested roots because the collaborator's configured scope is additive; (6) criteria no repository gate can verify are marked manual smoke.

Blocked by

Metadata

Metadata

Assignees

Labels

agent-readyneeds-triage

Fields

No fields configured for Feature.

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions