Skip to content

Commit 93188c6

Browse files
theletterfclaudecodexcursoragent
authored
Make docs agent workflows autonomous (#137)
* Pack identical APM skill bundle across all reusable workflows Every APM-importing reusable workflow in this repo currently caches its skill bundle under the constant key `apm-copilot-` when called from elastic/docs-content. The cache key formula `apm-${engine}-${hashFiles('.github/workflows/*.lock.yml')}` is evaluated in the caller's workspace, which has no lock files — so the hash segment is empty for every workflow. While only docs-review used APM this was benign. Once the sweeps landed (#123-#125), every additional workflow with a different `packages:` list started overwriting the same cache slot. The next workflow to run hit the previous one's bundle and got `Skill not found` for the skills it actually imports — with the agent ultimately falling back to manual analysis ("All skills are unavailable. I'll review the changes using my own judgment now."). Workaround: align every APM-importing workflow's `packages:` to the union of all skills used across the repo, so all five workflows pack the same bundle and cache collisions are no-ops. Adds a small per-run download cost (each workflow pulls all seven skills, uses one or two) but restores correctness. Filed upstream as github/gh-aw#30365 — when fixed there, we can revert each workflow's `packages:` back to its minimum set. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Make docs agent workflows autonomous Embed the docs review and sweep rules directly in the agent prompts so the workflows no longer depend on runtime Elastic Docs Skills, while keeping Elastic docs MCP as the bounded source for published-doc verification. Co-authored-by: OpenAI GPT-5.5 <noreply@openai.com> Co-authored-by: Cursor <cursoragent@cursor.com> * Run Vale before docs review Add deterministic Vale output to the docs-review workflow so style findings are grounded in elastic/vale-rules instead of runtime skills or model-only judgment. Co-authored-by: OpenAI GPT-5.5 <noreply@openai.com> Co-authored-by: Cursor <cursoragent@cursor.com> * Carry over docs skill review guidance Embed the high-value style, jargon, frontmatter, content-type, applies_to, and page-opening guidance from Elastic Docs Skills into the autonomous workflow prompts while keeping Vale and MCP as evidence sources. Co-authored-by: OpenAI GPT-5.5 <noreply@openai.com> Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: OpenAI GPT-5.5 <noreply@openai.com> Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 07dd56f commit 93188c6

20 files changed

Lines changed: 1039 additions & 807 deletions

.claude/skills/create-agentic-workflow/SKILL.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ You are a workflow generator for the [elastic/docs-actions](https://github.com/e
2727

2828
## Background
2929

30-
This repo uses [GitHub Agent Workflows](https://github.github.com/gh-aw/). Workflow `.md` sources live in `agentic-workflows/` as a library. A compile script copies them to `.github/workflows/` for the gh-aw compiler, which produces `.lock.yml` files that consumer repos call via `uses:`.
30+
This repo uses [GitHub Agent Workflows](https://github.github.com/gh-aw/). Workflow `.md` sources live in `.github/workflows/` for the gh-aw compiler, which produces `.lock.yml` files that consumer repos call via `uses:`. Usage documentation and trigger templates live under `agentic-workflows/`.
3131

3232
Each workflow needs three files:
33-
1. `agentic-workflows/<name>/gh-aw-<name>.md` — workflow source (frontmatter + prompt)
33+
1. `.github/workflows/gh-aw-<name>.md` — workflow source (frontmatter + prompt)
3434
2. `agentic-workflows/<name>/example.yml` — trigger template callers copy
3535
3. `agentic-workflows/<name>/README.md` — usage documentation
3636

@@ -64,6 +64,8 @@ Use `AskUserQuestion` to collect:
6464
Read an existing workflow for reference:
6565
- `.github/workflows/gh-aw-docs-issue-scope.md` — on-demand check pattern
6666
- `.github/workflows/gh-aw-issue-triage.md` — triage pattern with pre-steps
67+
- `.github/workflows/gh-aw-docs-style-sweep.md` — deterministic pre-step pattern
68+
- `.github/workflows/gh-aw-docs-coherence-sweep.md` — Elastic docs MCP pattern
6769

6870
Generate `.github/workflows/gh-aw-<name>.md`. Read the available fragments in `.github/workflows/gh-aw-fragments/` and import those relevant to the workflow. **Always include `inlined-imports: true`** — this embeds all imported content at compile time, which is required for cross-repo `workflow_call` invocation.
6971

@@ -110,6 +112,11 @@ tools:
110112
toolsets: [repos, issues, pull_requests, search]
111113
bash: true
112114
web-fetch:
115+
mcp-servers:
116+
elastic-docs:
117+
type: http
118+
url: "https://www.elastic.co/docs/_mcp/"
119+
allowed: ["*"]
113120
network:
114121
allowed:
115122
- defaults
@@ -137,6 +144,8 @@ Follow the frontmatter with the agent prompt in markdown. The imported fragments
137144
5. **Quality gate** — when to noop vs. when to report (noop is the expected outcome)
138145
6. **Output format** — exact format for the issue body, PR body, or comment
139146

147+
Make the workflow autonomous. Do not require runtime skills or agent-local packages for core behavior. Embed the domain rules the agent needs, use deterministic pre-steps for mechanical checks, and use Elastic docs MCP for published-doc evidence when needed. If MCP is required for a finding but is unavailable, instruct the agent to `noop` or skip the finding rather than guessing.
148+
140149
End with `${{ inputs.additional-instructions }}` so callers can inject repo-specific guidance.
141150

142151
Read the existing workflows for examples.
@@ -177,7 +186,7 @@ For scheduled audits, add `issues: write` to permissions. For fixes, add `conten
177186

178187
### Step 5: Generate the README
179188

180-
Create `agentic-workflows/<name>/README.md` following the pattern in `agentic-workflows/docs-check/README.md`:
189+
Create `agentic-workflows/<name>/README.md` following the pattern in `agentic-workflows/docs-review/README.md` or `agentic-workflows/docs-issue-scope/README.md`:
181190
- Description
182191
- Triggers table
183192
- Install section with curl one-liner

.github/workflows/gh-aw-docs-applies-to-sweep.lock.yml

Lines changed: 92 additions & 149 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/gh-aw-docs-applies-to-sweep.md

Lines changed: 43 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,15 @@
11
---
22
description: |
33
Validates the `applies_to` frontmatter key across a docs corpus on a rotating
4-
slice each run, using the docs-applies-to-tagging skill in audit mode.
5-
Opens a single labeled fix-issue with structured YAML findings consumable by
6-
a future fix-agent.
4+
slice each run, using self-contained validation rules and the Elastic docs
5+
MCP server for published cumulative-docs guidance. Opens a single labeled
6+
fix-issue with structured YAML findings consumable by a future fix-agent.
77
88
inlined-imports: true
99
imports:
1010
- gh-aw-fragments/formatting.md
1111
- gh-aw-fragments/rigor.md
12-
- uses: github/gh-aw/.github/workflows/shared/apm.md@v0.71.1
13-
with:
14-
# Workaround for github/gh-aw#30365: every APM-importing workflow in this
15-
# repo must pack the same package set so they don't clobber each other's
16-
# cache under the constant key apm-copilot- in the caller repo.
17-
packages:
18-
- elastic/elastic-docs-skills/skills/authoring/applies-to-tagging
19-
- elastic/elastic-docs-skills/skills/authoring/content-type-checker
20-
- elastic/elastic-docs-skills/skills/authoring/frontmatter-description
21-
- elastic/elastic-docs-skills/skills/authoring/page-opening-optimizer
22-
- elastic/elastic-docs-skills/skills/review/docs-check-style
23-
- elastic/elastic-docs-skills/skills/review/flag-jargon-skill
24-
- elastic/elastic-docs-skills/skills/review/frontmatter-audit
12+
- gh-aw-fragments/mcp-pagination.md
2513
engine:
2614
id: copilot
2715
concurrency:
@@ -81,10 +69,16 @@ tools:
8169
- "git log *"
8270
- "yq *"
8371
- "jq *"
72+
mcp-servers:
73+
elastic-docs:
74+
type: http
75+
url: "https://www.elastic.co/docs/_mcp/"
76+
allowed: ["*"]
8477
network:
8578
allowed:
8679
- defaults
8780
- github
81+
- "www.elastic.co"
8882
safe-outputs:
8983
noop:
9084
create-issue:
@@ -208,18 +202,38 @@ A pre-step has computed the in-scope file list:
208202

209203
Read with `cat` / `jq`. If `in_scope_count` is `0`, call `noop` with the stats and stop.
210204

211-
## Step 1: Run the skill in audit mode
205+
## Step 1: Validate applies_to autonomously
206+
207+
This workflow is autonomous. Do not invoke runtime skills or depend on a skill package being installed. For each in-scope file, read the frontmatter block at the top of the copy under `/tmp/gh-aw/sweep-data/scope/` and inspect the `applies_to` key.
208+
209+
Audit only. Do not edit repo originals or scope copies. This sweep emits an issue, not a PR.
210+
211+
Before filing any validity finding, verify the rule from one of these sources:
212212

213-
Invoke `skill(skill: docs-applies-to-tagging)` against `/tmp/gh-aw/sweep-data/scope/`.
213+
- A checked-in repository schema or docs-builder configuration in the source repository.
214+
- Published cumulative-docs guidance fetched during this run with `elastic-docs.get_document_by_url`, especially `/docs/contribute-docs/how-to/cumulative-docs/guidelines` and `/docs/contribute-docs/how-to/cumulative-docs/reference`.
215+
- Published syntax and placement guidance fetched during this run when body-level annotations are involved, especially the docs-builder applies_to syntax guide, badge placement guidance, and cumulative-docs example scenarios.
214216

215-
**Audit mode only — do not write any files.** The skill defaults to validation when not asked to fix; reinforce that intent in the call. This sweep produces an issue, not edits.
217+
Use the published reference as the source of truth for allowed dimensions, keys, lifecycle states, and version formats. If the MCP server is unavailable and no local schema is available, call `noop` with `"applies_to reference unavailable; skipping applies_to sweep"` rather than emitting unverified findings.
216218

217-
**If the skill returns "Skill not found", do not noop.** That error is ambiguous — it can mean the skill genuinely isn't installed, or that the invocation form was reformatted by the agent's tool serialization. Either way: fall back to manual analysis instead of aborting. Procedure:
219+
Apply these rules after verification:
218220

219-
1. Try invoking the skill with the exact form `skill(skill: docs-applies-to-tagging)`.
220-
2. If that fails or returns "Skill not found": fall back to **manual analysis**. Use `bash` to scan each in-scope file's frontmatter (the YAML block at the top), checking for missing/invalid `applies_to` keys against the documented allowed values. Produce findings as you would have from the skill output, and add a single line in the issue body's `Notes` section: "skill `docs-applies-to-tagging` did not produce output in this run; findings are agent-only."
221+
- Every page should include page-level `applies_to` frontmatter.
222+
- Page-level `applies_to` should use one primary dimension: Stack/Serverless (`stack`, `serverless`), Deployment (`deployment` with deployment subkeys and, where documented, `serverless`), or Product (`product` with documented product subkeys). Section-level and inline annotations can use a different dimension when needed to clarify local exceptions.
223+
- Lifecycle values must match the verified reference. Current published states include `preview`, `beta`, `ga`, `deprecated`, `removed`, and `unavailable`, but do not rely on this list without fetching the reference or reading a local schema during the run.
224+
- Version values must use documented formats, such as major/minor versions, exact versions, ranges, or greater-than-or-equal versions, according to the verified reference.
225+
- `ech` is the current key for Elastic Cloud Hosted. Treat `ess` as deprecated in new or updated content unless local build constraints require it.
226+
- Validate version semantics: only one version per lifecycle, only one open-ended `+` lifecycle per key, exact versions use `=x.x` or `=x.x.x`, ranges use one hyphen with no spaces, range starts must be less than or equal to ends, and ranges must not overlap.
227+
- Do not write version numbers in prose next to `applies_to` badges. Let the badge carry version applicability.
228+
- Section-level annotations belong immediately after a heading and apply until the next heading of the same or higher level. Do not put inline annotations in headings.
229+
- Inline annotations are appropriate for a single phrase, property, definition-list term, or table cell, not for whole sections.
230+
- Badge placement should match the element: frontmatter for page-level, after headings for section-level, at the beginning of list items when the whole item varies, at the end of a definition-list term when the whole item varies, and in the first column or relevant cell for tables.
231+
- Use `applies-switch` tabs only when code blocks or workflows differ entirely between contexts.
232+
- Do not require `unavailable` when omission already communicates that the content does not apply. Report `unavailable` misuse only when the page creates a high risk of user confusion or contradicts the published guidance.
233+
- Do not flag dimension choices unless the page-level `applies_to` clearly mixes primary dimensions, contradicts `products`, or conflicts with the page's documented scope.
234+
- Do not add or require tags for typo fixes, formatting changes, information architecture changes, or sections whose applicability is already established by a parent tag.
221235

222-
Only call `noop` if you cannot produce any high-confidence findings even from manual analysis.
236+
Only call `noop` if you cannot produce any high-confidence findings from verified rules.
223237

224238
## Step 2: Build the findings list
225239

@@ -229,9 +243,9 @@ Categories (use exactly these strings):
229243
- `invalid-applies-to-syntax` — malformed YAML or unrecognized structure under `applies_to:`.
230244
- `invalid-applies-to-value` — recognized structure but a value (product, deployment, lifecycle stage) that is not in the allowed vocabulary.
231245
- `inconsistent-applies-to``applies_to` contradicts other frontmatter (e.g., `products:` says one thing, `applies_to:` another).
232-
- `outdated-applies-to` — references a deployment/lifecycle value that is deprecated per the skill's reference set.
246+
- `outdated-applies-to` — references a deployment or lifecycle value that is deprecated per the verified reference.
233247

234-
For each finding extract `file`, `line`, `category`, `severity`, `evidence`, and `suggested_fix` (concrete YAML snippet) when the skill produces one.
248+
For each finding extract `file`, `line`, `category`, `severity`, `evidence`, and `suggested_fix` when you can produce a concrete YAML snippet confidently.
235249

236250
Strip the `/tmp/gh-aw/sweep-data/scope/` prefix from `file` so paths are repo-relative.
237251

@@ -259,11 +273,11 @@ Shard <slot+1>/<n> · <shard_count> pages in slice · <recent_count> recently-ch
259273
line: 4
260274
category: invalid-applies-to-value
261275
severity: high
262-
evidence: "applies_to.deployment.ess: 'preview' — not in allowed lifecycle values"
276+
evidence: "applies_to.deployment.ess uses an unrecognized deployment key; use `ech` for Elastic Cloud Hosted"
263277
suggested_fix: |
264278
applies_to:
265279
deployment:
266-
ess: ga
280+
ech: ga
267281
- file: docs/bar.md
268282
line: 1
269283
category: missing-applies-to
@@ -272,7 +286,7 @@ Shard <slot+1>/<n> · <shard_count> pages in slice · <recent_count> recently-ch
272286
```
273287
274288
## Done when
275-
- All listed pages have a valid `applies_to` block per the skill's reference set.
289+
- All listed pages have a valid `applies_to` block per the verified reference.
276290
- A PR addressing this issue is merged.
277291

278292
## Notes
@@ -286,7 +300,7 @@ Keep the YAML block parseable. Use the literal `|` block scalar for multi-line `
286300
## What to skip
287301

288302
- Files outside `/tmp/gh-aw/sweep-data/in-scope.txt`.
289-
- `applies_to` values the skill flags as warnings without a concrete remediation — they belong in the next iteration, not this sweep.
303+
- `applies_to` warnings without a concrete remediation — they belong in the next iteration, not this sweep.
290304
- Generic `applies_to` shape preferences when the existing value is technically valid.
291305

292306
${{ inputs.additional-instructions }}

0 commit comments

Comments
 (0)