Skip to content

Upgrade exemplar to multi-resource stencil with full test coverage - #3

Merged
codeyogi911 merged 1 commit into
mainfrom
claude/clify-api-to-cli-skill-LFqTd
Apr 26, 2026
Merged

Upgrade exemplar to multi-resource stencil with full test coverage#3
codeyogi911 merged 1 commit into
mainfrom
claude/clify-api-to-cli-skill-LFqTd

Conversation

@codeyogi911

Copy link
Copy Markdown
Owner

Summary

Replaces the single-endpoint JSONPlaceholder exemplar with a comprehensive, production-ready stencil (exemplar-cli) that demonstrates all patterns clify-generated CLIs must support. The new exemplar is structurally inspired by google/agents-cli and includes three resources (items, item-variants, orders) exercising pagination, idempotency, multipart uploads, and auth.

Key Changes

  • New exemplar structure (examples/exemplar-cli/):

    • Hierarchical subcommands (<resource> <action>)
    • One file per resource under commands/
    • Shared HTTP, auth, output, and config layers under lib/
    • First-class login command with --status
    • Modular skills under skills/<cli>-<role>/
  • Comprehensive test suite:

    • Smoke tests: CLI shape, --version, --help, error semantics
    • Integration tests: cursor pagination, idempotency-key headers, multipart uploads, structured error mapping
    • Auth tests: bearer token wiring, login status reflection, 401 handling
    • In-repo mock server (zero-dep) — no network required for npm test
  • Three-resource API surface:

    • items: list (cursor pagination), get, create (idempotency), update, delete
    • item-variants: sub-resource flattened to two-level nesting
    • orders: list, get, create (idempotency), upload (multipart)
  • Knowledge base (knowledge/):

    • Cursor pagination pattern
    • Idempotency-key header usage
    • Composite order validation rules
    • Rate-limit behavior
  • Eval harness (evals/):

    • Deterministic graders for file presence, .clify.json fields, auth scheme
    • Case-based testing against real APIs (Zoho Inventory example)
    • Structural similarity scoring placeholder
  • Updated documentation:

    • New references/scaffold-pipeline.md: in-depth per-phase reference
    • Renamed skills/clify-scaffold/skills/clify/ with lean summary
    • Removed obsolete clify-validate and clify-sync skills (functionality preserved in core)
    • Updated references/conventions.md to reference exemplar-cli
  • Backward compatibility:

    • Old JSONPlaceholder exemplar moved to examples/legacy/jsonplaceholder-cli/
    • Validation gate updated to scan both old and new CLI layouts (lib/ + commands/)

Notable Implementation Details

  • Mock server uses Node's built-in http module (zero dependencies)
  • Auth scheme is pluggable via lib/auth.mjs — scaffolder swaps scheme and matching branch for target API
  • Help text is generated from runtime resource registry, ensuring it never drifts
  • Path interpolation handles :id and :itemId placeholders with proper URL encoding
  • Pagination iterator (paginate()) handles cursor, page, offset, and Link header strategies
  • Idempotency-key and If-Match headers are optional flags, not forced
  • Multipart uploads wire --file flag and read file from disk
  • Error output uses structured JSON format with code + message
  • .clify.json captures auth scheme, API name, docs URL, content hash, and node version requirement

https://claude.ai/code/session_016WbCqoWpJ77he4VQbLSySe

The v0.2 stencil (JSONPlaceholder) was a read-only blog API with no auth,
no pagination, and no business rules. It couldn't teach the scaffolder
what an A+ CLI looks like. v0.3 replaces it with examples/exemplar-cli/,
a hand-crafted fictional API structurally inspired by google/agents-cli:

- bin/<api>-cli.mjs is a thin dispatcher
- lib/{api,auth,output,config,env,args,help}.mjs holds shared machinery
- commands/<resource>.mjs files: one per resource, default-export the registry
- skills/<api>-cli-{workflow,auth,resources,knowledge}/SKILL.md (modular)
- A first-class `login` command with --status
- Cursor pagination, idempotency-key, --if-match, multipart upload all
  wired in the stencil so generated CLIs inherit the patterns

Other changes:

- Collapse 3 skills (clify-scaffold, clify-validate, clify-sync) into 1.
  Validate and sync were thin wrappers around binary verbs an agent can
  call directly. The lone `clify` skill is 105 lines (down from 151) with
  6 phases; per-step detail moved to references/scaffold-pipeline.md.
- New `clify eval <case>` verb plus an evals/ harness with the inaugural
  zoho-inventory case. Deterministic graders run today; LLM-as-judge is
  stubbed for a follow-up.
- validate.mjs now scans bin/ + lib/ + commands/ for source conventions
  (BASE_URL, FormData, idempotency-key) and looks for the workflow skill
  at skills/<pkg.name>-workflow/SKILL.md, falling back to the legacy path.
- JSONPlaceholder moved to examples/legacy/ with a README explaining its
  status. Scaffold-init now copies from examples/exemplar-cli/.

Verification: 15/15 host tests, 33/33 exemplar tests, 21/21 validate gate
checks, scaffold-init round-trip clean, eval verb works end-to-end.

https://claude.ai/code/session_016WbCqoWpJ77he4VQbLSySe
@codeyogi911
codeyogi911 merged commit 88395a3 into main Apr 26, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants