Skip to content

Latest commit

 

History

History
208 lines (165 loc) · 12.3 KB

CLAUDE.md

File metadata and controls

208 lines (165 loc) · 12.3 KB

Project

TwentyThree CLI

A TypeScript/Node.js CLI (twentythree) for the TwentyThree video platform API, installable globally via npm. It gives users terminal access to every TwentyThree API endpoint, handles multi-workspace authentication with automatic token refresh, and ships alongside an installable AI agent skills package — modeled after the Basecamp CLI.

Core Value: A developer can authenticate, select a workspace, and call any TwentyThree API endpoint from the terminal in under a minute.

Constraints

  • Tech Stack: TypeScript + Node.js — no other runtimes; keeps the ecosystem consistent and npm distribution natural
  • Distribution: npm global install only for v1 — simplest path to ship
  • Auth: Credential-based (domain + bearer token) for v1 — browser OAuth is a subsequent milestone
  • API: Must support all endpoints in the OpenAPI spec as the long-term target — architecture must not artificially limit coverage

Technology Stack

Recommended Stack

CLI Framework

Technology Version Purpose Why
@oclif/core 4.10.5 CLI framework, command dispatch, help generation, flag parsing Only TypeScript-first framework designed for large multi-command CLIs; lazy-loads commands (each command file is required only when invoked — large API surface has zero startup penalty); built-in topic namespacing (videos:list, albums:create); plugin-autocomplete for tab completion; JSON output mode built in; Salesforce-maintained, v4 is actively published (6 days ago as of research date)
oclif 4.x CLI scaffolding and release tooling Code-generates command files, handles npm/package.json manifest, handles bin entrypoint wiring

Build Tooling

Technology Version Purpose Why
tsdown 0.21.x Bundle TypeScript → distributable CJS/ESM Powered by Rolldown (Rust); ESM-first; zero-config for CLI bundles; actively maintained as the officially endorsed successor to tsup; sensible defaults
typescript 5.x Type checking, declaration generation Required for type safety; tsdown handles emit via Rolldown but TypeScript compiler handles type checking in CI

OpenAPI Code Generation

Technology Version Purpose Why
openapi-typescript 7.x Generate TypeScript type definitions from the OpenAPI spec Types-only, zero runtime cost; generates paths, components, operations interfaces that can be used with any HTTP client; CLI accepts remote URLs directly (npx openapi-typescript https://video.twentythree.com/apidocs/swagger.json -o src/types/api.d.ts)
openapi-fetch latest Type-safe HTTP client using the generated types Tiny (~6 KB); enforces request/response types against the generated schema at compile time; same ecosystem as openapi-typescript

Config and Credential Storage

Technology Version Purpose Why
conf latest Store non-sensitive config: active workspace, workspace list, preferences XDG-compliant; writes to ~/.config/twentythree-cli/ on Linux/macOS; atomic writes prevent corruption; actively maintained by sindresorhus
@napi-rs/keyring 1.2.x Store bearer tokens securely in OS keychain Rust-backed native addon via NAPI-RS; wraps macOS Keychain, Windows Credential Manager, Linux Secret Service; actively maintained (last publish 3 months ago); keytar replacement with no abandoned-atom baggage; MSAL (Microsoft) is migrating to this library
  • Sensitive (bearer tokens, per-workspace credentials) → @napi-rs/keyring → OS keychain
  • Non-sensitive (active workspace selection, workspace display names, CLI preferences) → conf → ~/.config/twentythree-cli/config.json

Output Formatting and UX

Technology Version Purpose Why
chalk 4.x (NOT 5.x) Terminal colour Chalk 5 is ESM-only and breaks in CJS contexts; Chalk 4 is the safe choice until the build outputs pure ESM cleanly. Re-evaluate when fully ESM
cli-table3 latest Tabular output for list commands Lightweight; no extra deps; widely used; supports column truncation
ora 5.x (NOT 6.x) Spinners for async operations (API calls, token refresh) ora 6+ is ESM-only, same issue as chalk 5. ora 5 is CJS-safe
@clack/prompts latest Interactive prompts (auth setup, workspace selection) Ships beautiful opinionated styling out of the box; replaces the need for chalk + boxen + inquirer together; fewer dependencies; modern alternative to inquirer; actively maintained

HTTP Client

Technology Version Purpose Why
openapi-fetch latest API calls to TwentyThree endpoints Already in stack (see OpenAPI section); type-safe; tiny; supports middleware for auth injection

Token Refresh

Testing

Technology Version Purpose Why
vitest latest Unit and integration tests Native TypeScript support; no ts-jest config; Jest-compatible API; 30-70% faster than Jest in benchmarks; actively maintained by Vite core team
@oclif/test latest oclif command testing helpers Provides runCommand() helper that captures stdout/stderr for assertion; works with oclif's command loading

Full Dependency Map

Runtime Dependencies (dependencies)

Dev Dependencies (devDependencies)

Alternatives Considered

Category Recommended Alternative Why Not
CLI framework oclif Commander.js No command-file loader, no plugin system, manual registration at scale
CLI framework oclif yargs No command-file loader; builder verbosity grows with API surface; no autocomplete
CLI framework oclif Ink React runtime; for interactive UIs not data CLIs
Build tool tsdown tsup tsup is officially abandoned; tsdown is the maintained successor
Build tool tsdown tsc No bundling; file-per-file output; path issues in global installs
API types openapi-typescript orval Frontend-focused; generates React Query hooks, Axios clients — over-engineered for CLI
API types openapi-typescript @hey-api/openapi-ts Pre-1.0; 20+ plugin surface area; more appropriate for SDK generation
API types openapi-typescript swagger-codegen JVM dependency; verbose output; not Node-native
Credentials @napi-rs/keyring keytar Archived December 2022; unmaintained; deprecation warnings
Credentials @napi-rs/keyring plain conf file Tokens in plaintext files is a security antipattern
Prompts @clack/prompts inquirer More dependencies needed to match @clack styling; heavier
Testing vitest Jest Requires ts-jest config; slower; @swc/jest config complexity

Installation

Init with oclif generator (creates package.json, tsconfig, bin entrypoint)

Runtime deps

Dev deps

Sources

Conventions

Conventions not yet established. Will populate as patterns emerge during development.

Architecture

Architecture not yet mapped. Follow existing patterns found in the codebase.

Project Skills

No project skills found. Add skills to any of: .claude/skills/, .agents/skills/, .cursor/skills/, or .github/skills/ with a SKILL.md index file.

GSD Workflow Enforcement

Before using Edit, Write, or other file-changing tools, start work through a GSD command so planning artifacts and execution context stay in sync.

Use these entry points:

  • /gsd-quick for small fixes, doc updates, and ad-hoc tasks
  • /gsd-debug for investigation and bug fixing
  • /gsd-execute-phase for planned phase work

Do not make direct repo edits outside a GSD workflow unless the user explicitly asks to bypass it.

Developer Profile

Profile not yet configured. Run /gsd-profile-user to generate your developer profile. This section is managed by generate-claude-profile -- do not edit manually.

API Change Workflow

The TwentyThree OpenAPI spec is stored locally at packages/twentythree-cli/specs/twentythree-api-swagger.json. When the spec changes, follow this workflow to update the types and fix any affected commands.

1. Run the update script

From the repo root:

pnpm update-api-spec

Or directly from the CLI package:

cd packages/twentythree-cli && ./update-api-spec.sh

The script downloads the latest spec, shows a diff of what changed, and regenerates src/api/types.ts.

2. Read the diff output

The script prints a raw git diff of specs/twentythree-api-swagger.json. The diff shows:

  • New endpoints (added paths)
  • Removed endpoints (deleted paths)
  • Changed parameters, response shapes, or required fields

This diff is direct input for Claude — no further summarization needed.

3. Apply changes with Claude Code

  1. Run pnpm --filter twentythree-cli exec tsc --noEmit to capture TypeScript errors introduced by the spec update
  2. Open a Claude Code session
  3. Paste the diff output and any new TypeScript errors
  4. Ask Claude to update affected command files and fix broken types

Note: The codebase currently has pre-existing type errors unrelated to spec changes. Focus on errors that are newly introduced after running pnpm generate-types — not the pre-existing ones.

4. Verify

pnpm --filter twentythree-cli exec tsc --noEmit
pnpm --filter twentythree-cli test --run

Both commands should complete without new errors introduced by the spec update.

4b. Regenerate the command reference

docs/commands/ is generated from the built manifest. After pnpm --filter twentythree-cli build:

cd packages/twentythree-cli
pnpm exec oclif readme --multi --nested-topics-depth 2 --output-dir docs/commands
git checkout docs/commands/README.md   # the index table is hand-maintained; add a row for any new topic

Also add new topics to the topic table in the root README.md, and new resource groups to packages/twentythree-skills/skills/SKILL.md, skills/reference/<group>.md, and the RESOURCE_GROUPS / EXPECTED_FILE_COUNT constants in packages/twentythree-skills/scripts/validate-skills.mjs.

5. Commit

Commit the following files together in one commit:

  • packages/twentythree-cli/specs/twentythree-api-swagger.json (updated spec)
  • packages/twentythree-cli/src/api/types.ts (regenerated types)
  • Any command files updated to match the new spec

Example commit message: chore: update API spec and regenerate types (YYYY-MM-DD)