claudeloop-rest-surface
Explains the design of the generated `claudeloop api ...` command tree — introspecting the anthropic SDK's resource class tree, binding methods to Typer commands, the --raw/--stream/--provider modifiers, and the CI drift gate that enforces 1:1 parity with the SDK. Use this whenever building or modifying src/claudeloop/infrastructure/api/ (introspect.py, binder, gateway, providers) or the generated CLI sub-app, whenever the user asks about the REST API surface, the anthropic SDK's endpoints, or "1:1 parity" / "drift gate" / "no gaps". Make sure to consult this before hand-writing any command under claudeloop api — every command in that namespace must be generated from SDK introspection, never hand-written one at a time, or the drift gate becomes meaningless and the "no gaps" claim becomes false.
- License 许可
- MIT
- 最近更新
- 2026-11-15
- Stars
- ★ 5
- Forks
- 3
01 前言 Front Matter
- name
- claudeloop-rest-surface
- description
- Explains the design of the generated `claudeloop api ...` command tree — introspecting the anthropic SDK's resource class tree, binding methods to Typer commands, the --raw/--stream/--provider modifiers, and the CI drift gate that enforces 1:1 parity with the SDK. Use this whenever building or modifying src/claudeloop/infrastructure/api/ (introspect.py, binder, gateway, providers) or the generated CLI sub-app, whenever the user asks about the REST API surface, the anthropic SDK's endpoints, or "1:1 parity" / "drift gate" / "no gaps". Make sure to consult this before hand-writing any command under claudeloop api — every command in that namespace must be generated from SDK introspection, never hand-written one at a time, or the drift gate becomes meaningless and the "no gaps" claim becomes false.
03 SKILL.md 正文
claudeloop REST surface (generated, not hand-written)
Codex skill mirror of
.claude/skills/claudeloop-rest-surface/SKILL.md. When this guidance changes, update Claude skill, Cursor rule, and.agents/skills/in the same PR.
claudeloop api ... covers all of the anthropic Python SDK's endpoint
methods without a single one being hand-written. This is the load-bearing
constraint of the whole subsystem — see ADR 0006 for why (short version:
Anthropic's own ant CLI already exists and covers this surface from the
same OpenAPI spec; a hand-written duplicate would silently rot the moment
anyone stopped tracking upstream SDK changes by hand).
How discovery works — no live client needed
Walk the class tree under anthropic.resources via its
cached_property descriptors, not an instantiated anthropic.Anthropic()
client. This means discovery works with zero credentials configured — the
drift-gate CI test can run without any API key secret. Each leaf yields a
resource path, a method name, and its inspect.signature.
Command binding rules
- Path/scalar parameters → real, typed Typer options.
- Request body →
--json <inline>/--json-file <path>with@pathfile inlining, matchingant's own approach — do not flatten every nestedTypedDictfield into individual flags;antindependently reached the same conclusion for the same reason (the request shapes are too deeply nested for that to stay usable). --rawselects the SDK'swith_raw_responsevariant.--streamselectswith_streaming_responsewhere the method supports it.--max-items Nbounds auto-pagination on list endpoints.--providerselects an alternate SDK client (AnthropicAWS/AnthropicVertex/AnthropicBedrock/AnthropicBedrockMantle/AnthropicGoogleCloud/AnthropicFoundry). OnlyAnthropicAWS,AnthropicGoogleCloud, andAnthropicFoundrycarry the SDK's full resource tree — the others expose Messages and Beta only. The binder must reflect this per-provider difference; do not generate a command for a provider that would simply fail at runtime.
The drift gate — what makes "no gaps" a real claim
A CI test enumerates every endpoint-backed method the installed anthropic
SDK exposes and asserts each has a registered claudeloop api command.
It also asserts the discovered method count against a committed
baseline, so a method disappearing from a newer SDK release is caught too,
not just additions. If you add a new hand-bound command (for one of the six
local helpers below), update the baseline deliberately — don't let the test
silently pass with a stale count.
The six local helpers with no HTTP endpoint
messages.stream, messages.parse, beta.messages.stream,
beta.messages.parse, beta.messages.tool_runner, beta.webhooks.unwrap
— none of these map to a discoverable cached_property endpoint, so
introspection alone won't find them. Each must be explicitly enumerated
in the drift test as either hand-bound to a command or deliberately
exempted with a stated reason — never silently forgotten. If you're adding
support for one of these, add it to that explicit list, not just a new
Typer command.
Full reference
docs/architecture/decisions/0006-generated-rest-surface-not-hand-written.md,
docs/guides/rest-api-surface.md.
04 同仓库更多 Skills
white-paper-writing
Use when writing white papers, technical reports, policy documents, thought leadership pieces, or any long-form authoritative document. Triggers on requests to write, structure, outline, or review white papers, technical reports, position papers, policy briefs, or evidence-driven arguments. Also use for B2B content marketing strategy, technical documentation requiring authority, academic-style reports, or any document that must educate while persuading. Use when someone asks "how should I structure this" for a long-form document.
prose-technical-mechanics
Use when editing or writing prose at a technical/mechanical level: choosing between Anglo-Saxon and Latinate diction, placing information in topic vs stress positions, writing periodic vs cumulative sentences, handling sentence rhythm, punctuation as logic, transitions, paragraph structure, or phonesthetics. Use when someone wants to understand WHY prose works or doesn't, not just surface-level style advice. Triggers on word choice, sentence structure, emphasis, rhythm, diction, or any deep writing mechanics question.
prose-mechanics
Use when writing, editing, or analyzing prose style; when trying to avoid generic AI-sounding writing; when applying specific prose styles such as journalistic, academic, narrative, KJV biblical, Hemingway plain, Latinate/Jamesian, Orwellian, Augustan, Victorian, Early Modern (Bacon, Browne, Milton), or free indirect discourse; or when coaching someone on writing voice and mechanics. Triggers on any request to improve, analyze, or write in a specific prose style, to fix "AI-sounding" writing, to make prose more vivid or concrete, to vary sentence rhythm, or to understand how a particular writer achieves their effects.
narrative-structure
Use when structuring stories, pitches, presentations, white papers, or any persuasive narrative; analyzing the hero's journey in fiction or non-fiction; applying StoryBrand for business communication; designing narrative arcs for thought leadership; or understanding Vogler, Snyder, Propp, or Campbell frameworks. Triggers on any narrative structure, storytelling, pitch structure, StoryBrand, hero's journey, three-act structure, Freytag, Save the Cat, narrative arc, or "how should I structure this story/pitch/presentation" request.
legal-brief-writing
Use when writing legal briefs, motions, or any court filing; when analyzing judicial cognition and persuasion; when applying elite brief-writing techniques from Roberts, Clement, Kagan, Garner; or when structuring legal arguments for maximum persuasion. Also use for autistic/neurodivergent advocates who need to understand how their natural communication style maps to elite legal advocacy. Triggers on any legal writing, brief drafting, motion preparation, or legal argument structuring request.
journal-publishability-criteria
Use whenever a research paper, article or preprint is being written, revised, reviewed or published, and specifically before every publication of docs/paper.md. Covers what legitimate journals actually gate on, in order of gating — the editor's desk screen (scope, novelty, package problems), what reviewers judge (methodological soundness, claims the evidence can carry, statistical and qualitative reporting), EQUATOR reporting guidelines, the ICMJE authorship criteria, COPE's view of text recycling, the near-universal generative-AI policy (no AI author, disclosure, author responsibility), TOP 2025 transparency standards, how to verify a journal is legitimate, submitting without an institution, and a pre-submission checklist. Triggers on requests to evaluate, review, prepare or submit a paper, to judge publishability, to write a declarations or data-availability section, to disclose AI use, or to check a journal.