AGENT SKILL

codegen

Generates simple tests, docstrings, and documentation updates for PR changes. Use when reviewing a PR and you want draft tests, docstrings, or CHANGELOG entries to fill the gaps it surfaced (human review required before committing).

License 许可
MIT
最近更新
2026-11-14
Stars
★ 1
Forks
0

01 前言 Front Matter

name
codegen
metadata
{ "author": "Osniel Quintana-Salgado", "facet-of": "review" }
description
Generates simple tests, docstrings, and documentation updates for PR changes. Use when reviewing a PR and you want draft tests, docstrings, or CHANGELOG entries to fill the gaps it surfaced (human review required before committing).
allowed-tools
Bash Read Write

02 资源文件 2

03 SKILL.md 正文

Code Generator

Generates simple, low-risk code and documentation for PR changes — "easy wins": tests for simple functions, missing docstrings, CHANGELOG entries, API docs. Everything it emits is a draft for human review, never auto-committed.

Inputs

  • PR URL — full GitHub/Enterprise URL.
  • OUTPUT_DIR (optional) — defaults to a private mktemp -d.
  • Analysis JSON — analyze at $OUTPUT_DIR/pr-analysis-<number>.json (languages, frameworks, test_setup.framework, uses_mac_ui).
  • Docs Drift JSON — docs-drift at $OUTPUT_DIR/docs-drift-<number>.json (completeness findings — facet: "completeness", drift_class: "missing-doc" — name the missing docstring / CHANGELOG / API-doc surfaces).

Output

$OUTPUT_DIR/code-generation-<PR_NUMBER>.json (structure in Step 7) plus a human-readable code-generation-<PR_NUMBER>-summary.md (template in references/output-examples.md).

Step 0: Parse arguments

PR_URL="$1"
OUTPUT_DIR="${2:-$(mktemp -d -t pr-review-XXXXXX)}"
PR_NUMBER=$(echo "$PR_URL" | grep -oE 'pull/[0-9]+' | grep -oE '[0-9]+')

Prerequisites

Both files must already exist in $OUTPUT_DIR; this skill reads, never produces them. Run review:analyze and review:docs-drift first.

cat "$OUTPUT_DIR/pr-analysis-${PR_NUMBER}.json"
cat "$OUTPUT_DIR/docs-drift-${PR_NUMBER}.json"

Stop if either cat fails. Without the docs-drift findings there is no gap list, and the run produces an empty output file that reads like "nothing to generate".

Step 1: Determine what to generate

Generate only LOW-complexity, LOW-risk, HIGH-confidence items: simple getters/setters/validators/formatters, missing docstrings, CHANGELOG entries, API docs for new endpoints, trivial lint fixes.

Never generate: business logic, DB migrations, endpoint implementations, auth/authz logic, or anything needing domain knowledge.

Parse the inputs: identify simple, untested functions directly from the PR diff (cross-checking the changed files for an existing test); completeness gaps from docs-drift; language/framework/uses_mac_ui from analysis.

Step 2: Generate tests (conservative)

Candidates: pure functions, simple validators, data transformers, property accessors — under 20 lines, no external deps, no existing test. Use the skeletons in references/generation-templates.md (Python/JS/Go/Java/Rust).

Rules: max 3 tests per function (happy + ≤2 edge/error cases); skip complex, side-effecting, or already-tested functions. For Rust, prefer filling an exact untested branch/arm visible in the diff (e.g. an env-parse unset|blank|invalid arm) over a bare happy path, and place tests in the file's #[cfg(test)] mod tests block.

Step 3: Generate docstrings

For each completeness missing-doc finding on a public item, generate a docstring in the language's convention (templates in references/generation-templates.md). Document params, returns, and errors; omit internals. Match the file's existing docstring density; 2-10 lines.

Step 4: Generate CHANGELOG entries

Only if the repo keeps a CHANGELOG. Group PR commits into Added/Changed/Fixed/ Deprecated/Removed/Security (Keep a Changelog style):

gh pr view "$PR_URL" --json commits --jq '.commits[].messageHeadline'

Determine the version bump per the table in references/output-examples.md.

Step 5: Generate API documentation

For each new/changed endpoint the completeness findings flagged, emit an OpenAPI-style markdown section (template in references/generation-templates.md): method+path, request (headers/body), response (success/error), error codes. Omit internals. For an OpenAPI-first repo, prefer proposing the spec edit and let the render regenerate, rather than hand-writing prose (see docs-drift).

If technical-writing:write-doc is available, shape README/Reference prose with its matching template (templates/readme.md / reference.md) and references/common-doc-guidelines.md; emit the text into generated.api_docs, write no file, and ask no questions. Otherwise generate inline as above. Docstrings (Step 3) and CHANGELOG entries (Step 4) stay as they are, since CHANGELOG is not a write-doc type.

Step 6: Generate lint fixes

Only trivial issues: unused variable → _-prefix, trailing commas, whitespace, import ordering. Never fix logic/type errors. Emit {file, line, issue, fix, diff}.

These diffs are evidence that drift exists, not the remedy. /review:fix discards them and runs the repo's own formatter instead: the tool is authoritative, and a diff drafted during review is stale by the time anyone applies it. Keep emitting them — they are what tells fix to run the formatter at all.

Step 7: Output JSON

Build with jq -n, every generated snippet passed via --arg (never heredoc model/PR-derived text). Emit generated.{tests,docstrings,changelog_entries, api_docs,lint_fixes} (each entry carries file, reason, confidence), plus stats counts and a one-line summary:

jq -n --argjson pr_number "$PR_NUMBER" --arg ts "$(date -Iseconds)" \
  --arg test_code "$TEST_CODE" --arg docstring "$DOCSTRING" \
  '{ pr_number:$pr_number, generation_timestamp:$ts, status:"completed",
     generated:{ tests:[{file:"…",function:"…",code:$test_code,reason:"…",confidence:"high"}],
                 docstrings:[{file:"…",line:0,docstring:$docstring,reason:"…",confidence:"high"}],
                 changelog_entries:[], api_docs:[], lint_fixes:[] },
     stats:{tests_generated:0,docstrings_generated:0,changelog_entries:0,api_docs_sections:0,lint_fixes:0},
     review_required:true,
     summary:"…" }' > "$OUTPUT_DIR/code-generation-${PR_NUMBER}.json"

Then write the human-readable summary per references/output-examples.md.

Step 8: Safety & confidence

Validate each snippet (syntax, imports, naming convention) before emitting. Confidence: HIGH (validators/getters/formatters), MEDIUM (CHANGELOG, API docs). Emit HIGH+MEDIUM only — drop LOW. Always set review_required:true with concrete review notes (verify assertions match behavior; check CHANGELOG version against the release plan; validate API examples).

Step 9: Summary

Report counts by artifact and confidence, and remind that human review is required before committing. Point the reviewer at the JSON + summary files.

Limitations

Does NOT generate business logic, DB migrations, endpoint implementations, or architectural decisions; does NOT modify existing tests or auto-commit. DOES draft simple tests, docstrings, CHANGELOG entries, API docs, and trivial lint fixes — all for review.

Error handling

If an item fails, continue with the rest and record it under skipped with a reason and a manual-write recommendation (example in references/output-examples.md).

Integration & notes

Standalone. review does not call it, and nothing it writes reaches the findings ledger, so /review:fix never sees its output — invoke it by name when you want drafts, and review them by hand. Conservative by design: only easy, well-established patterns; skip anything ambiguous. Cost ~$0.50-1.50/PR.

Files

  • references/generation-templates.md — per-language test/docstring/API skeletons.
  • references/output-examples.md — human-summary template, version-bump table, skipped-item record.

04 同仓库更多 Skills

ozzycodes2
ozzycodes2/claudellum

writing-design-docs

Use when the user wants to write a problem-statement design doc, says "let's plan a feature properly" / "write a design doc" / "I'm thinking about how to do X" for a non-trivial X, or before committing to a non-obvious technical direction

★ 1
ozzycodes2
ozzycodes2/claudellum

write-doc

Use when the user asks to write or draft a README, ADR, runbook, tutorial, how-to, explanation, or reference doc, or a caller passes "type ADR" or "type README". Picks the type, fills a template, adds diagrams. RFCs and design docs belong to writing-design-docs.

★ 1
ozzycodes2
ozzycodes2/claudellum

review-doc

Use when the user asks to review, critique, score, grade, or "how good is this doc" for a Markdown doc or pasted text. Read-only. Scores it on the 20 Practical Prose dimensions and emits a findings table. Does not edit; fix-doc applies the findings next.

★ 1
ozzycodes2
ozzycodes2/claudellum

fix-doc

Use when the user asks to fix, edit for prose quality, polish, tighten, humanize, or de-slop a Markdown doc or pasted text, or says "make this read less AI". Applies review-doc findings, generates flagged diagrams, lists substantive issues for the author, then runs the AI-tell pass last. Modifies the target.

★ 1
ozzycodes2
ozzycodes2/claudellum

create-slides

Use when the user asks for a slide deck, presentation, talk, or slides from a document, report, PR, notes, or topic. Builds one self-contained Machinify-branded HTML deck in a minimalist style, with headline-plus-visual slides, speaker notes, and every diagram drawn by architecture-design:create-diagram.

★ 1
ozzycodes2
ozzycodes2/claudellum

start-session

Open a Claude Code working session in a fresh, isolated git worktree, so the user can start a task with a single /start-session <name>. Use at the START of a session when the user says "start session", "start a worktree", "spin up a worktree for ABC-123", "begin work on <ticket>", or passes a name/ticket to work under. Creates and ENTERS a worktree via the EnterWorktree tool (never `git worktree add`) under .claude/worktrees/, named exactly after the argument, on a local branch `worktree-<argument>`. Reports what the worktree inherited (`.worktreeinclude` copies, symlinked node_modules) and whether its `.env` still points at the main checkout's stack. If the argument is a JIRA key (e.g. ABC-123, PROJ-1505), also loads that story with the Atlassian CLI (`acli`) when available and summarizes the implementation ask. Also renames the session to the argument (the same effect as `/rename <NAME>`) so it's easy to find in `/resume`. Then stops and waits — it sets up the workspace and context, it does not implement.

★ 1