> built 2026-11-24 01:19 UTC from e9c82cd (main) · opsward 0.0.46. Details: build_info.json

# index.html.md

<!-- generated by epythet -->

# opsward

Diagnose, generate, and maintain the AI agent setup of your projects —
CLAUDE.md, skills, subagents, rules, and supporting docs.

Opsward works in two modes:

- **CLI mode** — deterministic, pure-code analysis you run directly. No AI involved.
- **Claude Code mode** — install opsward as Claude Code skills so that Claude runs the
  CLI tools, interprets results intelligently, and acts on suggestions. No API keys
  needed — Claude Code is the AI engine.

## Install

```bash
pip install opsward
```

---

## CLI Mode (no AI)

These commands are deterministic Python code — regex scoring, filesystem checks,
template substitution. Same input always gives the same output.

### Diagnose

Score your project’s AI setup health:

```bash
opsward diagnose .
```

```default
Diagnosis Report: myproject
Project type: python
Overall score: 72/100  (Grade: C)

Components:
  CLAUDE.md quality         [################....] 81/100
  Documentation             [##############......] 70/100
  Skills                    [############........] 60/100
  Setup (rules/agents/hooks) [##########..........] 50/100
  Cross-references          [####################] 100/100

Missing:
  [ ] docs_guide.md
  [ ] docs/known_issues.md

Suggestions:
  1. Create a docs_guide.md to index your documentation
  2. Consider adding hooks in .claude/hooks.json
```

### Generate

Create missing artifacts (dry run by default):

```bash
opsward generate .
opsward generate . --write   # actually create files
```

Generates CLAUDE.md, docs (architecture, conventions, known_issues, etc.),
skill templates, and agents — only what’s missing, never overwrites existing files.

### Maintain

Find stale references and drift:

```bash
opsward maintain .
```

```default
myproject: 3 issue(s)

  [stale_path → align] CLAUDE.md references `src/old_module.py` but it does not exist
  [sync_issue → align] `new_doc.md` exists in docs/ but is not listed in docs_guide.md
  [empty_doc → align] `conventions.md` appears to be an empty stub (12 bytes)
```

Each finding carries a recommended triage: **align** (the code is right, update the config), **revert** (the config is right, restore the code) or **ignore** (the reference is legitimately volatile). To ignore one, put `<!-- opsward: ignore-path -->` at the end of its line, or alone on the line before it; every path check (stale paths, the currency score, cross-references, ADR drift) then skips it.

**Config changelog** (opt-in): create `config_changelog.md` in the docs folder and give every change to the agent config (CLAUDE.md, AGENTS.md, `.claude/`) one dated line, newest first, saying what changed and why, e.g. `- 2026-10-20: moved the CLI-golden procedure out of CLAUDE.md (over budget); align`. Once the file exists, `opsward maintain` reports a `config_changelog` finding whenever a config commit is newer than the last changelog commit.

### Fleet

Diagnose many repos at once and roll the results up (grades, what is missing where, the weakest components, the worst repos):

```bash
opsward fleet ~/proj/a ~/proj/b            # explicit roots
opsward fleet --under ~/proj --depth 2     # every git repo under a folder
opsward fleet --under ~/proj --manifest ~/.local/share/opsward/fleet.json
opsward fleet --manifest ~/.local/share/opsward/fleet.json   # re-run the remembered fleet
```

`--manifest` remembers the fleet: it writes the roots and the latest name-keyed summary to that JSON file. The roots are this machine’s paths, so keep the manifest out of version control (opsward warns when it sits in a git work tree unignored).

### Weekly look

Where `diagnose` scores a package’s static setup, `opsward weekly` reads how agents actually behaved, from this machine’s Claude Code transcripts, and prints five numbers over the last 30 days with last run’s values beside them: new source files written after a fleet search, skills never invoked, package CLAUDE.md loaded before edit, `Component:` issues filed per week (through `gh`), and corrections written back (the fix-at-source hook’s event log). It ends with one proposed target condition, the number that got worse the most. Report-only: you pick the change.

```bash
opsward weekly                  # a markdown page; records this run under ~/.local/share/opsward/weekly
opsward weekly --days 7 --format json --no-save
```

Only metadata is read (tool names, paths, skill names, times), never prompt or file text. In Python, `opsward.weekly.weekly(...)` takes every source as a keyword argument.

### Memory audit

Claude Code’s auto-memory is kept per working directory, so a correction that holds for every project, once saved as a `feedback` memory in one folder, loads only there. `opsward memory-audit` lists those memories and, for each one, says whether it reads as project-specific or fleet-wide (and why), which memories in other folders say nearly the same thing, which skill (or `~/.claude/CLAUDE.md`) should own a fleet-wide one and whether it already says it, and which memories are stubs that only point elsewhere. Report-only: it never moves or deletes a memory.

```bash
opsward memory-audit                          # feedback memories, as a markdown table
opsward memory-audit --kinds feedback,user --format json
```

The scope test is a heuristic (it looks for habit wording and for the project’s own name). In Python, `opsward.memory_audit.audit(classify=...)` takes a judge instead, and `similarity=` takes another duplicate measure.

### Output Formats

All CLI commands support `--format json` for machine-parseable output:

```bash
opsward diagnose . --format json
opsward generate . --format json
opsward maintain . --format json
```

---

## Claude Code Mode (AI-enhanced)

Install opsward’s skills into Claude Code, and Claude becomes an intelligent
layer on top of the deterministic tools. It doesn’t just run opsward — it goes
beyond the heuristic scores by reading actual source code, reasoning about
accuracy, and making intelligent edits.

### Install Skills

```bash
opsward install-skills --write                    # into ./.claude/ (project-level)
opsward install-skills --global-install --write   # into ~/.claude/ (all projects)
```

### What the Skills Do

Once installed, these skills activate automatically in Claude Code when you ask
the right thing:

| Skill              | Trigger                     | What it does                                                                           |
|--------------------|-----------------------------|----------------------------------------------------------------------------------------|
| `opsward`          | “check my setup”, “opsward” | Diagnose → decide next step → generate or maintain → re-diagnose                       |
| `opsward-diagnose` | “audit my AI config”        | Run `opsward diagnose`, then read code to assess semantic quality, offer fixes         |
| `opsward-generate` | “scaffold AI setup”         | Run `opsward generate`, then read the codebase and replace templates with real content |
| `opsward-maintain` | “check for staleness”       | Run `opsward maintain`, then check for semantic drift (docs that no longer match code) |

### How It Works

1. **Opsward CLI** runs deterministic checks (regex scoring, path validation, template substitution) — fast, reproducible, no AI
2. **Claude reads the output** and adds deeper analysis: reads actual source code, checks if docs match reality, verifies commands are correct
3. **Claude proposes fixes** — not just what opsward suggests, but what it discovers by understanding the code
4. **Claude applies fixes** with user approval, then re-runs opsward to show improvement

The CLI provides the structural analysis. Claude provides the semantic understanding and action.

### Permissions

The skills use Claude Code’s standard permission model — no special permissions are
assumed or required:

- **Read-only operations** (reading files, searching code, running `opsward diagnose`): always safe, used freely
- **Write operations** (creating docs, editing CLAUDE.md): Claude Code prompts the user for each action per their permission settings
- **Destructive operations** (deleting files, removing content): always ask for explicit confirmation

If you want faster workflows (e.g., auto-approve file creation during generation),
you can configure that in your Claude Code permission settings — but opsward skills
never assume it.

---

## What It Checks

**CLAUDE.md quality** (6 dimensions):

- Commands & workflows — are build/test/lint commands documented?
- Architecture clarity — is there a module map with role descriptions?
- Conventions — are project-specific style rules present?
- Conciseness — is the file scannable, not bloated?
- Currency — do referenced paths actually exist?
- Actionability — are instructions specific enough to act on?

**Documentation completeness**: docs_guide.md, architecture.md, conventions.md,
known_issues.md, and content quality.

**Skills & agents**: SKILL.md presence, descriptions, setup-auditor agent.

**Cross-references**: paths in CLAUDE.md validated against the filesystem.

**Portability**: sections where a render (CLAUDE.md, GEMINI.md, …) drifts from AGENTS.md, 10 points each; never how many hosts a repo covers. Without an AGENTS.md it is not scored and its weight goes to CLAUDE.md quality (ADR 0012).

**Overall health**: weighted score (A–F grade) combining all components.

**Security advisories** (reported, never scored; modelled on the OWASP Top 10 for agentic applications): unrestricted Bash in a skill’s `allowed-tools` or in `permissions.allow`, `bypassPermissions`, a download piped into a shell, `eval` of a built string, unpinned `npx`/`uvx` packages in hooks and MCP servers, text that tries to override the agent’s other instructions, and committed credentials. They are heuristics, so they never move the grade or fail `--min-score`.

## Python API

```python
from pathlib import Path
from opsward import scan, diagnose, generate, generate_skills, maintain
from opsward import recommend_skills, validate_skill_spec

sr = scan(".")
report = diagnose(sr)
print(report)  # human-readable report card
print(report.grade)  # 'A', 'B', 'C', 'D', or 'F'

files = generate(sr)  # list[GeneratedFile]
issues = maintain(sr)  # list[MaintenanceSuggestion]

# Recommend ecosystem skills based on tech stack
recs = recommend_skills(sr)  # list[SkillRecommendation]

# Validate skills against agentskills.io spec
for skill in sr.skills:
    violations = validate_skill_spec(skill)

# Install skills programmatically
skill_files = generate_skills(Path.home() / ".claude")
```

### Evals (opt-in, report-only)

The rubric scores form; evals ask whether a config actually helps. They make model calls, so they never gate and never run by default:

```python
from pathlib import Path
from opsward.evals import (
    judge_claude_md,
    anthropic_judge,
    run_golden_tasks,
    GoldenTask,
    anthropic_agent,
)

# LLM-as-judge for the subjective dimensions (actionability, conciseness), next to the rubric's score
print(
    judge_claude_md(Path("CLAUDE.md").read_text(), judge=anthropic_judge(), samples=3)
)

# Golden tasks: does the agent honour a convention with the config, and not without it?
tasks = [GoldenTask("kw-only", "Write a function f(a, b, c).", expect=[r"\*,"])]
print(
    run_golden_tasks(
        tasks, agent=anthropic_agent(), config=Path("CLAUDE.md").read_text(), runs=3
    )
)
```

`pip install 'opsward[eval]'` for the paid judge and agent. Without them, `judge_claude_md` defaults to `rubric_judge` (opsward’s own rubric, free) and `echo_agent` exercises the golden-task harness without a model.

From the shell, `opsward eval` runs both and exits 0 whenever it ran (a report, never a gate; 2 on a usage error). It finds a repo’s golden tasks at `<docs>/evals/golden_tasks.json` (`misc/docs/` for Python, `docs/` for JS/TS) unless `--tasks` names a file:

```bash
opsward eval .                                   # free: the rubric judge and the echo agent
opsward eval . --judge anthropic --samples 3     # paid model calls (pip install 'opsward[eval]')
opsward eval . --tasks evals.json --runs 5 --format json
```

## CI Integration

Use opsward in CI to enforce AI setup quality:

```bash
# Fail if overall score drops below 60
opsward diagnose . --min-score 60

# Machine-parseable output for CI tooling
opsward diagnose . --format json --min-score 60
```

```yaml
# .github/workflows/ai-setup-check.yml
name: AI Setup Check
on: [pull_request]
jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: "3.12"
      - run: pip install opsward
      - run: opsward diagnose . --min-score 60
```

Two gates, for two jobs: `diagnose --min-score` is the cheap scored gate, and `lint` is the strict one, pass or fail with no score. `lint` checks every project skill against the agentskills.io spec and the hooks config for shapes Claude Code silently ignores, and exits 1 on any finding:

```bash
opsward lint .                          # opsward's own spec check, plus skill.validate() when installed
opsward lint . --validators opsward     # only opsward's check
pip install 'opsward[lint]'             # adds the `skill` package's validate()
# external linters, opt-in by name (opsward does not install them; `auto` never runs them):
npm install -g agnix                    # --validators agnix
pip install skillcheck                  # --validators skillcheck
pip install skillsaw                    # --validators skillsaw (adds a skill-description token budget)
```

One brief for every agent host: `AGENTS.md` is the canonical, and each host’s own file (`CLAUDE.md`, `GEMINI.md`, `.github/copilot-instructions.md`, …) is a symlink, an `@AGENTS.md` import, or a copy that can drift. `portability` shows which hosts find instructions and every section where a render differs from `AGENTS.md`; `fleet` rolls the same counts up across repos. With `opsward[lint]` installed, `portability` also lists project skills rendered for a host whose format drops some of their fields (`allowed-tools`, `license`, bundled resources): the `lossy` kind, reported and never scored. A `CLAUDE.md` that is `@AGENTS.md` plus Claude-only deltas is scored as Claude reads it, with the import inlined.

```bash
opsward portability .                   # host coverage table + drift findings (report-only)
opsward portability . --format json
```

The repo ships a reusable GitHub Action and pre-commit hooks:

```yaml
# a workflow step, after actions/checkout
- uses: addaix/opsward@<a release tag>
  with:
    min-score: "70"   # "" skips the scored gate
    lint: "true"
```

```yaml
# .pre-commit-config.yaml
- repo: https://github.com/addaix/opsward
  rev: <a release tag>
  hooks:
    - id: opsward-lint
    - id: opsward-diagnose
      args: [--min-score, "70"]
```

## Related Work

| Project                                                                                  | Relationship                                                                     |
|------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------|
| [spec-kit](https://github.com/github/spec-kit) (GitHub)                                  | Template-based scaffolding for 20+ AI agents. No diagnosis/scoring/maintenance.  |
| [claude-code-skill-factory](https://github.com/alirezarezvani/claude-code-skill-factory) | Inside-agent builders for skills, agents, hooks. Good for interactive authoring. |
| [ccexp](https://github.com/nyatinte/ccexp)                                               | Interactive TUI for browsing Claude Code config files. Complements opsward.      |
| [npx skills](https://github.com/vercel-labs/skills) (Vercel)                             | Cross-platform skill package manager. Opsward-generated skills are compatible.   |
| [awesome-agent-skills](https://github.com/VoltAgent/awesome-agent-skills)                | 549+ community skills from official dev teams.                                   |
| [awesome-claude-code](https://github.com/hesreallyhim/awesome-claude-code)               | Best single index of the Claude Code ecosystem.                                  |
| [wshobson/agents](https://github.com/wshobson/agents)                                    | Pre-built plugin monorepo (72 plugins, 112 agents, 146 skills).                  |
| [Mintlify skill.md](https://www.mintlify.com/blog/skill-md)                              | Auto-generates skill.md from docs sites. Same philosophy, different input.       |
<p class="epythet-aggregates">This documentation as a single file: <a href="opsward.md">opsward.md</a> (Markdown, for agents).</p>


# _autosummary/opsward.base.html.md

# opsward.base

All dataclasses and type definitions for opsward.

### Classes

| [`AgentInfo`](_autosummary/opsward.base.html.md#opsward.base.AgentInfo)(name, path[, description])            | An agent found in .claude/agents/.                                 |
|--------------------------------------------------------------------------------------------------|--------------------------------------------------------------------|
| [`ComponentScore`](_autosummary/opsward.base.html.md#opsward.base.ComponentScore)(name, score[, max_score, notes]) | Score for a single component (0–100) with optional notes.          |
| [`DiagnosisReport`](_autosummary/opsward.base.html.md#opsward.base.DiagnosisReport)(project_root, project_type)     | Report card produced by scoring a ScanResult.                      |
| [`DocSpec`](_autosummary/opsward.base.html.md#opsward.base.DocSpec)(name, path[, size_bytes])               | A document found in the docs directory.                            |
| [`GeneratedFile`](_autosummary/opsward.base.html.md#opsward.base.GeneratedFile)(target_path, content[, ...])      | A file to be written by the generate step.                         |
| [`MaintenanceSuggestion`](_autosummary/opsward.base.html.md#opsward.base.MaintenanceSuggestion)(category, description)    | A single maintenance action proposed by maintain.py.               |
| [`ProjectType`](_autosummary/opsward.base.html.md#opsward.base.ProjectType)(\*values)                           | Detected project type.                                             |
| [`RuleInfo`](_autosummary/opsward.base.html.md#opsward.base.RuleInfo)(name, path[, content])                 | A rule found in .claude/rules/.                                    |
| [`ScanResult`](_autosummary/opsward.base.html.md#opsward.base.ScanResult)(project_root[, project_type, ...])   | Everything we learned by reading (never writing) a target project. |
| [`SkillInfo`](_autosummary/opsward.base.html.md#opsward.base.SkillInfo)(name, path[, has_skill_md, ...])      | A skill found in .claude/skills/.                                  |

### *class* opsward.base.AgentInfo(name, path, description='')

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

An agent found in .claude/agents/.

### *class* opsward.base.ComponentScore(name, score, max_score=100, notes=list())

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

Score for a single component (0–100) with optional notes.

### *class* opsward.base.DiagnosisReport(project_root, project_type, scores=list(), missing_items=list(), suggestions=list(), weighted_score=None, advisories=list(), portability=None)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

Report card produced by scoring a ScanResult.

#### *property* grade *: [str](https://docs.python.org/3/builtins/stdtypes.html#str)*

A (90-100), B (80-89), C (70-79), D (60-69), F (<60).

* **Type:**
  Letter grade

#### *property* overall_score *: [float](https://docs.python.org/3/builtins/functions.html#float)*

Weighted score if set (0.0 included), else simple average.

### *class* opsward.base.DocSpec(name, path, size_bytes=0)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

A document found in the docs directory.

### *class* opsward.base.GeneratedFile(target_path, content, overwrite_policy='skip')

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

A file to be written by the generate step.

### *class* opsward.base.MaintenanceSuggestion(category, description, diff='', triage='')

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

A single maintenance action proposed by maintain.py.

### *class* opsward.base.ProjectType(\*values)

Bases: [`Enum`](https://docs.python.org/3/library/enum.html#enum.Enum)

Detected project type.

### *class* opsward.base.RuleInfo(name, path, content='')

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

A rule found in .claude/rules/.

### *class* opsward.base.ScanResult(project_root, project_type=ProjectType.unknown, claude_md_path=None, claude_md_content='', skills=list(), agents=list(), rules=list(), hooks_path=None, hooks_config=None, docs=list(), has_docs_guide=False, docs_guide_path=None, agents_md_path=None, agents_md_content='', host_files=dict(), is_monorepo=False, monorepo_packages=list(), decisions=list(), global_skills=list(), global_skills_dir=None)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

Everything we learned by reading (never writing) a target project.

### *class* opsward.base.SkillInfo(name, path, has_skill_md=False, description='', frontmatter=dict(), line_count=0, is_link=False, real_path=None, canonical_path=None)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

A skill found in .claude/skills/.


# _autosummary/opsward.cli.html.md

# opsward.cli

CLI dispatch for opsward.

### Functions

| [`diagnose`](_autosummary/opsward.cli.html.md#opsward.cli.diagnose)(\*project_roots[, format, verbose, ...])   | Diagnose the AI agent setup of one or more projects.                                                   |
|------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------|
| [`eval_`](_autosummary/opsward.cli.html.md#opsward.cli.eval_)(project_root, \*[, judge, samples, ...])      | Report-only evals of a project's agent setup: an LLM judge of CLAUDE.md, and golden tasks.             |
| [`find`](_autosummary/opsward.cli.html.md#opsward.cli.find)(query, \*project_roots[, kinds, ...])          | Find assets (skills, agents, docs) across one or more projects by QUERY.                               |
| [`fleet`](_autosummary/opsward.cli.html.md#opsward.cli.fleet)(\*project_roots[, under, depth, ...])         | Diagnose many projects at once and roll the results up into one fleet report.                          |
| [`generate`](_autosummary/opsward.cli.html.md#opsward.cli.generate)(\*project_roots[, write, format, ...])     | Generate missing AI setup artifacts for one or more projects.                                          |
| [`install_skills`](_autosummary/opsward.cli.html.md#opsward.cli.install_skills)([target, global_install, ...])       | Install opsward's Claude Code skills (and agents) into a project or globally.                          |
| [`lint`](_autosummary/opsward.cli.html.md#opsward.cli.lint)(\*project_roots[, validators, format])         | Check skill specs and the hooks config: pass or fail, no score (exit 1 on any finding).                |
| [`maintain`](_autosummary/opsward.cli.html.md#opsward.cli.maintain)(\*project_roots[, format])                 | Check for stale references, out-of-sync docs, and other drift.                                         |
| [`memory_audit`](_autosummary/opsward.cli.html.md#opsward.cli.memory_audit)([kinds, format])                       | List auto-memories that hold fleet-wide rules, and propose who should own each.                        |
| [`new`](_autosummary/opsward.cli.html.md#opsward.cli.new)(title[, write, project_root, status, ...])      | Allocate the next numbered ADR for TITLE (dry run unless --write; never overwrites).                   |
| [`note`](_autosummary/opsward.cli.html.md#opsward.cli.note)(text[, write, project_root])                   | Append TEXT as a dated one-line decision (a Y-statement) to decisions/log.md (dry run unless --write). |
| [`portability`](_autosummary/opsward.cli.html.md#opsward.cli.portability)(\*project_roots[, format])              | Show which agent hosts find project instructions, and how renders drift from AGENTS.md.                |
| [`recommend`](_autosummary/opsward.cli.html.md#opsward.cli.recommend)(\*project_roots[, format])                | Recommend ecosystem skills based on the project's tech stack.                                          |
| [`weekly`](_autosummary/opsward.cli.html.md#opsward.cli.weekly)([days, format, no_save])                     | Print the agent setup's five numbers over the last DAYS, and one proposed change.                      |

### opsward.cli.diagnose(\*project_roots, format='text', verbose=False, min_score=80)

Diagnose the AI agent setup of one or more projects.

* **Parameters:**
  * **project_roots** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – one or more paths to project directories
  * **format** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – output format — ‘text’ or ‘json’
  * **verbose** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – show additional detail in text output
  * **min_score** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – minimum overall score to pass (exit 0); below this exits 1

### opsward.cli.eval_(project_root, , judge='rubric', samples=1, tasks='', runs=1, format='text')

Report-only evals of a project’s agent setup: an LLM judge of CLAUDE.md, and golden tasks.

The judge scores CLAUDE.md’s subjective dimensions next to the rubric’s own score. The
golden tasks (a JSON list of {name, prompt, expect, forbid}, by default
<docs>/evals/golden_tasks.json) run with and without CLAUDE.md and report the pass-rate
delta. –judge rubric is free and deterministic (the rubric judge and an agent that
quotes the config: it checks the harness, not a model); –judge anthropic makes paid
calls (pip install ‘opsward[eval]’). Exits 0 whenever it ran (a report, never a gate);
2 only on a usage error.

* **Parameters:**
  * **project_root** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – the project directory
  * **judge** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – ‘rubric’ (free) or ‘anthropic’ (paid model calls)
  * **samples** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – judge samples per dimension (the median is reported)
  * **tasks** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – golden-tasks JSON file (default: <docs>/evals/golden_tasks.json, if present)
  * **runs** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – runs per golden task and arm
  * **format** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – output format — ‘text’ or ‘json’

### opsward.cli.find(query, \*project_roots, kinds='skill,agent', semantic=False, limit=10)

Find assets (skills, agents, docs) across one or more projects by QUERY.

Cross-repo asset discovery via the toolery package
(install with: pip install ‘opsward[discovery]’).

* **Parameters:**
  * **query** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – search query
  * **project_roots** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – one or more project directories (default: current dir)
  * **kinds** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – comma-separated asset kinds — skill, agent, doc
  * **semantic** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – use toolery’s ir semantic backend (needs toolery[ir])
  * **limit** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – max results to show

### opsward.cli.fleet(\*project_roots, under='', depth=1, format='text', manifest='')

Diagnose many projects at once and roll the results up into one fleet report.

The fleet is the given roots, plus the git repos found under –under. With –manifest
the fleet is remembered: the roots and the latest summary are written to that JSON
file, and a later run with only –manifest re-diagnoses the same roots (given roots or
–under replace them). The manifest holds this machine’s absolute paths, so keep it
out of version control. Exits 1 when any root could not be diagnosed.

* **Parameters:**
  * **project_roots** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – project directories to diagnose
  * **under** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – also diagnose every git repo found under this directory
  * **depth** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – how many levels below –under to look for git repos
  * **format** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – output format — ‘text’ or ‘json’ (the name-keyed summary)
  * **manifest** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – JSON file that remembers the fleet’s roots and its latest summary

### opsward.cli.generate(\*project_roots, write=False, format='text', agents_md=False, hooks=False)

Generate missing AI setup artifacts for one or more projects.

By default, shows what would be created (dry run). Use –write to
actually write files. Existing files are never overwritten.

* **Parameters:**
  * **project_roots** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – one or more paths to project directories
  * **write** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – actually write files (default: dry run)
  * **format** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – output format — ‘text’ or ‘json’
  * **agents_md** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – also generate AGENTS.md (cross-platform agent instructions)
  * **hooks** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – also generate starter hook scripts

### opsward.cli.install_skills(target='.', , global_install=False, agents=True, write=False)

Install opsward’s Claude Code skills (and agents) into a project or globally.

By default, shows what would be created (dry run). Use –write to
actually write files. Existing files are never overwritten.

* **Parameters:**
  * **target** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – project directory (ignored when –global is set)
  * **global_install** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – install into ~/.claude/ instead of the project
  * **agents** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – also install agent definitions (default: True)
  * **write** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – actually write files (default: dry run)

### opsward.cli.lint(\*project_roots, validators='auto', format='text')

Check skill specs and the hooks config: pass or fail, no score (exit 1 on any finding).

The strict counterpart of `diagnose --min-score`, for CI and pre-commit. Validators:
opsward (its own agentskills.io check, always there), skill (the skill package’s
validate(); pip install ‘opsward[lint]’), and the external agnix and skillcheck
linters (opt-in by name). auto runs opsward and skill, each when installed.

* **Parameters:**
  * **project_roots** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – one or more project directories (default: current dir)
  * **validators** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – ‘auto’, or a comma list of: opsward, skill, agnix, skillcheck
  * **format** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – output format — ‘text’ or ‘json’

### opsward.cli.maintain(\*project_roots, format='text')

Check for stale references, out-of-sync docs, and other drift.

Each finding carries a recommended triage: align (update the config to match the
code), revert (restore the code the config describes) or ignore (a legitimately
volatile reference: put `opsward: ignore-path` on its line).

* **Parameters:**
  * **project_roots** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – one or more paths to project directories
  * **format** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – output format — ‘text’ or ‘json’

### opsward.cli.memory_audit(kinds='feedback', format='text')

List auto-memories that hold fleet-wide rules, and propose who should own each.

Reads this machine’s Claude Code auto-memory (~/.claude/projects/ */memory/*.md). For
each memory: project or fleet scope (with the reason), near-duplicates in other folders,
for a fleet-wide one the skill or ~/.claude/CLAUDE.md that should hold it and whether it
already does, and stubs that only point elsewhere. Report-only: nothing is changed.

* **Parameters:**
  * **kinds** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – comma-separated memory kinds (user, feedback, project, reference)
  * **format** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – output format — ‘text’ (a markdown page) or ‘json’

### opsward.cli.new(title, write=False, project_root='.', status='Proposed', evidence='')

Allocate the next numbered ADR for TITLE (dry run unless –write; never overwrites).

* **Parameters:**
  * **title** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – the decision’s title; the file name is derived from it
  * **write** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – actually write the file (default: dry run)
  * **project_root** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – the project directory (default: current dir)
  * **status** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – initial status — Proposed (default), or Accepted when the human has accepted it
  * **evidence** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – the issue, discussion or PR this rests on (a URL or #N)

### opsward.cli.note(text, write=False, project_root='.')

Append TEXT as a dated one-line decision (a Y-statement) to decisions/log.md (dry run unless –write).

* **Parameters:**
  * **text** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – the decision: “In the context of …, facing …, we decided for …, because …”
  * **write** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – actually append (default: dry run); the log is created from its template when missing
  * **project_root** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – the project directory (default: current dir)

### opsward.cli.portability(\*project_roots, format='text')

Show which agent hosts find project instructions, and how renders drift from AGENTS.md.

One row per host (claude, codex, copilot, cursor, …) with how it is covered:
symlink, import (an @AGENTS.md shim), native (reads AGENTS.md itself), copy, rules,
or none. Then every section where a render differs from AGENTS.md, and (with
opsward[lint]) every project skill whose render drops fields. Report-only.

* **Parameters:**
  * **project_roots** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – one or more project directories (default: current dir)
  * **format** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – output format — ‘text’ or ‘json’

### opsward.cli.recommend(\*project_roots, format='text')

Recommend ecosystem skills based on the project’s tech stack.

Analyzes dependencies and suggests skills from the community catalog.

* **Parameters:**
  * **project_roots** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – one or more paths to project directories
  * **format** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – output format — ‘text’ or ‘json’

### opsward.cli.weekly(days=30, format='text', no_save=False)

Print the agent setup’s five numbers over the last DAYS, and one proposed change.

Search before write, skills never invoked, package CLAUDE.md loaded before edit,
component issues per week, corrections written back: read from this machine’s Claude
Code transcripts, its skills folder, `gh` and the fix-at-source event log, compared
with the last run (kept in ~/.local/share/opsward/weekly). Report-only: the change is
yours to pick.

* **Parameters:**
  * **days** ([`float`](https://docs.python.org/3/builtins/functions.html#float)) – the window, in days
  * **format** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – output format — ‘text’ (a markdown page) or ‘json’
  * **no_save** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – do not record this run as the next one’s “last time”


# _autosummary/opsward.data.html.md

# opsward.data

Bundled package resources for opsward, accessed via `importlib.resources.files("opsward.data")`.

Holds the generation templates (under `templates/`) and any other static
assets the generator installs into target projects. Never hardcode filesystem
paths to these resources – resolve them through `importlib.resources`.

### Modules

| [`templates`](_autosummary/opsward.data.templates.html.md#module-opsward.data.templates)   | Generation templates organized by target project type.   |
|--------------------------------------------------------------------------------------------|----------------------------------------------------------|


# _autosummary/opsward.data.templates.html.md

# opsward.data.templates

Generation templates organized by target project type.

`shared/` holds templates (and installable Claude Code skills) that apply to
any project; `python/` and `jsts/` hold language-specific variants. The
generator reads these via `importlib.resources` and substitutes
`${variable}` placeholders (`string.Template`) before writing to a target.


# _autosummary/opsward.decisions.html.md

# opsward.decisions

Decision capture: numbered ADRs, the one-line decision log, and their drift.

Two tiers, per ADR 0010 and `misc/docs/research/adr_and_home_finding.md`: a
trivial or medium decision is one **Y-statement** line appended to `decisions/log.md`
(“In the context of …, facing …, we decided for …, to achieve …, accepting …,
because …”); a load-bearing, expensive-to-reverse one is a numbered **MADR** file
`decisions/NNNN-slug.md` that is never edited once accepted, only superseded.

Pure functions here; the CLI (`opsward decision new|note`) is the only writer, and
it never overwrites. `maintain` uses [`check_decisions()`](_autosummary/opsward.decisions.html.md#opsward.decisions.check_decisions) to report an ADR that
cites a path which no longer exists, or that has no Status, which is how rot shows up.

### Functions

| [`adr_files`](_autosummary/opsward.decisions.html.md#opsward.decisions.adr_files)(decisions_dir)                         | The numbered ADR files in *decisions_dir*, in number order (the template is not one).                                                                   |
|---------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|
| [`check_decisions`](_autosummary/opsward.decisions.html.md#opsward.decisions.check_decisions)(sr)                              | `maintain` check: ADRs citing paths that no longer exist, or carrying no status.                                                                        |
| [`cited_paths`](_autosummary/opsward.decisions.html.md#opsward.decisions.cited_paths)(content)                             | Paths an ADR cites as current, outside fenced code: bare path tokens and Markdown link targets (relative ones only; URLs and host names are not paths). |
| [`clean_title`](_autosummary/opsward.decisions.html.md#opsward.decisions.clean_title)(title)                               | One line, single-spaced; empty is an error the CLI reports.                                                                                             |
| [`decision_docs`](_autosummary/opsward.decisions.html.md#opsward.decisions.decision_docs)(sr)                                | The ADRs a scan found (`ScanResult.decisions`), numbered files only.                                                                                    |
| [`log_append`](_autosummary/opsward.decisions.html.md#opsward.decisions.log_append)(decisions_dir, text, \*[, date])      | The log file and the full content it should hold after appending *text*.                                                                                |
| [`log_entry`](_autosummary/opsward.decisions.html.md#opsward.decisions.log_entry)(text, \*[, date])                      | One Y-statement line for `decisions/log.md`.                                                                                                            |
| [`new_adr`](_autosummary/opsward.decisions.html.md#opsward.decisions.new_adr)(decisions_dir, title, \*[, status, ...]) | The next numbered ADR for *title*, rendered from the `adr.md` template.                                                                                 |
| [`next_number`](_autosummary/opsward.decisions.html.md#opsward.decisions.next_number)(decisions_dir)                       | One more than the highest numbered ADR, so numbers never collide (1 for an empty dir).                                                                  |
| [`slugify`](_autosummary/opsward.decisions.html.md#opsward.decisions.slugify)(title)                                   | A file-name slug: lowercase, hyphens, nothing else, at most 60 characters.                                                                              |
| [`status_of`](_autosummary/opsward.decisions.html.md#opsward.decisions.status_of)(content)                               | The ADR's status text, from a `## Status` heading, a `**Status:**` line or MADR front matter; `None` when there is none.                                |

### opsward.decisions.adr_files(decisions_dir)

The numbered ADR files in *decisions_dir*, in number order (the template is not one).

* **Return type:**
  [`Iterator`](https://docs.python.org/3/library/typing.html#typing.Iterator)[[`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)]

### opsward.decisions.check_decisions(sr)

`maintain` check: ADRs citing paths that no longer exist, or carrying no status.

Rot in a decision record is a path that moved: the rationale still reads well and
points at nothing. Superseded, deprecated and rejected ADRs are history and are not
checked for paths: the superseding record is where the current paths live. This
reports; it never rewrites an accepted ADR (ADR 0010).

* **Return type:**
  [`Iterable`](https://docs.python.org/3/library/typing.html#typing.Iterable)[[`MaintenanceSuggestion`](_autosummary/opsward.base.html.md#opsward.base.MaintenanceSuggestion)]

### opsward.decisions.cited_paths(content)

Paths an ADR cites as current, outside fenced code: bare path tokens and Markdown
link targets (relative ones only; URLs and host names are not paths).

A path the record cites as history is not checked: wrap it in `~~strikethrough~~`,
or say so on the line (`formerly`, `previously`, `moved`, `migrated`,
`renamed`, `replaced`, `removed`, `retired`, `deleted`), as in “we moved `pkg/old.py` to `pkg/new.py`” — there
only `pkg/new.py` must exist.

```pycon
>>> cited_paths("See `pkg/a.py`, [0002](0002-x.md), [doc](../research/r.md), https://x.io/a/b.py, docs.github.com/en/x.md\n```\nsrc/in/fence.py\n```")
['../research/r.md', '0002-x.md', 'pkg/a.py']
>>> cited_paths("We moved `pkg/old.py` to `pkg/new.py`; ~~`pkg/gone.py`~~ is history.")
['pkg/new.py']
>>> cited_paths("It was read from `pkg/live.py`.\nRenamed [old](../old.md) to [new](../new.md).")
['../new.md', 'pkg/live.py']
```

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

### opsward.decisions.clean_title(title)

One line, single-spaced; empty is an error the CLI reports.

```pycon
>>> clean_title("  two\n lines ")
'two lines'
```

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### opsward.decisions.decision_docs(sr)

The ADRs a scan found (`ScanResult.decisions`), numbered files only.

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`DocSpec`](_autosummary/opsward.base.html.md#opsward.base.DocSpec)]

### opsward.decisions.log_append(decisions_dir, text, , date=None)

The log file and the full content it should hold after appending *text*.

A missing log starts from the `log.md` template. The existing log is read
strictly: an unreadable or non-UTF-8 log raises (`OSError` /
`UnicodeDecodeError`) rather than being replaced by the new line alone. The
caller writes; this does not.

* **Return type:**
  [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path), [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

### opsward.decisions.log_entry(text, , date=None)

One Y-statement line for `decisions/log.md`.

```pycon
>>> log_entry("In the context of goldens, facing drift, we decided for pinning.", date=_dt.date(2026, 10, 19))
'- 2026-10-19 — In the context of goldens, facing drift, we decided for pinning.'
```

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### opsward.decisions.new_adr(decisions_dir, title, , status='Proposed', date=None, evidence='')

The next numbered ADR for *title*, rendered from the `adr.md` template.

*evidence* is the issue, discussion or PR the decision rests on (a URL or `#N`);
it lands in the Evidence section so the three surfaces stay linked.

```pycon
>>> import tempfile
>>> gf = new_adr(Path(tempfile.mkdtemp()), "Pin the CLI surface", date=_dt.date(2026, 10, 19), evidence="#8")
>>> gf.target_path.name, gf.content.splitlines()[0]
('0001-pin-the-cli-surface.md', '# 0001 — Pin the CLI surface')
```

* **Return type:**
  [`GeneratedFile`](_autosummary/opsward.base.html.md#opsward.base.GeneratedFile)

### opsward.decisions.next_number(decisions_dir)

One more than the highest numbered ADR, so numbers never collide (1 for an empty dir).

```pycon
>>> import tempfile
>>> next_number(Path(tempfile.mkdtemp()))
1
```

* **Return type:**
  [`int`](https://docs.python.org/3/builtins/functions.html#int)

### opsward.decisions.slugify(title)

A file-name slug: lowercase, hyphens, nothing else, at most 60 characters.

```pycon
>>> slugify("Pin the CLI surface by goldens!")
'pin-the-cli-surface-by-goldens'
```

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### opsward.decisions.status_of(content)

The ADR’s status text, from a `## Status` heading, a `**Status:**` line or
MADR front matter; `None` when there is none.

```pycon
>>> status_of("# x\n\n## Status\n\nAccepted (2026-01-01)\n")
'Accepted (2026-01-01)'
>>> status_of("---\nstatus: accepted\n---\n# x\n"), status_of("**Status:** Superseded by 0003"), status_of("# x\nno status")
('accepted', 'Superseded by 0003', None)
```

* **Return type:**
  [`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]


# _autosummary/opsward.discover.html.md

# opsward.discover

Optional cross-repo asset discovery, delegating to the `toolery` package.

opsward scans and *scores* the AI setup of one repo; this adds *finding* assets — skills,
subagents, docs — across one or more repos. It is opt-in and keeps opsward’s core
dependency-light: `pip install 'opsward[discovery]'` pulls in `toolery` (add
`toolery[ir]` for semantic search). Conceptually this is opsward’s per-repo/fleet
orchestration meeting toolery’s discovery engine (epic #12 → #13).

### Functions

| [`find_assets`](_autosummary/opsward.discover.html.md#opsward.discover.find_assets)(\*roots, query[, kinds, ...])   | Find assets matching `query` across one or more project `roots`.   |
|----------------------------------------------------------------------------------------------|--------------------------------------------------------------------|

### opsward.discover.find_assets(\*roots, query, kinds='skill,agent', semantic=False, limit=10)

Find assets matching `query` across one or more project `roots`.

Harvests the requested `kinds` (comma-separated string or a sequence of
`"skill"`/`"agent"`/`"doc"`) from each root via `toolery` and returns ranked
`(Card, score)` results. With `semantic=True`, uses `toolery`’s ir federated
backend (needs `toolery[ir]`). Defaults to the current directory when no roots given.


# _autosummary/opsward.evals.html.md

# opsward.evals

Eval harness (opsward#17, gap 3): opt-in, report-only quality signals beyond the rubric.

Two layers, both of which *report* and never gate (model calls cost money and are
nondeterministic, so the deterministic rubric stays the only gate):

* **LLM-as-judge** for the rubric’s subjective dimensions (actionability, conciseness):
  [`judge_claude_md()`](_autosummary/opsward.evals.html.md#opsward.evals.judge_claude_md) asks a *judge* to score CLAUDE.md against an explicit rubric,
  > `samples` times, and reports the median next to the rubric’s own score.
* **Golden tasks**: [`run_golden_tasks()`](_autosummary/opsward.evals.html.md#opsward.evals.run_golden_tasks) runs an *agent* on repo-specific tasks with
  and without a candidate config, and checks each output against the task’s `expect` /
  `forbid` patterns. The with-minus-without pass rate is the signal that a config helps.

The judge and the agent are injected. [`rubric_judge()`](_autosummary/opsward.evals.html.md#opsward.evals.rubric_judge) (the default judge) and
[`echo_agent()`](_autosummary/opsward.evals.html.md#opsward.evals.echo_agent) are free and deterministic – they exercise the harness and anchor the
scale – while [`anthropic_judge()`](_autosummary/opsward.evals.html.md#opsward.evals.anthropic_judge) and [`anthropic_agent()`](_autosummary/opsward.evals.html.md#opsward.evals.anthropic_agent) make paid calls through
the `anthropic` SDK (`pip install 'opsward[eval]'`) and are never used by default.

```pycon
>>> report = judge_claude_md("# P\n\n## Commands\n\n```bash\npytest\n```\n")
>>> sorted(report.scores), report.judge
(['actionability', 'conciseness'], 'rubric')
>>> tasks = [GoldenTask("kw", "Write f(a, b, c)", expect=[r"\*,"])]
>>> golden = run_golden_tasks(tasks, agent=echo_agent, config="Use `*,` before the 3rd arg.")
>>> golden.delta()
1.0
```

### Module Attributes

| [`DFLT_JUDGE_MODEL`](_autosummary/opsward.evals.html.md#opsward.evals.DFLT_JUDGE_MODEL)          | Default model for the paid judge and agent; override with `model=`.                                                                         |
|----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------|
| [`JUDGE_RUBRICS`](_autosummary/opsward.evals.html.md#opsward.evals.JUDGE_RUBRICS)             | vague "rate the quality" prompts give noise, anchored bands do not.                                                                         |
| [`Judge`](_autosummary/opsward.evals.html.md#opsward.evals.Judge)                     | the JSON object above).                                                                                                                     |
| [`Agent`](_autosummary/opsward.evals.html.md#opsward.evals.Agent)                     | An agent does a task under a config (CLAUDE.md text; `""` = no config) and returns its output.                                              |
| [`DFLT_GOLDEN_TASKS_RELPATH`](_autosummary/opsward.evals.html.md#opsward.evals.DFLT_GOLDEN_TASKS_RELPATH) | Where a repo keeps its golden tasks, relative to its docs folder (`opsward.scan.docs_dir_for()`: `misc/docs` for Python, `docs` for JS/TS). |

### Functions

| [`anthropic_agent`](_autosummary/opsward.evals.html.md#opsward.evals.anthropic_agent)(\*[, model, client, max_tokens])   | A paid single-call agent: the config is the system prompt, the task the user turn.                                              |
|-----------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------|
| [`anthropic_judge`](_autosummary/opsward.evals.html.md#opsward.evals.anthropic_judge)(\*[, model, client, max_tokens])   | A paid judge over the Messages API.                                                                                             |
| [`echo_agent`](_autosummary/opsward.evals.html.md#opsward.evals.echo_agent)(task, config)                           | The free agent: "does" the task by quoting its config, so a config that states the convention passes and an empty one does not. |
| [`golden_tasks_path`](_autosummary/opsward.evals.html.md#opsward.evals.golden_tasks_path)(scan_result)                     | The default golden-tasks file of a scanned project (it may not exist).                                                          |
| [`judge_claude_md`](_autosummary/opsward.evals.html.md#opsward.evals.judge_claude_md)(content, \*[, judge, ...])         | Score CLAUDE.md `content` on each subjective dimension, `samples` times each.                                                   |
| [`load_golden_tasks`](_autosummary/opsward.evals.html.md#opsward.evals.load_golden_tasks)(path)                            | Tasks from a JSON list of `{"name", "prompt", "expect": [...], "forbid": [...]}`.                                               |
| [`parse_verdict`](_autosummary/opsward.evals.html.md#opsward.evals.parse_verdict)(reply, \*, max_score)                | `(score, reasoning)` from a judge reply: the *last* JSON object in it with a `score`.                                           |
| [`rubric_judge`](_autosummary/opsward.evals.html.md#opsward.evals.rubric_judge)(request)                              | The free, deterministic judge: answers with opsward's own rubric score.                                                         |
| [`run_golden_tasks`](_autosummary/opsward.evals.html.md#opsward.evals.run_golden_tasks)(tasks, \*, agent, config[, ...])  | Run every task `runs` times under `config` and under `baseline`; count passes.                                                  |

### Classes

| [`DimensionVerdict`](_autosummary/opsward.evals.html.md#opsward.evals.DimensionVerdict)(score, max_score, rubric_score)   | A dimension's judged score (median of the samples) next to the rubric's own.               |
|-----------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------|
| [`GoldenReport`](_autosummary/opsward.evals.html.md#opsward.evals.GoldenReport)(runs[, results, errors])              | Per task and arm (`with` / `without` the config): runs passed and runs that errored.       |
| [`GoldenTask`](_autosummary/opsward.evals.html.md#opsward.evals.GoldenTask)(name, prompt[, expect, forbid])         | A repo-specific task, passed when the output matches every `expect` regex and no `forbid`. |
| [`JudgeReport`](_autosummary/opsward.evals.html.md#opsward.evals.JudgeReport)(judge[, scores])                       | Every judged dimension.                                                                    |
| [`JudgeRequest`](_autosummary/opsward.evals.html.md#opsward.evals.JudgeRequest)(dimension, content)                   | One dimension to judge: the rubric, the content, and the rendered prompt.                  |

### opsward.evals.Agent

An agent does a task under a config (CLAUDE.md text; `""` = no config) and returns its output.

alias of [`Callable`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Callable)[[[`GoldenTask`](_autosummary/opsward.evals.html.md#opsward.evals.GoldenTask), [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)], [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

### opsward.evals.DFLT_GOLDEN_TASKS_RELPATH *= 'evals/golden_tasks.json'*

Where a repo keeps its golden tasks, relative to its docs folder
(`opsward.scan.docs_dir_for()`: `misc/docs` for Python, `docs` for JS/TS).

### opsward.evals.DFLT_JUDGE_MODEL *= 'claude-opus-5-5'*

Default model for the paid judge and agent; override with `model=`.

### *class* opsward.evals.DimensionVerdict(score, max_score, rubric_score, samples=list(), reasoning=list(), errors=list())

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

A dimension’s judged score (median of the samples) next to the rubric’s own.

### *class* opsward.evals.GoldenReport(runs, results=dict(), errors=dict())

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

Per task and arm (`with` / `without` the config): runs passed and runs that errored.

A run whose agent raised is left out of its arm’s pass rate (it says nothing about the
config), so a flaky agent cannot skew [`delta()`](_autosummary/opsward.evals.html.md#opsward.evals.GoldenReport.delta); the errors are listed.

#### delta()

Pass rate with the config minus without: positive means the config helps.

* **Return type:**
  [`float`](https://docs.python.org/3/builtins/functions.html#float)

#### rate(arm)

Passed / completed (non-errored) runs in `arm`; 0.0 when none completed.

* **Return type:**
  [`float`](https://docs.python.org/3/builtins/functions.html#float)

### *class* opsward.evals.GoldenTask(name, prompt, expect=(), forbid=())

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

A repo-specific task, passed when the output matches every `expect` regex and no `forbid`.

### opsward.evals.JUDGE_RUBRICS *: [dict](https://docs.python.org/3/builtins/stdtypes.html#dict)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), [dict](https://docs.python.org/3/builtins/stdtypes.html#dict)]* *= {'actionability': {'bands': {'0': 'Empty, or nothing actionable.', '1-4': 'Mostly generic advice an agent cannot turn into an action.', '13-15': 'Every instruction names a concrete command, path, pattern or rule; nothing needs interpretation.', '5-8': 'About half is aspiration or description rather than instruction.', '9-12': 'Mostly concrete; a few instructions are vague ("keep code clean") or lack the command to run.'}, 'max': 15, 'question': 'Can a coding agent act on these instructions without guessing?'}, 'conciseness': {'bands': {'0': 'Empty.', '1-4': 'Bloated: the useful instructions are hard to find.', '13-15': 'No filler, no repetition, no prose where a list or a command would do; detail lives in linked docs.', '5-8': 'Noticeable padding: restated points, long explanations an agent does not need every session.', '9-12': 'Mostly tight; some repetition or paragraphs that could be one line.'}, 'max': 15, 'question': "Is it dense and scannable, with every line earning its place in an agent's context?"}}*

vague “rate the quality” prompts give noise, anchored bands do not.

* **Type:**
  Explicit rubrics

### opsward.evals.Judge

the JSON object above).

* **Type:**
  A judge reads a request and returns its raw reply (expected

alias of [`Callable`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Callable)[[[`JudgeRequest`](_autosummary/opsward.evals.html.md#opsward.evals.JudgeRequest)], [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

### *class* opsward.evals.JudgeReport(judge, scores=dict())

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

Every judged dimension. Report-only: nothing here is meant to fail a build.

### *class* opsward.evals.JudgeRequest(dimension, content)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

One dimension to judge: the rubric, the content, and the rendered prompt.

### opsward.evals.anthropic_agent(, model='claude-opus-5-5', client=None, max_tokens=16000)

A paid single-call agent: the config is the system prompt, the task the user turn.

* **Return type:**
  [`Callable`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Callable)[[[`GoldenTask`](_autosummary/opsward.evals.html.md#opsward.evals.GoldenTask), [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)], [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

### opsward.evals.anthropic_judge(, model='claude-opus-5-5', client=None, max_tokens=16000)

A paid judge over the Messages API. `client` defaults to `anthropic.Anthropic()`.

* **Return type:**
  [`Callable`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Callable)[[[`JudgeRequest`](_autosummary/opsward.evals.html.md#opsward.evals.JudgeRequest)], [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

### opsward.evals.echo_agent(task, config)

The free agent: “does” the task by quoting its config, so a config that states the
convention passes and an empty one does not. It tests the harness, not a model.

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### opsward.evals.golden_tasks_path(scan_result)

The default golden-tasks file of a scanned project (it may not exist).

```pycon
>>> import tempfile
>>> from opsward.scan import scan
>>> root = Path(tempfile.mkdtemp())
>>> _ = (root / "pyproject.toml").write_text("")
>>> golden_tasks_path(scan(root, claude_config_dir=None)).relative_to(root).as_posix()
'misc/docs/evals/golden_tasks.json'
```

* **Return type:**
  [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)

### opsward.evals.judge_claude_md(content, \*, judge=<function rubric_judge>, dimensions=('actionability', 'conciseness'), samples=1)

Score CLAUDE.md `content` on each subjective dimension, `samples` times each.

A reply that cannot be parsed is recorded as an error on its dimension, never raised.

* **Raises:**
  [**ValueError**](https://docs.python.org/3/builtins/exceptions.html#ValueError) – `samples < 1` or an unknown dimension (a mistake in the call).
* **Return type:**
  [`JudgeReport`](_autosummary/opsward.evals.html.md#opsward.evals.JudgeReport)

### opsward.evals.load_golden_tasks(path)

Tasks from a JSON list of `{"name", "prompt", "expect": [...], "forbid": [...]}`.

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`GoldenTask`](_autosummary/opsward.evals.html.md#opsward.evals.GoldenTask)]

### opsward.evals.parse_verdict(reply, , max_score)

`(score, reasoning)` from a judge reply: the *last* JSON object in it with a `score`.

The last, because a judge that quotes a snippet or restates the format writes its
verdict at the end. `9`, `9.0` and `"9"` are all read as 9.

* **Raises:**
  [**ValueError**](https://docs.python.org/3/builtins/exceptions.html#ValueError) – no JSON object with a `score`, or one that is not an integer in
  `0..max_score`.
* **Return type:**
  [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`int`](https://docs.python.org/3/builtins/functions.html#int), [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

```pycon
>>> parse_verdict('Quote {"a": 1}. Verdict: {"reasoning": "ok", "score": 12}', max_score=15)
(12, 'ok')
```

### opsward.evals.rubric_judge(request)

The free, deterministic judge: answers with opsward’s own rubric score.

It exercises the harness end to end and anchors the scale (a real judge’s scores are
read next to it), but it is not an independent opinion.

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### opsward.evals.run_golden_tasks(tasks, , agent, config, baseline='', runs=1)

Run every task `runs` times under `config` and under `baseline`; count passes.

An agent error is recorded, never raised, and leaves that run out of the pass rate.

* **Raises:**
  [**ValueError**](https://docs.python.org/3/builtins/exceptions.html#ValueError) – two tasks share a name, or `runs < 1`.
* **Return type:**
  [`GoldenReport`](_autosummary/opsward.evals.html.md#opsward.evals.GoldenReport)


# _autosummary/opsward.fleet.html.md

# opsward.fleet

### opsward.fleet(roots, \*, diagnose_root=<function \_diagnose_root>, check_dirs=True)

Diagnose every root and aggregate. A root that fails is recorded, never fatal.

* **Parameters:**
  * **roots** ([`Iterable`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Iterable)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)]) – project directories, e.g. `git_roots_under(parent)`.
  * **diagnose_root** ([`Callable`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Callable)[[[`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)], [`DiagnosisReport`](_autosummary/opsward.base.html.md#opsward.base.DiagnosisReport)]) – `Path -> DiagnosisReport`; defaults to `diagnose(scan(root))`.
  * **check_dirs** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – record a root that is not a directory as an error.
* **Return type:**
  `FleetReport`


# _autosummary/opsward.generate.html.md

# opsward.generate

### opsward.generate(scan_result, , agents_md=False, hooks=False)

Determine which artifacts are missing, render templates, return files to create.

```pycon
>>> from pathlib import Path
>>> from opsward.base import ScanResult
>>> files = generate(ScanResult(project_root=Path('/tmp/empty')))
>>> any(f.target_path.name == 'CLAUDE.md' for f in files)
True
```

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`GeneratedFile`](_autosummary/opsward.base.html.md#opsward.base.GeneratedFile)]


# _autosummary/opsward.html.md

# opsward

Diagnose, generate, and maintain the AI agent setup of your projects.

### Modules

| [`base`](_autosummary/opsward.base.html.md#module-opsward.base)                                           | All dataclasses and type definitions for opsward.                                                |
|---------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------|
| [`cli`](_autosummary/opsward.cli.html.md#module-opsward.cli)                                             | CLI dispatch for opsward.                                                                        |
| [`data`](_autosummary/opsward.data.html.md#module-opsward.data)                                           | Bundled package resources for opsward, accessed via `importlib.resources.files("opsward.data")`. |
| [`decisions`](_autosummary/opsward.decisions.html.md#module-opsward.decisions)                                 | Decision capture: numbered ADRs, the one-line decision log, and their drift.                     |
| [`discover`](_autosummary/opsward.discover.html.md#module-opsward.discover)                                   | Optional cross-repo asset discovery, delegating to the `toolery` package.                        |
| [`evals`](_autosummary/opsward.evals.html.md#module-opsward.evals)                                         | Eval harness (opsward#17, gap 3): opt-in, report-only quality signals beyond the rubric.         |
| [`fleet`](_autosummary/opsward.fleet.html.md#opsward.fleet)(roots, \*[, diagnose_root, check_dirs])        | Diagnose every root and aggregate.                                                               |
| [`generate`](_autosummary/opsward.generate.html.md#opsward.generate)(scan_result, \*[, agents_md, hooks])     | Determine which artifacts are missing, render templates, return files to create.                 |
| [`lint`](_autosummary/opsward.lint.html.md#module-opsward.lint)                                           | Schema lint (opsward#17, gap 2): spec and config violations, pass or fail, no score.             |
| [`maintain`](_autosummary/opsward.maintain.html.md#opsward.maintain)(scan_result, \*[, previous_report, ...]) | Detect maintenance issues and return suggestions.                                                |
| [`memory_audit`](_autosummary/opsward.memory_audit.html.md#module-opsward.memory_audit)                           | Memory audit: fleet-wide rules stranded in project-local auto-memory, and who should own them.   |
| [`portability`](_autosummary/opsward.portability.html.md#module-opsward.portability)                             | Multi-host portability: which agent hosts a repo satisfies, and canonical↔render drift.          |
| [`recommend`](_autosummary/opsward.recommend.html.md#module-opsward.recommend)                                 | Recommend skills from the ecosystem based on project tech stack.                                 |
| [`scan`](_autosummary/opsward.scan.html.md#opsward.scan)(project_root, \*[, claude_config_dir])           | Scan *project_root* and return a ScanResult.                                                     |
| [`score`](_autosummary/opsward.score.html.md#module-opsward.score)                                         | Pure scoring functions.                                                                          |
| [`security`](_autosummary/opsward.security.html.md#module-opsward.security)                                   | Security advisories (opsward#17, gap 5): "valid" is not "safe to ship".                          |
| [`subagents`](_autosummary/opsward.subagents.html.md#module-opsward.subagents)                                 | Reuse a skill as a subagent: declare it in the skill, generate the twin, check the sync.         |
| [`util`](_autosummary/opsward.util.html.md#module-opsward.util)                                           | Shared helpers for opsward.                                                                      |
| [`weekly`](_autosummary/opsward.weekly.html.md#module-opsward.weekly)                                       | The weekly look: the agent setup's five numbers, against last week, and one proposed change.     |


# _autosummary/opsward.lint.html.md

# opsward.lint

Schema lint (opsward#17, gap 2): spec and config violations, pass or fail, no score.

`diagnose --min-score` is the cheap scored gate; `lint` is the strict one. It runs
every *validator* over every project skill, and checks the hooks config, and reports each
violation with a repo-relative path. A validator is `SkillInfo -> list[str]`:

* `opsward` – opsward’s own agentskills.io spec check (`validate_skill_spec()`),
  always available;
* `skill` – the `skill` package’s `skill.validate()` (`pip install 'opsward[lint]'`),
  which composes its own registered validators;
* `agnix`, `skillcheck` and `skillsaw` – external linters, run as subprocesses
  (`npm install -g agnix`, `pip install skillcheck`, `pip install skillsaw`); their
  JSON diagnostics of level `error` and `warning` become findings. opsward depends on
  none of them, and they are opt-in by name: their rule sets are wider and noisier than the spec check, so a
  gate on `"auto"` must not turn red because a machine happens to have one installed.

`"auto"` (the default) is [`AUTO_VALIDATORS`](_autosummary/opsward.lint.html.md#opsward.lint.AUTO_VALIDATORS), each when it is available. A host
can pass any mapping of name to validator instead.

```pycon
>>> from pathlib import Path
>>> from opsward.base import ScanResult, SkillInfo
>>> sr = ScanResult(Path("repo"), skills=[SkillInfo("Bad_Name", Path("repo/.claude/skills/Bad_Name"),
...                                                 has_skill_md=True, frontmatter={"name": "Bad_Name"})])
>>> findings = list(lint(sr, validators={"opsward": opsward_validator}))
>>> findings[0].path, findings[0].source
('.claude/skills/Bad_Name', 'opsward')
```

### Module Attributes

| [`DFLT_VALIDATORS`](_autosummary/opsward.lint.html.md#opsward.lint.DFLT_VALIDATORS)         | these names, each when it is available.                                             |
|--------------------------------------------------------------------------|-------------------------------------------------------------------------------------|
| [`EXTERNAL_FINDING_LEVELS`](_autosummary/opsward.lint.html.md#opsward.lint.EXTERNAL_FINDING_LEVELS) | Diagnostic levels of an external linter that count as findings (`info` does not).   |
| [`DFLT_EXTERNAL_TIMEOUT`](_autosummary/opsward.lint.html.md#opsward.lint.DFLT_EXTERNAL_TIMEOUT)   | Seconds an external linter may take on one skill.                                   |
| [`VALIDATORS`](_autosummary/opsward.lint.html.md#opsward.lint.VALIDATORS)              | name -> (validator, is-it-available).                                               |
| [`AUTO_VALIDATORS`](_autosummary/opsward.lint.html.md#opsward.lint.AUTO_VALIDATORS)         | the same set on every machine.                                                      |
| [`INSTALL_HINTS`](_autosummary/opsward.lint.html.md#opsward.lint.INSTALL_HINTS)           | How to install each optional validator (named in the "not installed" error).        |
| [`HOOKS_FILES`](_autosummary/opsward.lint.html.md#opsward.lint.HOOKS_FILES)             | Where Claude Code reads hooks from; a settings file holds hooks only under `hooks`. |

### Functions

| [`agnix_validator`](_autosummary/opsward.lint.html.md#opsward.lint.agnix_validator)(skill)              | [agnix](https://github.com/agent-sh/agnix) over the skill's directory.                    |
|--------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------|
| [`lint`](_autosummary/opsward.lint.html.md#opsward.lint.lint)(scan_result, \*[, validators]) | Every spec/config violation in the scanned project, skills first, then hooks.             |
| [`opsward_validator`](_autosummary/opsward.lint.html.md#opsward.lint.opsward_validator)(skill)            | opsward's own spec check; a skill directory without a SKILL.md is one violation.          |
| [`resolve_validators`](_autosummary/opsward.lint.html.md#opsward.lint.resolve_validators)([spec])          | Turn `"auto"`, `"opsward,skill"` or a mapping into a name -> validator dict.              |
| [`skill_package_validator`](_autosummary/opsward.lint.html.md#opsward.lint.skill_package_validator)(skill)      | The `skill` package's `validate()` over the skill's directory.                            |
| [`skillcheck_validator`](_autosummary/opsward.lint.html.md#opsward.lint.skillcheck_validator)(skill)         | [skillcheck](https://pypi.org/project/skillcheck/) over the skill's SKILL.md.             |
| [`skillsaw_validator`](_autosummary/opsward.lint.html.md#opsward.lint.skillsaw_validator)(skill)           | [skillsaw](https://github.com/stbenjam/skillsaw) (Apache-2.0) over the skill's directory. |

### Classes

| [`LintFinding`](_autosummary/opsward.lint.html.md#opsward.lint.LintFinding)(path, source, message)   | One violation: where (repo-relative), which validator said so, and what.   |
|---------------------------------------------------------------------------------------|----------------------------------------------------------------------------|

### opsward.lint.AUTO_VALIDATORS *= ('opsward', 'skill')*

the same set on every machine.

* **Type:**
  What `"auto"` runs (each when available)

### opsward.lint.DFLT_EXTERNAL_TIMEOUT *= 120*

Seconds an external linter may take on one skill.

### opsward.lint.DFLT_VALIDATORS *= 'auto'*

these names, each when it is available.

* **Type:**
  What `validators="auto"` means

### opsward.lint.EXTERNAL_FINDING_LEVELS *= ('error', 'warning')*

Diagnostic levels of an external linter that count as findings (`info` does not).

### opsward.lint.HOOKS_FILES *= ('hooks.json', 'settings.json', 'settings.local.json')*

Where Claude Code reads hooks from; a settings file holds hooks only under `hooks`.

### opsward.lint.INSTALL_HINTS *= {'agnix': 'npm install -g agnix', 'skill': "pip install 'opsward[lint]'", 'skillcheck': 'pip install skillcheck', 'skillsaw': 'pip install skillsaw'}*

How to install each optional validator (named in the “not installed” error).

### *class* opsward.lint.LintFinding(path, source, message)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

One violation: where (repo-relative), which validator said so, and what.

### opsward.lint.VALIDATORS *: [dict](https://docs.python.org/3/builtins/stdtypes.html#dict)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[Callable](https://docs.python.org/3/library/collections.abc.html#collections.abc.Callable)[[[SkillInfo](_autosummary/opsward.base.html.md#opsward.base.SkillInfo)], [list](https://docs.python.org/3/builtins/stdtypes.html#list)], [Callable](https://docs.python.org/3/library/collections.abc.html#collections.abc.Callable)[[], [bool](https://docs.python.org/3/builtins/functions.html#bool)]]]* *= {'agnix': (<function agnix_validator>, <function \_on_path.<locals>.<lambda>>), 'opsward': (<function opsward_validator>, <function <lambda>>), 'skill': (<function skill_package_validator>, <function \_skill_package_available>), 'skillcheck': (<function skillcheck_validator>, <function \_on_path.<locals>.<lambda>>), 'skillsaw': (<function skillsaw_validator>, <function \_on_path.<locals>.<lambda>>)}*

name -> (validator, is-it-available).

* **Type:**
  Every known validator

### opsward.lint.agnix_validator(skill)

[agnix](https://github.com/agent-sh/agnix) over the skill’s directory.

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

### opsward.lint.lint(scan_result, , validators='auto')

Every spec/config violation in the scanned project, skills first, then hooks.

Hooks are read from every file in [`HOOKS_FILES`](_autosummary/opsward.lint.html.md#opsward.lint.HOOKS_FILES) that exists, not only the one
`scan` picked, so an unparseable or shadowed hooks file is still reported.

* **Return type:**
  [`Iterator`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Iterator)[[`LintFinding`](_autosummary/opsward.lint.html.md#opsward.lint.LintFinding)]

### opsward.lint.opsward_validator(skill)

opsward’s own spec check; a skill directory without a SKILL.md is one violation.

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

### opsward.lint.resolve_validators(spec='auto')

Turn `"auto"`, `"opsward,skill"` or a mapping into a name -> validator dict.

* **Raises:**
  [**ValueError**](https://docs.python.org/3/builtins/exceptions.html#ValueError) – an unknown name, or a named validator that is not installed.
* **Return type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`Callable`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Callable)[[[`SkillInfo`](_autosummary/opsward.base.html.md#opsward.base.SkillInfo)], [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)]]

```pycon
>>> list(resolve_validators("opsward"))
['opsward']
>>> resolve_validators("nope")
Traceback (most recent call last):
...
ValueError: unknown validator 'nope' (known: opsward, skill, agnix, skillcheck, skillsaw)
```

### opsward.lint.skill_package_validator(skill)

The `skill` package’s `validate()` over the skill’s directory.

A directory with no SKILL.md is left to [`opsward_validator()`](_autosummary/opsward.lint.html.md#opsward.lint.opsward_validator) (`skill` would
report it again, with an absolute path).

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

### opsward.lint.skillcheck_validator(skill)

[skillcheck](https://pypi.org/project/skillcheck/) over the skill’s SKILL.md.

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

### opsward.lint.skillsaw_validator(skill)

[skillsaw](https://github.com/stbenjam/skillsaw) (Apache-2.0) over the skill’s directory.

Its rule worth having beside the spec check is `context-budget`: a frontmatter
description too long for the host’s skill listing. Custom rules from a
`.skillsaw.yaml` and third-party rule plugins are switched off, so linting a
checkout never runs code that checkout supplies.

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]


# _autosummary/opsward.maintain.html.md

# opsward.maintain

### opsward.maintain(scan_result, , previous_report=None, claude_md_max_chars=10000)

Detect maintenance issues and return suggestions.

```pycon
>>> from pathlib import Path
>>> from opsward.base import ScanResult
>>> maintain(ScanResult(project_root=Path('/tmp/empty')))
[]
```

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`MaintenanceSuggestion`](_autosummary/opsward.base.html.md#opsward.base.MaintenanceSuggestion)]


# _autosummary/opsward.memory_audit.html.md

# opsward.memory_audit

Memory audit: fleet-wide rules stranded in project-local auto-memory, and who should own them.

Claude Code’s auto-memory is keyed by working directory: a `feedback` memory written in one
project loads only in sessions started there. A rule that holds for every project is stranded
in that one. This audit lists every memory of the chosen kinds, then for each one:

- **scope**: `project` or `fleet`, with the reason ([`classify()`](_autosummary/opsward.memory_audit.html.md#opsward.memory_audit.classify), a heuristic; pass
  `classify=` to use a judge instead);
- **duplicates**: memories in *other* directories that say nearly the same thing
  ([`similarity()`](_autosummary/opsward.memory_audit.html.md#opsward.memory_audit.similarity), lexical, replaceable);
- **owner**: for a fleet-wide one, the installed skill whose name and description match it
  best, else `~/.claude/CLAUDE.md`, and whether the owner already says it;
- **stub**: a memory that only says it moved elsewhere, listed for deletion.

Report-only: it never writes, moves or deletes a memory. The user curates the table.

```pycon
>>> parse_frontmatter("---\nname: x\nmetadata:\n  type: feedback\n---\nbody")
({'name': 'x', 'type': 'feedback'}, 'body')
```

### Module Attributes

| [`DUPLICATE_AT`](_autosummary/opsward.memory_audit.html.md#opsward.memory_audit.DUPLICATE_AT)   | Two memories in different directories at or above this similarity are reported as duplicates.                               |
|-----------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------|
| [`OWNER_AT`](_autosummary/opsward.memory_audit.html.md#opsward.memory_audit.OWNER_AT)       | A skill must match a fleet-wide memory at least this well to be proposed as its owner.                                      |
| [`COVERED_AT`](_autosummary/opsward.memory_audit.html.md#opsward.memory_audit.COVERED_AT)     | Share of a memory's distinctive words its owner must already hold to say "already there".                                   |
| [`FLEET_CUES`](_autosummary/opsward.memory_audit.html.md#opsward.memory_audit.FLEET_CUES)     | Words that mark a rule as a habit for every project.                                                                        |
| [`CWD_SCAN_LINES`](_autosummary/opsward.memory_audit.html.md#opsward.memory_audit.CWD_SCAN_LINES) | How many lines of each transcript [`project_dir()`](_autosummary/opsward.memory_audit.html.md#opsward.memory_audit.project_dir) reads looking for a `cwd`. |

### Functions

| [`audit`](_autosummary/opsward.memory_audit.html.md#opsward.memory_audit.audit)(\*[, home, kinds, found, skills_dirs, ...])   | Audit the memories (`found`, default: [`memories()`](_autosummary/opsward.memory_audit.html.md#opsward.memory_audit.memories) of `home` and `kinds`).                                  |
|------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [`classify`](_autosummary/opsward.memory_audit.html.md#opsward.memory_audit.classify)(memory)                                    | `(scope, reason)`: `project` when the memory names its own project (and is not phrased as a habit), else `fleet` or `project` by its wording.              |
| [`is_stub`](_autosummary/opsward.memory_audit.html.md#opsward.memory_audit.is_stub)(memory, \*[, short, head])                  | A memory that says it moved: the marker in its name or opening, or anywhere in a short one.                                                                |
| [`memories`](_autosummary/opsward.memory_audit.html.md#opsward.memory_audit.memories)([home, kinds])                             | Every memory of `kinds` under `home`'s project folders (`MEMORY.md` indexes excluded).                                                                     |
| [`names_project`](_autosummary/opsward.memory_audit.html.md#opsward.memory_audit.names_project)(text, name)                           | Whether `text` names the project `name`, with `-`, `_` and space equivalent and no letter or digit on either side.                                         |
| [`parse_frontmatter`](_autosummary/opsward.memory_audit.html.md#opsward.memory_audit.parse_frontmatter)(text)                             | `(fields, body)`: flat `key: value` fields of a `---` block, nested `metadata` keys lifted to the top (`metadata: type: feedback` gives `type`).           |
| [`project_dir`](_autosummary/opsward.memory_audit.html.md#opsward.memory_audit.project_dir)(folder, \*[, scan_lines])               | The working directory a project folder is for, read from its transcripts, else `""`.                                                                       |
| [`project_name`](_autosummary/opsward.memory_audit.html.md#opsward.memory_audit.project_name)(slug[, cwd])                           | The project a directory names: the last part of its real `cwd` when known, else the last part of the slug (lossy: `tw_platform` comes back as `platform`). |
| [`project_slug`](_autosummary/opsward.memory_audit.html.md#opsward.memory_audit.project_slug)(path)                                  | Claude Code's folder name for a working directory: every non-alphanumeric is `-`.                                                                          |
| [`render`](_autosummary/opsward.memory_audit.html.md#opsward.memory_audit.render)(result, \*[, home])                          | The audit as a markdown page: fleet-wide memories and their proposed owner first.                                                                          |
| [`similarity`](_autosummary/opsward.memory_audit.html.md#opsward.memory_audit.similarity)(a, b)                                    | Jaccard similarity of two texts' distinctive words.                                                                                                        |
| [`skills`](_autosummary/opsward.memory_audit.html.md#opsward.memory_audit.skills)(dirs)                                        | `{name: "name description"}` of the skills under `dirs` (`*/SKILL.md`).                                                                                    |
| [`words`](_autosummary/opsward.memory_audit.html.md#opsward.memory_audit.words)(text)                                         | The distinctive words of `text`: lowercase, three letters or more, no stopwords.                                                                           |

### Classes

| [`Memory`](_autosummary/opsward.memory_audit.html.md#opsward.memory_audit.Memory)(path, project, kind, name, ...[, ...])   | One memory file.   |
|--------------------------------------------------------------------------------------------------|--------------------|

### opsward.memory_audit.COVERED_AT *= 0.6*

Share of a memory’s distinctive words its owner must already hold to say “already there”.

### opsward.memory_audit.CWD_SCAN_LINES *= 200*

How many lines of each transcript [`project_dir()`](_autosummary/opsward.memory_audit.html.md#opsward.memory_audit.project_dir) reads looking for a `cwd`.

### opsward.memory_audit.DUPLICATE_AT *= 0.45*

Two memories in different directories at or above this similarity are reported as duplicates.

### opsward.memory_audit.FLEET_CUES *= re.compile('\\\\b(always|never|every (?:project|repo|package|session)|in general|whenever|by default|from now on|across (?:the )?(?:fleet|projects|repos))\\\\b', re.IGNORECASE)*

Words that mark a rule as a habit for every project.

### *class* opsward.memory_audit.Memory(path, project, kind, name, description, body, modified, project_dir='', scope='', reason='', duplicates=list(), owner='', owner_score=0.0, covered=False, stub=False)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

One memory file.

### opsward.memory_audit.OWNER_AT *= 0.08*

A skill must match a fleet-wide memory at least this well to be proposed as its owner.

### opsward.memory_audit.audit(\*, home=None, kinds=('feedback', ), found=None, skills_dirs=None, global_claude_md=None, read_owner=None, classify=<function classify>, similarity=<function similarity>, duplicate_at=0.45, owner_at=0.08)

Audit the memories (`found`, default: [`memories()`](_autosummary/opsward.memory_audit.html.md#opsward.memory_audit.memories) of `home` and `kinds`).

`read_owner(owner)` returns an owner’s text, to say whether it already holds the rule
(default: the skill’s `SKILL.md`, or the global `CLAUDE.md`).

* **Return type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)

### opsward.memory_audit.classify(memory)

`(scope, reason)`: `project` when the memory names its own project (and is not
phrased as a habit), else `fleet` or `project` by its wording.

```pycon
>>> m = Memory("p", "-x-t-priv", "feedback", "n", "", "Always route LLM calls through aix.", "")
>>> classify(m)
('fleet', "worded as a habit ('Always') and does not name priv")
>>> classify(Memory("p", "-x-t-priv", "feedback", "n", "", "In priv, the CLI golden must be re-recorded.", ""))
('project', 'names its own project (priv)')
```

* **Return type:**
  [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

### opsward.memory_audit.is_stub(memory, , short=400, head=200)

A memory that says it moved: the marker in its name or opening, or anywhere in a short one.

```pycon
>>> is_stub(Memory("p", "x", "feedback", "old-rule-SUPERSEDED", "", "x " * 400, ""))
True
>>> is_stub(Memory("p", "x", "feedback", "rule", "", "Prefer dol. " * 50 + "It replaced by hand.", ""))
False
```

* **Return type:**
  [`bool`](https://docs.python.org/3/builtins/functions.html#bool)

### opsward.memory_audit.memories(home=None, , kinds=('feedback',))

Every memory of `kinds` under `home`’s project folders (`MEMORY.md` indexes excluded).

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`Memory`](_autosummary/opsward.memory_audit.html.md#opsward.memory_audit.Memory)]

### opsward.memory_audit.names_project(text, name)

Whether `text` names the project `name`, with `-`, `_` and space equivalent
and no letter or digit on either side.

```pycon
>>> names_project("Deploys of tw-platform go through deploy.py.", "tw_platform")
True
>>> names_project("In tw_platform, never rsync.", "platform")
True
>>> names_project("the iq_platformer tool", "iq_platform")
False
```

* **Return type:**
  [`bool`](https://docs.python.org/3/builtins/functions.html#bool)

### opsward.memory_audit.parse_frontmatter(text)

`(fields, body)`: flat `key: value` fields of a `---` block, nested `metadata`
keys lifted to the top (`metadata: type: feedback` gives `type`).

* **Return type:**
  [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict), [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

### opsward.memory_audit.project_dir(folder, , scan_lines=200)

The working directory a project folder is for, read from its transcripts, else `""`.

The folder’s name is a lossy slug (`tw_platform` and `tw-platform` both give
`tw-platform`), but each transcript records the real `cwd`. The first one whose
slug is the folder’s name wins, newest transcript first.

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### opsward.memory_audit.project_name(slug, cwd='')

The project a directory names: the last part of its real `cwd` when known, else
the last part of the slug (lossy: `tw_platform` comes back as `platform`).

```pycon
>>> project_name("-Users-me-Dropbox-py-proj-t-priv")
'priv'
>>> project_name("-Users-me-proj-tt-tw-platform", "/Users/me/proj/tt/tw_platform")
'tw_platform'
```

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### opsward.memory_audit.project_slug(path)

Claude Code’s folder name for a working directory: every non-alphanumeric is `-`.

```pycon
>>> project_slug("/Users/me/proj/tt/tw_platform")
'-Users-me-proj-tt-tw-platform'
```

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### opsward.memory_audit.render(result, , home=None)

The audit as a markdown page: fleet-wide memories and their proposed owner first.

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### opsward.memory_audit.similarity(a, b)

Jaccard similarity of two texts’ distinctive words.

```pycon
>>> similarity("prefer the storage facade dol", "the dol storage facade, always")
1.0
>>> similarity("route calls through aix", "route storage through dol")
0.333
```

* **Return type:**
  [`float`](https://docs.python.org/3/builtins/functions.html#float)

### opsward.memory_audit.skills(dirs)

`{name: "name description"}` of the skills under `dirs` (`*/SKILL.md`).

* **Return type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

### opsward.memory_audit.words(text)

The distinctive words of `text`: lowercase, three letters or more, no stopwords.

```pycon
>>> sorted(words("Always route LLM calls through aix, never directly."))
['aix', 'calls', 'directly', 'llm', 'route', 'through']
```

* **Return type:**
  [`set`](https://docs.python.org/3/builtins/stdtypes.html#set)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]


# _autosummary/opsward.portability.html.md

# opsward.portability

Multi-host portability: which agent hosts a repo satisfies, and canonical↔render drift.

The canonical project brief is `AGENTS.md` (opsward#15). Every other host’s instruction
file (`CLAUDE.md`, `GEMINI.md`, `.github/copilot-instructions.md`, …) is a *render*
of it, related to it in one of three ways:

* `symlink` — the file is a symlink to `AGENTS.md`: byte-identical, cannot drift;
* `import` — the file imports it (`@AGENTS.md`) and adds host-only deltas: the
  recommended shape for hosts with an import syntax (Claude Code, Gemini CLI). The
  import path resolves against the importing file’s folder, as Claude Code resolves it:
  `.claude/CLAUDE.md` needs `@../AGENTS.md`, and an import that names some other
  file (`@AGENTS.md` there means `.claude/AGENTS.md`) is no import of the canonical;
* `copy` — a separate file: everything in it can drift from the canonical.

The check is a *linter*: the canonical is authoritative and drift in a render is
reported, never merged back. Three finding kinds, matched section by section (by
normalised heading):

* `stale` — a canonical section is missing from a copy;
* `diverged` — a section is in both, with different bodies (a stale render or a hand
  edit in the render: the files alone cannot say which);
* `host_only` — a section only the render has: promote it to `AGENTS.md` if it is
  portable, or keep it as a host delta (after an `@AGENTS.md` import).

Scoped-rule folders (`.cursor/rules/`, `.windsurf/rules/`, `.clinerules/`) count
towards coverage but are not compared: they are not renders of one brief.

A fourth kind, `lossy`, is about skills rather than the brief: a project skill
rendered for a host whose format drops some of its fields (`allowed-tools`,
`license`, bundled resources). Where each host installs skills and what its format
drops is the `skill` package’s registry (`skill.install.agent_targets`,
`skill.translate.lost_fields`); `HostSpec.skill_target` points into it, so the two
registries are joined, not copied. `check_portability` reports it when `skill` is
installed (`pip install 'opsward[lint]'`); it is never scored.

Files that are only coverage signals (`CONVENTIONS.md` is often a contributor doc, not a
render) are compared only when they import or link the canonical.

`read_host_files` is read-only (it backs `scan`); `analyze` is pure.

```pycon
>>> report = analyze(
...     "# P\n\n## Build\n\npytest\n",
...     {"CLAUDE.md": HostFile("CLAUDE.md", "## Build\n\npytest -x\n## Claude\n\nx\n")},
... )
>>> report.coverage["claude"], report.coverage["codex"]
('copy', 'native')
>>> sorted((f.kind, f.section) for f in report.findings)
[('diverged', 'build'), ('host_only', 'claude')]
```

### Module Attributes

| [`DRIFT_KINDS`](_autosummary/opsward.portability.html.md#opsward.portability.DRIFT_KINDS)   | The drift finding kinds, in report order (see the module docstring).               |
|----------------------------------------------------------------|------------------------------------------------------------------------------------|
| [`LOSSY`](_autosummary/opsward.portability.html.md#opsward.portability.LOSSY)         | A skill rendered in a format that drops some of its fields (reported, not scored). |

### Functions

| [`analyze`](_autosummary/opsward.portability.html.md#opsward.portability.analyze)(canonical, host_files, \*[, hosts])      | Coverage and drift of *host_files* against the *canonical* `AGENTS.md` text.         |
|---------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------|
| [`as_read`](_autosummary/opsward.portability.html.md#opsward.portability.as_read)(render, canonical, \*[, path])           | *render* (the file at root-relative *path*) as its host reads it, import inlined.    |
| [`canonical_import`](_autosummary/opsward.portability.html.md#opsward.portability.canonical_import)(importer)                       | The `@…` import that names `AGENTS.md` from the file *importer* (root-relative).     |
| [`check_portability`](_autosummary/opsward.portability.html.md#opsward.portability.check_portability)(root, \*[, hosts])             | `analyze` over what is on disk under *root*, plus `lossy` skill renders.             |
| [`claude_md_as_read`](_autosummary/opsward.portability.html.md#opsward.portability.claude_md_as_read)(scan_result)                   | The scanned CLAUDE.md as Claude Code reads it (`as_read` at its own path).           |
| [`claude_md_relpath`](_autosummary/opsward.portability.html.md#opsward.portability.claude_md_relpath)(scan_result)                   | The scanned CLAUDE.md's path relative to the project root (`CLAUDE.md` if unknown).  |
| [`has_canonical`](_autosummary/opsward.portability.html.md#opsward.portability.has_canonical)(canonical)                         | Whether an `AGENTS.md` text says anything (a BOM or whitespace does not).            |
| [`lossy_findings`](_autosummary/opsward.portability.html.md#opsward.portability.lossy_findings)(root, \*[, hosts])                | One `lossy` finding per project skill rendered for a host whose format drops fields. |
| [`read_host_files`](_autosummary/opsward.portability.html.md#opsward.portability.read_host_files)(root, \*[, hosts])               | Every host instruction file and rule folder present under *root*.                    |
| [`resolves_to_canonical`](_autosummary/opsward.portability.html.md#opsward.portability.resolves_to_canonical)(import_path, \*, importer) | Whether `@import_path` in the file *importer* (root-relative) names `AGENTS.md`.     |
| [`summarize`](_autosummary/opsward.portability.html.md#opsward.portability.summarize)(report)                                | One diagnose suggestion per drifting render.                                         |

### Classes

| [`DriftFinding`](_autosummary/opsward.portability.html.md#opsward.portability.DriftFinding)(kind, path, section[, lost])   | One section that differs between `AGENTS.md` and a render.                        |
|----------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------|
| [`HostFile`](_autosummary/opsward.portability.html.md#opsward.portability.HostFile)(path[, content, ...])              | One host instruction file (or rule folder) as found on disk.                      |
| [`HostSpec`](_autosummary/opsward.portability.html.md#opsward.portability.HostSpec)(name[, instruction_files, ...])    | Where one agent host looks for project instructions (research table, opsward#15). |
| [`PortabilityReport`](_autosummary/opsward.portability.html.md#opsward.portability.PortabilityReport)([coverage, findings])     | Host coverage (host -> relation, `native` or `none`) and drift findings.          |

### opsward.portability.DRIFT_KINDS *= ('stale', 'diverged', 'host_only')*

The drift finding kinds, in report order (see the module docstring).

### *class* opsward.portability.DriftFinding(kind, path, section, lost=())

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

One section that differs between `AGENTS.md` and a render.

### *class* opsward.portability.HostFile(path, content='', links_to_canonical=False, is_dir=False, compared=True)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

One host instruction file (or rule folder) as found on disk.

#### *property* relation *: [str](https://docs.python.org/3/builtins/stdtypes.html#str)*

`symlink`, `import`, `rules` or `copy` (see the module docstring).

### *class* opsward.portability.HostSpec(name, instruction_files=(), rule_dirs=(), reads_agents_md=False, compared=True, skill_target=None)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

Where one agent host looks for project instructions (research table, opsward#15).

### opsward.portability.LOSSY *= 'lossy'*

A skill rendered in a format that drops some of its fields (reported, not scored).

### *class* opsward.portability.PortabilityReport(coverage=dict(), findings=list())

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

Host coverage (host -> relation, `native` or `none`) and drift findings.

#### *property* covered *: [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[str](https://docs.python.org/3/builtins/stdtypes.html#str)]*

Hosts that find project instructions, in `AGENT_HOSTS` order.

### opsward.portability.analyze(canonical, host_files, , hosts={'aider': HostSpec(name='aider', instruction_files=('CONVENTIONS.md',), rule_dirs=(), reads_agents_md=False, compared=False, skill_target=None), 'claude': HostSpec(name='claude', instruction_files=('CLAUDE.md', '.claude/CLAUDE.md'), rule_dirs=('.claude/rules',), reads_agents_md=False, compared=True, skill_target='claude-code'), 'cline': HostSpec(name='cline', instruction_files=('.clinerules',), rule_dirs=('.clinerules',), reads_agents_md=True, compared=True, skill_target='cline'), 'codex': HostSpec(name='codex', instruction_files=(), rule_dirs=(), reads_agents_md=True, compared=True, skill_target='codex'), 'copilot': HostSpec(name='copilot', instruction_files=('.github/copilot-instructions.md',), rule_dirs=('.github/instructions',), reads_agents_md=True, compared=True, skill_target='copilot'), 'cursor': HostSpec(name='cursor', instruction_files=('.cursorrules',), rule_dirs=('.cursor/rules',), reads_agents_md=True, compared=True, skill_target='cursor'), 'gemini': HostSpec(name='gemini', instruction_files=('GEMINI.md',), rule_dirs=(), reads_agents_md=False, compared=True, skill_target='gemini'), 'windsurf': HostSpec(name='windsurf', instruction_files=('.windsurfrules', '.windsurfrules.md'), rule_dirs=('.windsurf/rules',), reads_agents_md=False, compared=True, skill_target='windsurf'), 'zed': HostSpec(name='zed', instruction_files=('.rules',), rule_dirs=(), reads_agents_md=True, compared=True, skill_target=None)})

Coverage and drift of *host_files* against the *canonical* `AGENTS.md` text. Pure.

A blank canonical (empty, whitespace or a BOM) counts as absent.

* **Return type:**
  [`PortabilityReport`](_autosummary/opsward.portability.html.md#opsward.portability.PortabilityReport)

### opsward.portability.as_read(render, canonical, , path='CLAUDE.md')

*render* (the file at root-relative *path*) as its host reads it, import inlined.

An `@…AGENTS.md` import that resolves to the canonical from *path*’s folder is
replaced by *canonical*: a line that is only the import is replaced in place; an
import inside a sentence appends the canonical at the end. A copy, or an import that
does not resolve (`@AGENTS.md` in `.claude/CLAUDE.md`), comes back unchanged, so
scoring a shim judges what the agent actually sees, not the three-line file.

```pycon
>>> as_read("@AGENTS.md\n\n## Claude\n\nx", "## Build\n\npytest\n")
'## Build\n\npytest\n\n## Claude\n\nx'
>>> as_read("Read @AGENTS.md first.", "## Build")
'Read @AGENTS.md first.\n\n## Build'
>>> as_read("## Build\n\npytest", "## Other")
'## Build\n\npytest'
>>> as_read("@AGENTS.md", "## Build", path=".claude/CLAUDE.md")
'@AGENTS.md'
>>> as_read("@../AGENTS.md", "## Build", path=".claude/CLAUDE.md")
'## Build'
```

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### opsward.portability.canonical_import(importer)

The `@…` import that names `AGENTS.md` from the file *importer* (root-relative).

```pycon
>>> canonical_import("CLAUDE.md"), canonical_import(".claude/CLAUDE.md")
('@AGENTS.md', '@../AGENTS.md')
```

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### opsward.portability.check_portability(root, , hosts={'aider': HostSpec(name='aider', instruction_files=('CONVENTIONS.md',), rule_dirs=(), reads_agents_md=False, compared=False, skill_target=None), 'claude': HostSpec(name='claude', instruction_files=('CLAUDE.md', '.claude/CLAUDE.md'), rule_dirs=('.claude/rules',), reads_agents_md=False, compared=True, skill_target='claude-code'), 'cline': HostSpec(name='cline', instruction_files=('.clinerules',), rule_dirs=('.clinerules',), reads_agents_md=True, compared=True, skill_target='cline'), 'codex': HostSpec(name='codex', instruction_files=(), rule_dirs=(), reads_agents_md=True, compared=True, skill_target='codex'), 'copilot': HostSpec(name='copilot', instruction_files=('.github/copilot-instructions.md',), rule_dirs=('.github/instructions',), reads_agents_md=True, compared=True, skill_target='copilot'), 'cursor': HostSpec(name='cursor', instruction_files=('.cursorrules',), rule_dirs=('.cursor/rules',), reads_agents_md=True, compared=True, skill_target='cursor'), 'gemini': HostSpec(name='gemini', instruction_files=('GEMINI.md',), rule_dirs=(), reads_agents_md=False, compared=True, skill_target='gemini'), 'windsurf': HostSpec(name='windsurf', instruction_files=('.windsurfrules', '.windsurfrules.md'), rule_dirs=('.windsurf/rules',), reads_agents_md=False, compared=True, skill_target='windsurf'), 'zed': HostSpec(name='zed', instruction_files=('.rules',), rule_dirs=(), reads_agents_md=True, compared=True, skill_target=None)})

`analyze` over what is on disk under *root*, plus `lossy` skill renders.

The library entry point. Read-only.

* **Return type:**
  [`PortabilityReport`](_autosummary/opsward.portability.html.md#opsward.portability.PortabilityReport)

### opsward.portability.claude_md_as_read(scan_result)

The scanned CLAUDE.md as Claude Code reads it (`as_read` at its own path).

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### opsward.portability.claude_md_relpath(scan_result)

The scanned CLAUDE.md’s path relative to the project root (`CLAUDE.md` if unknown).

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### opsward.portability.has_canonical(canonical)

Whether an `AGENTS.md` text says anything (a BOM or whitespace does not).

* **Return type:**
  [`bool`](https://docs.python.org/3/builtins/functions.html#bool)

### opsward.portability.lossy_findings(root, , hosts={'aider': HostSpec(name='aider', instruction_files=('CONVENTIONS.md',), rule_dirs=(), reads_agents_md=False, compared=False, skill_target=None), 'claude': HostSpec(name='claude', instruction_files=('CLAUDE.md', '.claude/CLAUDE.md'), rule_dirs=('.claude/rules',), reads_agents_md=False, compared=True, skill_target='claude-code'), 'cline': HostSpec(name='cline', instruction_files=('.clinerules',), rule_dirs=('.clinerules',), reads_agents_md=True, compared=True, skill_target='cline'), 'codex': HostSpec(name='codex', instruction_files=(), rule_dirs=(), reads_agents_md=True, compared=True, skill_target='codex'), 'copilot': HostSpec(name='copilot', instruction_files=('.github/copilot-instructions.md',), rule_dirs=('.github/instructions',), reads_agents_md=True, compared=True, skill_target='copilot'), 'cursor': HostSpec(name='cursor', instruction_files=('.cursorrules',), rule_dirs=('.cursor/rules',), reads_agents_md=True, compared=True, skill_target='cursor'), 'gemini': HostSpec(name='gemini', instruction_files=('GEMINI.md',), rule_dirs=(), reads_agents_md=False, compared=True, skill_target='gemini'), 'windsurf': HostSpec(name='windsurf', instruction_files=('.windsurfrules', '.windsurfrules.md'), rule_dirs=('.windsurf/rules',), reads_agents_md=False, compared=True, skill_target='windsurf'), 'zed': HostSpec(name='zed', instruction_files=('.rules',), rule_dirs=(), reads_agents_md=True, compared=True, skill_target=None)})

One `lossy` finding per project skill rendered for a host whose format drops fields.

A skill counts as rendered for a host when its translated file exists where the
`skill` package installs it (or, for a shared file such as `GEMINI.md`, when the
file holds the skill’s section). Yields nothing when `skill` is not installed.
Read-only.

* **Return type:**
  [`Iterator`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Iterator)[[`DriftFinding`](_autosummary/opsward.portability.html.md#opsward.portability.DriftFinding)]

### opsward.portability.read_host_files(root, , hosts={'aider': HostSpec(name='aider', instruction_files=('CONVENTIONS.md',), rule_dirs=(), reads_agents_md=False, compared=False, skill_target=None), 'claude': HostSpec(name='claude', instruction_files=('CLAUDE.md', '.claude/CLAUDE.md'), rule_dirs=('.claude/rules',), reads_agents_md=False, compared=True, skill_target='claude-code'), 'cline': HostSpec(name='cline', instruction_files=('.clinerules',), rule_dirs=('.clinerules',), reads_agents_md=True, compared=True, skill_target='cline'), 'codex': HostSpec(name='codex', instruction_files=(), rule_dirs=(), reads_agents_md=True, compared=True, skill_target='codex'), 'copilot': HostSpec(name='copilot', instruction_files=('.github/copilot-instructions.md',), rule_dirs=('.github/instructions',), reads_agents_md=True, compared=True, skill_target='copilot'), 'cursor': HostSpec(name='cursor', instruction_files=('.cursorrules',), rule_dirs=('.cursor/rules',), reads_agents_md=True, compared=True, skill_target='cursor'), 'gemini': HostSpec(name='gemini', instruction_files=('GEMINI.md',), rule_dirs=(), reads_agents_md=False, compared=True, skill_target='gemini'), 'windsurf': HostSpec(name='windsurf', instruction_files=('.windsurfrules', '.windsurfrules.md'), rule_dirs=('.windsurf/rules',), reads_agents_md=False, compared=True, skill_target='windsurf'), 'zed': HostSpec(name='zed', instruction_files=('.rules',), rule_dirs=(), reads_agents_md=True, compared=True, skill_target=None)})

Every host instruction file and rule folder present under *root*. Read-only.

* **Return type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)

### opsward.portability.resolves_to_canonical(import_path, , importer)

Whether `@import_path` in the file *importer* (root-relative) names `AGENTS.md`.

Imports resolve against the importing file’s folder (Claude Code’s rule), so the
same `@AGENTS.md` is the canonical from the root and a missing file from
`.claude/`.

```pycon
>>> resolves_to_canonical("AGENTS.md", importer="CLAUDE.md")
True
>>> resolves_to_canonical("AGENTS.md", importer=".claude/CLAUDE.md")
False
>>> resolves_to_canonical("../AGENTS.md", importer=".claude/CLAUDE.md")
True
```

* **Return type:**
  [`bool`](https://docs.python.org/3/builtins/functions.html#bool)

### opsward.portability.summarize(report)

One diagnose suggestion per drifting render.

* **Return type:**
  [`Iterator`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Iterator)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]


# _autosummary/opsward.recommend.html.md

# opsward.recommend

Recommend skills from the ecosystem based on project tech stack.

Maps detected dependencies and frameworks to curated skill sources.

### Functions

| [`recommend_skills`](_autosummary/opsward.recommend.html.md#opsward.recommend.recommend_skills)(scan_result)   | Recommend ecosystem skills based on detected tech stack.   |
|----------------------------------------------------------------------------------|------------------------------------------------------------|

### Classes

| [`SkillRecommendation`](_autosummary/opsward.recommend.html.md#opsward.recommend.SkillRecommendation)(name, reason, source)   | A recommended skill from the ecosystem.   |
|----------------------------------------------------------------------------------------------|-------------------------------------------|

### *class* opsward.recommend.SkillRecommendation(name, reason, source)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

A recommended skill from the ecosystem.

### opsward.recommend.recommend_skills(scan_result)

Recommend ecosystem skills based on detected tech stack.

```pycon
>>> from pathlib import Path
>>> from opsward.base import ScanResult
>>> recommend_skills(ScanResult(project_root=Path('/tmp/empty')))
[]
```

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`SkillRecommendation`](_autosummary/opsward.recommend.html.md#opsward.recommend.SkillRecommendation)]


# _autosummary/opsward.scan.html.md

# opsward.scan

### opsward.scan(project_root, \*, claude_config_dir=<object object>)

Scan *project_root* and return a ScanResult.

`claude_config_dir` is the user’s Claude Code config dir, whose `skills/` is
the global scope a project skill competes with (shadowing, listing budget). It
defaults to `default_claude_config_dir()`; pass `None` to read nothing
outside the project (tests, portable goldens). Reading it is still read-only.

```pycon
>>> import tempfile, pathlib
>>> r = scan(pathlib.Path(tempfile.mkdtemp()), claude_config_dir=None)
>>> r.project_type, r.global_skills
(<ProjectType.unknown: 'unknown'>, [])
```

* **Return type:**
  [`ScanResult`](_autosummary/opsward.base.html.md#opsward.base.ScanResult)


# _autosummary/opsward.score.html.md

# opsward.score

Pure scoring functions. ScanResult -> DiagnosisReport.

All functions are pure — same input, same output.

### Functions

| [`claude_md_size_overrun`](_autosummary/opsward.score.html.md#opsward.score.claude_md_size_overrun)(content, \*[, ...])       | Return a [`SizeOverrun`](_autosummary/opsward.score.html.md#opsward.score.SizeOverrun) if *content* exceeds *max_chars*, else None.   |
|---------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------|
| [`diagnose`](_autosummary/opsward.score.html.md#opsward.score.diagnose)(scan_result, \*[, ...])                 | Score a ScanResult and return a DiagnosisReport.                                                                     |
| [`docs_dir_hint`](_autosummary/opsward.score.html.md#opsward.score.docs_dir_hint)(sr)                                | Project-relative docs dir to suggest moving sections into.                                                           |
| [`skill_reachability_findings`](_autosummary/opsward.score.html.md#opsward.score.skill_reachability_findings)(sr, \*, suggestions) | Why a project skill may never trigger, as note lines (and one suggestion each).                                      |
| [`validate_hooks_config`](_autosummary/opsward.score.html.md#opsward.score.validate_hooks_config)(cfg)                       | Validate a hooks config against Claude Code's expected shape.                                                        |
| [`validate_skill_spec`](_autosummary/opsward.score.html.md#opsward.score.validate_skill_spec)(skill)                       | Validate a SkillInfo against the agentskills.io specification.                                                       |

### Classes

| [`SizeOverrun`](_autosummary/opsward.score.html.md#opsward.score.SizeOverrun)(chars, max_chars, penalty, ...)   | A CLAUDE.md over its size budget, with the sections worth moving out.   |
|------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------|

### *class* opsward.score.SizeOverrun(chars, max_chars, penalty, sections, docs_dir)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

A CLAUDE.md over its size budget, with the sections worth moving out.

#### describe(, deducted=None)

One-paragraph finding naming the longest sections and where to move them.

`deducted` is the points actually lost (the line-count rule may have
left fewer than `penalty` to take); omit it to leave the figure out.

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### opsward.score.claude_md_size_overrun(content, , max_chars=10000, docs_dir='misc/docs', top=3)

Return a [`SizeOverrun`](_autosummary/opsward.score.html.md#opsward.score.SizeOverrun) if *content* exceeds *max_chars*, else None.

The penalty is proportional to the overrun: `_CONCISE_SIZE_PENALTY_MAX`
points at twice the threshold (at least 1 once over it).

```pycon
>>> claude_md_size_overrun("x" * 11, max_chars=10).penalty
1
>>> claude_md_size_overrun("short", max_chars=10) is None
True
```

* **Return type:**
  [`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`SizeOverrun`](_autosummary/opsward.score.html.md#opsward.score.SizeOverrun)]

### opsward.score.diagnose(scan_result, , claude_md_max_chars=10000, listing_budget_chars=30000)

Score a ScanResult and return a DiagnosisReport.

`claude_md_max_chars` is the CLAUDE.md size above which Conciseness
loses points (see [`claude_md_size_overrun()`](_autosummary/opsward.score.html.md#opsward.score.claude_md_size_overrun)).

```pycon
>>> from pathlib import Path
>>> from opsward.base import ScanResult
>>> r = diagnose(ScanResult(project_root=Path('/tmp/empty')))
>>> r.grade
'F'
```

* **Return type:**
  [`DiagnosisReport`](_autosummary/opsward.base.html.md#opsward.base.DiagnosisReport)

### opsward.score.docs_dir_hint(sr)

Project-relative docs dir to suggest moving sections into.

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### opsward.score.skill_reachability_findings(sr, , suggestions, listing_budget_chars=30000)

Why a project skill may never trigger, as note lines (and one suggestion each).

Three shapes from the #23 report: a project skill **shadowed** by a global one of the
same name (Claude Code resolves personal > project, verified in a fresh session); an
**unmigrated bridge** (a real directory under `.claude/skills` while the repo also
holds the skill at its canonical location); and a **listing budget** that the global
scope plus this project’s skills cannot fit, so descriptions get dropped
least-invoked-first. The global scope comes from `ScanResult.global_skills`;
with none (`scan(..., claude_config_dir=None)`) only the bridge check runs.

```pycon
>>> from pathlib import Path
>>> from opsward.base import ScanResult, SkillInfo
>>> g = SkillInfo(name='lint', path=Path('/g/lint'), has_skill_md=True, description='Global lint.', real_path=Path('/g/lint'))
>>> p = SkillInfo(name='lint', path=Path('/p/.claude/skills/lint'), has_skill_md=True, description='Project lint.', real_path=Path('/p/.claude/skills/lint'))
>>> sr = ScanResult(project_root=Path('/p'), skills=[p], global_skills=[g])
>>> s = []
>>> skill_reachability_findings(sr, suggestions=s)[0][:46]
'Skill "lint": shadowed by the global skill of '
>>> len(s)
1
```

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

### opsward.score.validate_hooks_config(cfg)

Validate a hooks config against Claude Code’s expected shape.

Returns a list of human-readable violation strings (empty = valid). Catches
the silent-failure traps: a non-string `matcher`, an unknown event name,
or an entry with no runnable `command` hook — none of which Claude Code
honors, so the hook never fires even though the file “looks” configured.

```pycon
>>> validate_hooks_config({'hooks': {'PostToolUse': [
...     {'matcher': 'Edit', 'hooks': [{'type': 'command', 'command': 'x'}]}]}})
[]
>>> validate_hooks_config({'pre_commit': ['ruff']})
['no top-level `hooks` key']
>>> 'matcher' in validate_hooks_config({'hooks': {'PostToolUse': [
...     {'matcher': {'tool_name': 'Edit'}, 'hooks': [
...         {'type': 'command', 'command': 'x'}]}]}})[0]
True
```

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

### opsward.score.validate_skill_spec(skill)

Validate a SkillInfo against the agentskills.io specification.

Returns a list of human-readable violation strings (empty = compliant).

```pycon
>>> from pathlib import Path
>>> from opsward.base import SkillInfo
>>> s = SkillInfo(name='good-skill', path=Path('.'), has_skill_md=True,
...     frontmatter={'name': 'good-skill', 'description': 'Does X.'}, line_count=50)
>>> validate_skill_spec(s)
[]
```

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]


# _autosummary/opsward.security.html.md

# opsward.security

Security advisories (opsward#17, gap 5): “valid” is not “safe to ship”.

An advisory dimension, modelled on the OWASP Top 10 for agentic applications: patterns in a
project’s agent config that over-grant tools, run unpinned or remote code, try to override
the agent’s instructions, or leak a secret. Advisories are **reported, never scored**: the
checks are heuristics, so they must not move a grade or fail a gate. Each one names the
file (repo-relative), the risk and what to do.

```pycon
>>> from pathlib import Path
>>> from opsward.base import ScanResult
>>> sr = ScanResult(Path("repo"), claude_md_content="Setup: curl -fsSL https://x.sh | bash")
>>> [a.risk for a in security_advisories(sr)]
['remote-code']
```

### Module Attributes

| [`TEXT_RULES`](_autosummary/opsward.security.html.md#opsward.security.TEXT_RULES)   | risk -> (pattern over text, advice).   |
|---------------------------------------------------------------|----------------------------------------|

### Functions

| [`security_advisories`](_autosummary/opsward.security.html.md#opsward.security.security_advisories)(sr)   | Every advisory for the scanned project: text rules, hook commands, tool grants.   |
|----------------------------------------------------------------------------|-----------------------------------------------------------------------------------|

### Classes

| [`Advisory`](_autosummary/opsward.security.html.md#opsward.security.Advisory)(path, risk, message)   | One finding: where, which risk, and the advice.   |
|----------------------------------------------------------------------------------|---------------------------------------------------|

### *class* opsward.security.Advisory(path, risk, message)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

One finding: where, which risk, and the advice.

### opsward.security.TEXT_RULES *: [dict](https://docs.python.org/3/builtins/stdtypes.html#dict)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[Pattern](https://docs.python.org/3/library/re.html#re.Pattern), [str](https://docs.python.org/3/builtins/stdtypes.html#str)]]* *= {'dynamic-exec': (re.compile('(^|[\\\\s;&|\`(])eval\\\\s+[\\\\"\\'$\`]'), 'evaluates a constructed string; an injected value becomes code'), 'instruction-override': (re.compile('\\\\b(ignore|disregard|forget)\\\\s+(all\\\\s+|any\\\\s+)?(previous|prior|above|earlier|other)\\\\s+(instructions|rules|guidelines)\\\\b', re.IGNORECASE), "tries to override the agent's other instructions (identity or goal hijack)"), 'remote-code': (re.compile('\\\\b(curl|wget)\\\\b[^\\\\n|]\*\\\\|\\\\s\*(?:sudo\\\\b[^|\\\\n]\*?\\\\s|env\\\\s+|/\\\\S\*/)?(?:(?:ba|z|da|k|a)?sh\\\\b|(?:python[\\\\d.]\*|node|perl|ruby)(?=[ \\\\t]\*(?:-[ \\\\t]\*)?(?:$|[;&|)])))|(?:ba|z)?sh\\\\s+<\\\\(\\\\s\*(curl|wget, re.MULTILINE), 'runs a download straight from the network; pin a checksum or vendor the script'), 'secret': (re.compile('\\\\b(sk-(ant-)?[A-Za-z0-9_-]{20,}|ghp_[A-Za-z0-9]{30,}|github_pat_[A-Za-z0-9_]{30,}|AKIA[0-9A-Z]{16}|xox[bpa]-[A-Za-z0-9-]{20,})'), 'looks like a credential committed in plain text; rotate it and load it from the environment')}*

risk -> (pattern over text, advice). Text checks run over CLAUDE.md, AGENTS.md, every
SKILL.md, every agent definition and every hooks command.

### opsward.security.security_advisories(sr)

Every advisory for the scanned project: text rules, hook commands, tool grants.

* **Return type:**
  [`Iterator`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Iterator)[[`Advisory`](_autosummary/opsward.security.html.md#opsward.security.Advisory)]


# _autosummary/opsward.subagents.html.md

# opsward.subagents

Reuse a skill as a subagent: declare it in the skill, generate the twin, check the sync.

A Claude Code subagent is a Markdown file under `.claude/agents/` whose frontmatter
can *preload* a skill (`skills: [name]` injects the full `SKILL.md` body). So a skill
that is also useful in its own context needs nothing but a thin twin that preloads it,
restricts tools, picks a model and states the reply contract. The single source of
truth stays in the skill: it opts in with spec-legal `metadata` keys (the Agent Skills
spec allows string pairs there, and other hosts ignore them). Quote the values so a
strict validator sees strings:

```default
---
name: fleet-sweep
description: ...
metadata:
  subagent: "true"
  subagent-tools: "Bash, Read, Grep"
  subagent-model: "sonnet"
  subagent-reply-lines: "5"
  subagent-name: "fleet-sweeper"
---
```

Only `subagent` is required; the defaults are `Read, Grep, Glob, Bash`, no model
(the host picks), 5 lines, and the skill’s own name. Three pure functions do the
work, so `generate` and `maintain` share one source: [`subagent_spec()`](_autosummary/opsward.subagents.html.md#opsward.subagents.subagent_spec) reads
the declaration, [`render_subagent()`](_autosummary/opsward.subagents.html.md#opsward.subagents.render_subagent) renders the twin (with a marker line
carrying a hash of what it was rendered from), and [`twin_status()`](_autosummary/opsward.subagents.html.md#opsward.subagents.twin_status) classifies
every skill/agent pair in a scan. Decision record:
`misc/docs/decisions/0009-skills-declare-their-subagent-twin.md`.

### Functions

| [`check_subagent_twins`](_autosummary/opsward.subagents.html.md#opsward.subagents.check_subagent_twins)(sr)                    | `maintain` check: every twin that is not generated and current.                       |
|----------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------|
| [`render_subagent`](_autosummary/opsward.subagents.html.md#opsward.subagents.render_subagent)(spec, \*, source)           | Render the twin agent file for *spec*; *source* is the skill's repo-relative path.    |
| [`subagent_files`](_autosummary/opsward.subagents.html.md#opsward.subagents.subagent_files)(sr)                          | Yield the twin agent file for every validly declared skill (missing or not).          |
| [`subagent_spec`](_autosummary/opsward.subagents.html.md#opsward.subagents.subagent_spec)(skill)                        | Return the twin a skill declares under `metadata`, or `None`.                         |
| [`twin_for_rendered_skill`](_autosummary/opsward.subagents.html.md#opsward.subagents.twin_for_rendered_skill)(skill_md_text, ...) | The twin of a skill that is about to be written (so one `generate` run creates both). |
| [`twin_status`](_autosummary/opsward.subagents.html.md#opsward.subagents.twin_status)(sr)                             | Classify every declared twin and every hand-written agent that preloads a skill.      |
| [`twin_summary`](_autosummary/opsward.subagents.html.md#opsward.subagents.twin_summary)(sr)                            | Counts by state, for the diagnosis note.                                              |

### Classes

| [`SubagentSpec`](_autosummary/opsward.subagents.html.md#opsward.subagents.SubagentSpec)(skill_name, name, description, ...)   | What a skill declared about its subagent twin, with defaults applied.                           |
|-----------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------|
| [`TwinStatus`](_autosummary/opsward.subagents.html.md#opsward.subagents.TwinStatus)(skill, agent, state[, declared, ...])   | One skill/agent pair as [`twin_status()`](_autosummary/opsward.subagents.html.md#opsward.subagents.twin_status) sees it. |

### *class* opsward.subagents.SubagentSpec(skill_name, name, description, tools, model, reply_lines)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

What a skill declared about its subagent twin, with defaults applied.

#### problems()

Why this declaration cannot be rendered (empty = fine).

```pycon
>>> SubagentSpec('s', '../x', '', 'Bash: all', None, 0).problems()
['no frontmatter description (the twin reuses it as its trigger)', 'subagent-name `../x` is not a valid agent name', 'subagent-reply-lines must be at least 1', 'subagent-tools must not contain `: `']
```

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

#### source_hash()

Hash of everything the rendered twin depends on, so drift is detectable.

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### *class* opsward.subagents.TwinStatus(skill, agent, state, declared=False, content='', detail='', path='')

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

One skill/agent pair as [`twin_status()`](_autosummary/opsward.subagents.html.md#opsward.subagents.twin_status) sees it.

### opsward.subagents.check_subagent_twins(sr)

`maintain` check: every twin that is not generated and current.

* **Return type:**
  [`Iterable`](https://docs.python.org/3/library/typing.html#typing.Iterable)[[`MaintenanceSuggestion`](_autosummary/opsward.base.html.md#opsward.base.MaintenanceSuggestion)]

### opsward.subagents.render_subagent(spec, , source)

Render the twin agent file for *spec*; *source* is the skill’s repo-relative path.

The body is deliberately short: the skill’s full content is preloaded by the host
through the `skills` field, so the twin only adds the context contract.

```pycon
>>> spec = SubagentSpec('sweep', 'sweep', 'Sweep and report.', 'Bash', 'haiku', 3)
>>> text = render_subagent(spec, source='.claude/skills/sweep/SKILL.md')
>>> text.splitlines()[1:4]
['name: sweep', 'description: Sweep and report.', 'tools: Bash']
>>> 'skills: [sweep]' in text and 'at most 3 lines' in text
True
```

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### opsward.subagents.subagent_files(sr)

Yield the twin agent file for every validly declared skill (missing or not).

Callers that must not overwrite (the CLI) skip existing targets; the marker in a
generated file is what [`twin_status()`](_autosummary/opsward.subagents.html.md#opsward.subagents.twin_status) uses to tell a stale twin from a
hand-written one. Invalid and duplicate declarations yield nothing; `maintain`
reports them.

* **Return type:**
  [`Iterator`](https://docs.python.org/3/library/typing.html#typing.Iterator)[[`GeneratedFile`](_autosummary/opsward.base.html.md#opsward.base.GeneratedFile)]

### opsward.subagents.subagent_spec(skill)

Return the twin a skill declares under `metadata`, or `None`.

```pycon
>>> from pathlib import Path
>>> from opsward.base import SkillInfo
>>> s = SkillInfo(name='sweep', path=Path('/x/sweep'), has_skill_md=True,
...     description='Sweep the fleet and report.',
...     frontmatter={'name': 'sweep', 'metadata': {'subagent': 'true', 'subagent-model': 'haiku'}})
>>> spec = subagent_spec(s)
>>> (spec.name, spec.tools, spec.model, spec.reply_lines)
('sweep', 'Read, Grep, Glob, Bash', 'haiku', 5)
>>> subagent_spec(SkillInfo(name='plain', path=Path('/x/plain'))) is None
True
```

* **Return type:**
  [`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`SubagentSpec`](_autosummary/opsward.subagents.html.md#opsward.subagents.SubagentSpec)]

### opsward.subagents.twin_for_rendered_skill(skill_md_text, skill_md_path, root)

The twin of a skill that is about to be written (so one `generate` run creates both).

```pycon
>>> from pathlib import Path
>>> text = '---\nname: s\ndescription: Do the thing.\nmetadata:\n  subagent: "true"\n---\nbody\n'
>>> gf = twin_for_rendered_skill(text, Path('/p/.claude/skills/s/SKILL.md'), Path('/p'))
>>> gf.target_path.as_posix(), 'skills: [s]' in gf.content
('/p/.claude/agents/s.md', True)
```

* **Return type:**
  [`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`GeneratedFile`](_autosummary/opsward.base.html.md#opsward.base.GeneratedFile)]

### opsward.subagents.twin_status(sr)

Classify every declared twin and every hand-written agent that preloads a skill.

- `invalid`: the declaration cannot be rendered (see `SubagentSpec.problems`).
- `duplicate`: two skills declare the same twin name; the first wins, the rest are reported.
- `missing`: the skill declares a twin and no agent file exists.
- `stale`: the agent file was generated from a declaration that has since changed.
- `in_sync`: generated and current.
- `handwritten`: an agent opsward did not generate, either carrying the name a skill
  declares for its twin (`declared=True`), or sharing a non-declaring skill’s name or
  preloading it via `skills:` (`declared=False`).

* **Return type:**
  [`Iterator`](https://docs.python.org/3/library/typing.html#typing.Iterator)[[`TwinStatus`](_autosummary/opsward.subagents.html.md#opsward.subagents.TwinStatus)]

### opsward.subagents.twin_summary(sr)

Counts by state, for the diagnosis note.

```pycon
>>> from pathlib import Path
>>> twin_summary(ScanResult(project_root=Path('/tmp/empty')))
{}
```

* **Return type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`int`](https://docs.python.org/3/builtins/functions.html#int)]


# _autosummary/opsward.util.html.md

# opsward.util

Shared helpers for opsward.

### Module Attributes

| [`IGNORE_PATH_MARKER`](_autosummary/opsward.util.html.md#opsward.util.IGNORE_PATH_MARKER)   | Put this on a line (as `<!-- opsward: ignore-path -->` or `# opsward: ignore-path`) and the paths on it are not checked; alone on its line, it covers the next line too.   |
|-----------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|

### Functions

| [`checked_lines`](_autosummary/opsward.util.html.md#opsward.util.checked_lines)(content, \*[, marker])     | `content` without the lines an ignore-path marker covers.                           |
|-------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------|
| [`extract_paths`](_autosummary/opsward.util.html.md#opsward.util.extract_paths)(content)                   | Plausible repo-relative file paths cited in markdown, minus URLs and ignored lines. |
| [`iter_files`](_autosummary/opsward.util.html.md#opsward.util.iter_files)(directory, \*[, suffix, ...]) | Yield files in *directory*, optionally filtered by suffix.                          |
| [`iter_subdirs`](_autosummary/opsward.util.html.md#opsward.util.iter_subdirs)(directory)                  | Yield immediate subdirectories of *directory*, sorted by name.                      |
| [`read_json_safe`](_autosummary/opsward.util.html.md#opsward.util.read_json_safe)(path)                     | Read a JSON file, returning None on any failure.                                    |
| [`read_text_safe`](_autosummary/opsward.util.html.md#opsward.util.read_text_safe)(path)                     | Read a text file, returning '' if it doesn't exist or can't be decoded.             |

### opsward.util.IGNORE_PATH_MARKER *= 'opsward: ignore-path'*

Put this on a line (as `<!-- opsward: ignore-path -->` or `# opsward: ignore-path`)
and the paths on it are not checked; alone on its line, it covers the next line too.

### opsward.util.checked_lines(content, , marker='opsward: ignore-path')

`content` without the lines an ignore-path marker covers.

A marker quoted in backticks (prose *about* the marker) is not a marker.

```pycon
>>> checked_lines("a/b.py\nold/c.py <!-- opsward: ignore-path -->\n# opsward: ignore-path\ntmp/d.py\ne/f.py")
'a/b.py\ne/f.py'
>>> checked_lines("<!-- opsward: ignore-path -->\n<!-- opsward: ignore-path -->\nx/y.py\nz/w.py")
'z/w.py'
>>> checked_lines("Use `<!-- opsward: ignore-path -->` on src/a.py")
'Use `<!-- opsward: ignore-path -->` on src/a.py'
```

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### opsward.util.extract_paths(content)

Plausible repo-relative file paths cited in markdown, minus URLs and ignored lines.

The one extractor behind the currency score, the cross-reference check, the stale-path
finding and the ADR drift check, so `opsward: ignore-path` silences all of them.

```pycon
>>> extract_paths("See `src/a.py`, https://x.io/b.html and ./docs/c.md")
['src/a.py', './docs/c.md']
```

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

### opsward.util.iter_files(directory, , suffix='', recursive=False, \_seen=None)

Yield files in *directory*, optionally filtered by suffix.

`recursive=True` walks subdirectories too, depth-first in name order. Hidden
folders are skipped (opsward’s choice: `.trash` and the like are not agents),
a folder already visited through a symlink is not re-entered, and a folder that
cannot be read is skipped rather than raised.

### opsward.util.iter_subdirs(directory)

Yield immediate subdirectories of *directory*, sorted by name.

### opsward.util.read_json_safe(path)

Read a JSON file, returning None on any failure.

* **Return type:**
  [`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)]

### opsward.util.read_text_safe(path)

Read a text file, returning ‘’ if it doesn’t exist or can’t be decoded.

```pycon
>>> from pathlib import Path
>>> read_text_safe(Path('/nonexistent/file.txt'))
''
```

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)


# _autosummary/opsward.weekly.html.md

# opsward.weekly

The weekly look: the agent setup’s five numbers, against last week, and one proposed change.

The `setup-self-improvement` loop asks for one improvement a week, chosen from five numbers
and passed through a human gate. This module prints the numbers; the user picks the change.
It only reads, and the only thing it writes is its own history (one JSON file per run).

The five numbers, over the last `days` (30 by default):

1. **Search before write**: of the new source files an agent wrote, the share written after
   the session had searched what the fleet already has (an Explore agent, a search skill
   such as `fleet-protocol`, or `ir`/`projreg`/`priv find`/`gh search` in Bash).
   Local greps are counted beside it as context: agents run them in nearly every session.
   A file counts as new when the session writes it without having read or edited it first.
2. **Skills never invoked**: the share of installed skills no session invoked (with the
   invocation count per skill). Never-invoked skills are candidates for name-only or
   deletion, not for a longer description.
3. **CLAUDE.md before edit**: of the packages a session edited, the share whose nearest
   `CLAUDE.md` the session had loaded first (its cwd is inside the package, or it read the
   file before the first edit).
4. **Component issues per week**: issues titled `Component: ...` the owner filed.
5. **Corrections written back**: `writeback-seen` events over the triggers (`trigger-prompt`,
   `trigger-fix-commit`) in the fix-at-source hook’s event log.

Only metadata is read: tool names, file paths, skill names, timestamps. Never prompt or file
text. Every source is a keyword argument (`sessions`, `skills_dirs`, `search`,
`events`, `history`), so a caller or a test can point it elsewhere.

```pycon
>>> NUMBERS[0].key, NUMBERS[1].better
('search_before_write', 'lower')
```

### Module Attributes

| [`SEARCH_AGENTS`](_autosummary/opsward.weekly.html.md#opsward.weekly.SEARCH_AGENTS)      | an Explore agent, a search skill, or a fleet search command at the start of a Bash command (not after a pipe).   |
|---------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------|
| [`LOCAL_SEARCH_TOOLS`](_autosummary/opsward.weekly.html.md#opsward.weekly.LOCAL_SEARCH_TOOLS) | Grep and Glob, or rg/grep/find/fd starting a Bash command.                                                       |
| [`Session`](_autosummary/opsward.weekly.html.md#opsward.weekly.Session)            | `(session_id, records)`.                                                                                         |

### Functions

| [`claude_md_before_edit`](_autosummary/opsward.weekly.html.md#opsward.weekly.claude_md_before_edit)(sessions, \*[, ...])     | Number 3: (session, package) pairs whose nearest `CLAUDE.md` was loaded before the first edit.                                                                 |
|-------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [`component_issues`](_autosummary/opsward.weekly.html.md#opsward.weekly.component_issues)(\*, days, now[, search])      | Number 4: `Component:` issues filed in the window, and per week.                                                                                               |
| [`corrections`](_autosummary/opsward.weekly.html.md#opsward.weekly.corrections)(events, \*, days, now)             | Number 5: corrections written back (`writeback-seen`) over triggers, in the window.                                                                            |
| [`gh_component_issues`](_autosummary/opsward.weekly.html.md#opsward.weekly.gh_component_issues)(\*, since[, title, limit]) | How many issues the `gh` user filed since `since` (a date) whose title has `title`.                                                                            |
| [`installed_skills`](_autosummary/opsward.weekly.html.md#opsward.weekly.installed_skills)(dirs)                         | Skill names: the folders holding a `SKILL.md` directly under each of `dirs`.                                                                                   |
| [`propose`](_autosummary/opsward.weekly.html.md#opsward.weekly.propose)(result, previous)                      | One target condition: the number that got worse the most since last time; with no history, the weakest of the shares (a share's distance from its best value). |
| [`read_events`](_autosummary/opsward.weekly.html.md#opsward.weekly.read_events)([path])                            | The fix-at-source hook's events (`$FIX_AT_SOURCE_LOG`, else its default path).                                                                                 |
| [`render`](_autosummary/opsward.weekly.html.md#opsward.weekly.render)(result)                                 | The weekly look as a markdown page: the numbers, the change since last time, one proposal.                                                                     |
| [`search_before_write`](_autosummary/opsward.weekly.html.md#opsward.weekly.search_before_write)(sessions, \*[, suffixes])  | Number 1: new source files written after a fleet search, over all new source files.                                                                            |
| [`skill_use`](_autosummary/opsward.weekly.html.md#opsward.weekly.skill_use)(sessions, \*, installed)             | Number 2: invocations per skill, and the installed skills no session invoked.                                                                                  |
| [`tool_uses`](_autosummary/opsward.weekly.html.md#opsward.weekly.tool_uses)(records)                             | `(cwd, tool name, input)` for every tool call in a transcript, in order.                                                                                       |
| [`transcripts`](_autosummary/opsward.weekly.html.md#opsward.weekly.transcripts)([home, days])                      | Top-level Claude Code transcripts under `home` (default `~/.claude`) modified within `days`, as `(session_id, records)`; a session found twice is read once.   |
| [`weekly`](_autosummary/opsward.weekly.html.md#opsward.weekly.weekly)(\*[, days, home, sessions, ...])        | The five numbers over the last `days`, last time's values, and one proposed change.                                                                            |

### Classes

| [`Number`](_autosummary/opsward.weekly.html.md#opsward.weekly.Number)(key, label, field, better, target)   | One of the five: where its value is in the result, which way is better, and the change it suggests.   |
|----------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------|

### opsward.weekly.LOCAL_SEARCH_TOOLS *= ('Grep', 'Glob')*

Grep and Glob, or rg/grep/find/fd starting a Bash command. Agents do this
in nearly every session, so it is reported as context, not as the number.

* **Type:**
  A local search

### *class* opsward.weekly.Number(key, label, field, better, target)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

One of the five: where its value is in the result, which way is better, and the change it suggests.

### opsward.weekly.SEARCH_AGENTS *= ('Explore',)*

an Explore agent, a
search skill, or a fleet search command at the start of a Bash command (not after a pipe).

* **Type:**
  A search of what the fleet already has (the fleet-protocol meaning)

### opsward.weekly.Session

`(session_id, records)`.

* **Type:**
  One transcript

alias of [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)]

### opsward.weekly.claude_md_before_edit(sessions, , is_file=None, stop='~')

Number 3: (session, package) pairs whose nearest `CLAUDE.md` was loaded before the first edit.

Loaded means the session’s cwd is inside the package (Claude Code loads it), or the session
read the file. `stop` is where the search for a `CLAUDE.md` ends (default: home).

* **Return type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)

### opsward.weekly.component_issues(\*, days, now, search=<function gh_component_issues>)

Number 4: `Component:` issues filed in the window, and per week.

* **Return type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)

### opsward.weekly.corrections(events, , days, now)

Number 5: corrections written back (`writeback-seen`) over triggers, in the window.

* **Return type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)

### opsward.weekly.gh_component_issues(, since, title='Component:', limit=500)

How many issues the `gh` user filed since `since` (a date) whose title has `title`.

* **Return type:**
  [`int`](https://docs.python.org/3/builtins/functions.html#int)

### opsward.weekly.installed_skills(dirs)

Skill names: the folders holding a `SKILL.md` directly under each of `dirs`.

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

### opsward.weekly.propose(result, previous)

One target condition: the number that got worse the most since last time; with no
history, the weakest of the shares (a share’s distance from its best value).

```pycon
>>> r = {"search_before_write": {"ratio": 0.9}, "corrections": {"ratio": 0.4}}
>>> propose(r, None)["key"]
'corrections'
>>> propose(r, {"numbers": {"search_before_write": 1.0, "corrections": 0.4}})["key"]
'search_before_write'
```

* **Return type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)

### opsward.weekly.read_events(path=None)

The fix-at-source hook’s events (`$FIX_AT_SOURCE_LOG`, else its default path).

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)]

### opsward.weekly.render(result)

The weekly look as a markdown page: the numbers, the change since last time, one proposal.

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### opsward.weekly.search_before_write(sessions, , suffixes=('.py', '.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs', '.rs', '.swift', '.go', '.kt', '.java', '.rb', '.sh', '.c', '.cc', '.cpp', '.h'))

Number 1: new source files written after a fleet search, over all new source files.

`local_first` (after at least a Grep, a Glob or an `rg`) is context.

```pycon
>>> def use(name, **args):
...     return {"type": "assistant", "message": {"content": [{"type": "tool_use", "name": name, "input": args}]}}
>>> s = [use("Write", file_path="/a.py"), use("Grep", pattern="x"), use("Write", file_path="/b.py"),
...      use("Bash", command="projreg find x"), use("Write", file_path="/c.py"), use("Write", file_path="/c.py")]
>>> search_before_write([("s", s)])
{'new_source_files': 3, 'searched_first': 1, 'ratio': 0.333, 'local_first': 2}
```

* **Return type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)

### opsward.weekly.skill_use(sessions, , installed)

Number 2: invocations per skill, and the installed skills no session invoked.

* **Return type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)

### opsward.weekly.tool_uses(records)

`(cwd, tool name, input)` for every tool call in a transcript, in order.

```pycon
>>> rec = {"type": "assistant", "cwd": "/w", "message": {"content": [
...     {"type": "tool_use", "name": "Grep", "input": {"pattern": "x"}}]}}
>>> list(tool_uses([rec]))
[('/w', 'Grep', {'pattern': 'x'})]
```

* **Return type:**
  [`Iterator`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Iterator)[[`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`Mapping`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Mapping)]]

### opsward.weekly.transcripts(home=None, , days=30)

Top-level Claude Code transcripts under `home` (default `~/.claude`) modified within
`days`, as `(session_id, records)`; a session found twice is read once.

* **Return type:**
  [`Iterator`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Iterator)[[`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)]]

### opsward.weekly.weekly(\*, days=30, home=None, sessions=None, skills_dirs=None, search=<function gh_component_issues>, events=None, history=None, save=True, now=None)

The five numbers over the last `days`, last time’s values, and one proposed change.

Saves this run’s numbers to `history` (`$OPSWARD_WEEKLY_DIR`, else
`~/.local/share/opsward/weekly`) as `YYYY-MM-DD.json` unless `save=False`.

* **Return type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)


# about-this-build.html.md

<!-- generated by epythet -->

# About this build

This documentation was built on **2026-11-24 01:19 UTC** from commit <a href="https://github.com/addaix/opsward/commit/e9c82cd74ccbfe727cc79659f6eb6bf5f90db225"><code>e9c82cd</code></a> on branch <code>main</code>, for **opsward 0.0.46** (from <code>pyproject.toml</code>).

#### WARNING
The documentation and the package may be misaligned:

- The documented version (0.0.46) is behind the latest release on PyPI (0.0.47): `pip install opsward` gives newer code than these docs describe.

## Source

|                     |                                                                                                                                                       |
|---------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------|
| Commit              | <a href="https://github.com/addaix/opsward/commit/e9c82cd74ccbfe727cc79659f6eb6bf5f90db225"><code>e9c82cd74ccbfe727cc79659f6eb6bf5f90db225</code></a> |
| Branch              | <code>main</code>                                                                                                                                     |
| Tags at this commit | none                                                                                                                                                  |
| Working tree        | clean                                                                                                                                                 |
| Remote              | <code>https://github.com/addaix/opsward</code>                                                                                                        |

## Continuous integration

|              |                                                                                            |
|--------------|--------------------------------------------------------------------------------------------|
| Repository   | <code>addaix/opsward</code>                                                                |
| Run          | <a href="https://github.com/addaix/opsward/actions/runs/45303990172">45303990172</a>       |
| Ref          | <code>refs/heads/main</code>                                                               |
| Event commit | <code>e9c82cd74ccbfe727cc79659f6eb6bf5f90db225</code> (in the history of the built commit) |

## Tools

|          |         |
|----------|---------|
| epythet  | 0.2.25  |
| Sphinx   | 9.1.1   |
| docutils | 0.22.4  |
| Python   | 3.12.16 |

## Configuration as resolved

|               |                                                                  |
|---------------|------------------------------------------------------------------|
| theme         | <code>auto</code> (Sphinx theme <code>shibuya</code>)            |
| accent        | <code>#8f3254</code>                                             |
| api_generator | <code>autosummary</code>                                         |
| ignore        | <code>tests/</code>, <code>scrap/</code>, <code>examples/</code> |
| agent_outputs | <code>true</code>                                                |
| aggregates    | <code>md</code>                                                  |
| ai_artifacts  | <code>true</code>                                                |

## Package on PyPI

Latest release: <a href="https://pypi.org/project/opsward/0.0.47/">0.0.47</a>, newer than the documented version (0.0.46).

## Reproduce

```bash
git clone https://github.com/addaix/opsward && cd opsward
git checkout e9c82cd74ccbfe727cc79659f6eb6bf5f90db225
pip install "epythet==0.2.25"
epythet quickstart . --ignore tests/ scrap/ examples/
```

The same data, for machines: <a href="build_info.json"><code>build_info.json</code></a> (schema version 1).


# ai-agents.html.md

<!-- generated by epythet -->

# For AI agents

`opsward` ships artifacts for coding agents alongside its code. This page lists
them, says where each lives in the repository, and points at the
machine-readable copies of this documentation.

## Skills

Skills are folders holding a `SKILL.md` (the [Agent Skills](https://agentskills.io) format): a description that tells an agent when to use it and a body with the procedure. Install one into your agent with `gh skill` (any host: `--agent claude-code`, `copilot`, `cursor`, `codex`, `gemini`), or use the copy bundled in the wheel.

### `opsward`

Run opsward to assess and improve this project’s AI agent setup. Use when the user says ‘opsward’, ‘check my setup’, ‘improve my AI config’, or wants a full audit and remediation.

Source: [`.claude/skills/opsward`](https://github.com/addaix/opsward/tree/HEAD/.claude/skills/opsward).

### `opsward-add-drift-check`

Add a new staleness or drift check to opsward’s maintain stage (maintain.py), so `opsward maintain` reports a new kind of MaintenanceSuggestion — a stale reference, an out-of-sync index, an outdated or empty doc, an incomplete skill. Use when extending what `opsward maintain` detects, adding a suggestion category, or deciding whether a finding belongs in maintain or in the diagnose score. Covers the check-generator shape, categories, the diff field, the exit-code contract, and the CLI golden it can move.

Source: [`.claude/skills/opsward-add-drift-check`](https://github.com/addaix/opsward/tree/HEAD/.claude/skills/opsward-add-drift-check).

### `opsward-add-recommendation`

Add a tech-stack→skill mapping to opsward’s recommendation engine in recommend.py, so `opsward recommend` suggests an ecosystem skill when it detects a dependency or framework (e.g. Supabase, FastAPI, Tailwind). Use when extending the curated `_RECOMMENDATIONS` list, adding a new detection signal, or changing where recommended skills are sourced from.

Source: [`.claude/skills/opsward-add-recommendation`](https://github.com/addaix/opsward/tree/HEAD/.claude/skills/opsward-add-recommendation).

### `opsward-add-scan-field`

Add a new fact that opsward learns about a target project — a field on ScanResult populated by scan.py — and consume it downstream in score/generate/maintain/recommend. Use when a new check, score, template variable, or drift detector needs data the scan does not yet collect (a new config file, a new .claude/ inventory, a project signal), or when changing project-type detection. Covers the read-only contract, the dataclass-default rule, the util read helpers, and the CLI goldens a scan change can move.

Source: [`.claude/skills/opsward-add-scan-field`](https://github.com/addaix/opsward/tree/HEAD/.claude/skills/opsward-add-scan-field).

### `opsward-add-scoring`

Add or adjust opsward’s quality scoring — a CLAUDE.md sub-dimension, a whole weighted component, or the skill/spec validation rules — in score.py. Use when changing how `opsward diagnose` grades a project, tuning weights or point thresholds, adding a new ComponentScore, or modifying validate_skill_spec. Explains the pure-function contract, the weighting math, and the constants to keep balanced.

Source: [`.claude/skills/opsward-add-scoring`](https://github.com/addaix/opsward/tree/HEAD/.claude/skills/opsward-add-scoring).

### `opsward-add-template`

Add or edit a generation template in opsward — a doc template (architecture.md, testing.md, …), an installable skill (SKILL.md), or an agent definition — and wire it into generate.py so opsward produces it. Use when adding a new artifact opsward should scaffold into target projects, adding a template variable, or changing what `opsward generate` / `install-skills` emit. Covers string.Template rules and the python/jsts/shared layout.

Source: [`.claude/skills/opsward-add-template`](https://github.com/addaix/opsward/tree/HEAD/.claude/skills/opsward-add-template).

### `opsward-dev`

Contributor guide for developing opsward itself — its architecture, hard invariants, and where each kind of change goes. Use when modifying opsward’s own source (scan/score/generate/maintain/recommend/cli), adding a template, scoring dimension, or skill recommendation, or when unsure which module owns a change. NOT for running opsward on a target project (use the `opsward` skill for that).

Source: [`.claude/skills/opsward-dev`](https://github.com/addaix/opsward/tree/HEAD/.claude/skills/opsward-dev).

### `opsward-diagnose`

Diagnose the health of this project’s AI agent setup. Use when the user asks to check, audit, or score the project’s CLAUDE.md, skills, docs, or agent configuration.

Source: [`.claude/skills/opsward-diagnose`](https://github.com/addaix/opsward/tree/HEAD/.claude/skills/opsward-diagnose).

### `opsward-generate`

Generate missing AI setup artifacts for this project. Use when the user asks to scaffold, create, or bootstrap CLAUDE.md, docs, skills, or agent configuration.

Source: [`.claude/skills/opsward-generate`](https://github.com/addaix/opsward/tree/HEAD/.claude/skills/opsward-generate).

### `opsward-maintain`

Check documentation and AI setup for staleness, drift, or inconsistency. Use when the user asks to maintain, refresh, or update project docs and AI configuration.

Source: [`.claude/skills/opsward-maintain`](https://github.com/addaix/opsward/tree/HEAD/.claude/skills/opsward-maintain).

### `opsward-subagents`

Decide which of a repo’s skills should also run as subagents (in their own context), declare it in each skill’s frontmatter, and generate or refresh the twin agent files with opsward. Use when a skill does bulky or read-heavy work whose output should stay out of the main context, when a skill needs a tool restriction or a cheaper model, when a hand-written agent duplicates a skill, when `opsward maintain` reports a `subagent_twin` finding, or when asked “should this skill be a subagent”, “make this skill usable as a subagent”, “generate agents from skills”, or to sweep a repo for skill/agent pairs. Also usable as a subagent itself.

Source: [`.claude/skills/opsward-subagents`](https://github.com/addaix/opsward/tree/HEAD/.claude/skills/opsward-subagents).

## Subagents

Subagents are Markdown files with a frontmatter (`name`, `description`, `tools`) and a system prompt as the body. Copy one into your project’s `.claude/agents/` (or your agent host’s equivalent) to delegate the task it describes.

### `opsward-subagents`

Decide which of a repo’s skills should also run as subagents (in their own context), declare it in each skill’s frontmatter, and generate or refresh the twin agent files with opsward. Use when a skill does bulky or read-heavy work whose output should stay out of the main context, when a skill needs a tool restriction or a cheaper model, when a hand-written agent duplicates a skill, when `opsward maintain` reports a `subagent_twin` finding, or when asked “should this skill be a subagent”, “make this skill usable as a subagent”, “generate agents from skills”, or to sweep a repo for skill/agent pairs. Also usable as a subagent itself.

Source: [`.claude/agents/opsward-subagents.md`](https://github.com/addaix/opsward/tree/HEAD/.claude/agents/opsward-subagents.md); tools: `Bash, Read, Grep, Glob, Edit, Write`.

### `setup-auditor`

Read-only diagnostic agent that audits the project’s AI setup (CLAUDE.md, skills, docs, rules). Use when you want to check the health of the project’s agent configuration without making changes.

Source: [`.claude/agents/setup-auditor.md`](https://github.com/addaix/opsward/tree/HEAD/.claude/agents/setup-auditor.md).

## Instruction files

Files agents read before working in this repository.

- [`CLAUDE.md`](https://github.com/addaix/opsward/tree/HEAD/CLAUDE.md): read by Claude Code
- [`AGENTS.md`](https://github.com/addaix/opsward/tree/HEAD/AGENTS.md): read by Codex, Copilot, Cursor and other agents

## Machine-readable documentation

This site publishes the same documentation in forms that fit an agent’s context window:

- [`llms.txt`](https://addaix.github.io/opsward/llms.txt): an index of every page with a one-line description ([llms.txt](https://llmstxt.org) format)
- [`opsward.md`](https://addaix.github.io/opsward/opsward.md): the whole documentation as one Markdown file
- `<page>.html.md`: a rendered Markdown twin of every page, advertised from each page’s `<head>` with `<link rel="alternate" type="text/markdown">`
- [`objects.inv`](https://addaix.github.io/opsward/objects.inv): the Sphinx inventory: a symbol-to-URL index (`sphobjinv convert plain objects.inv -`)


# api.html.md

# API reference

| [`opsward`](_autosummary/opsward.html.md#module-opsward)   | Diagnose, generate, and maintain the AI agent setup of your projects.   |
|---------------------------------------------------------------------------|-------------------------------------------------------------------------|


