diff --git a/.claude/CLAUDE.md b/.claude/CLAUDE.md index 9e78324c..0b302cc3 100644 --- a/.claude/CLAUDE.md +++ b/.claude/CLAUDE.md @@ -50,6 +50,32 @@ cat .cursor/rules/AI-Assistance.mdc 5. **Remove tests without asking** - Always get permission first 6. **NODE_ENV** - To check if the CLI is in test mode, use the `isTestMode()` helper function. 7. **`process.exit`** - When creating a command, use `this.exit()` for consistent test mode handling. +8. **Implement common functionality without searching first** - See "Discover Patterns" below. + +## 🔍 Discover Patterns Before Implementing (CRITICAL) + +This codebase has 50+ commands with established patterns. **Before implementing ANY common functionality, search for how existing code handles it.** + +### Before You Write Code + +1. **Find a similar command** - If adding `push foo`, look at `channels foo` or `apps foo` first +2. **Search for the problem** - Before writing error handling, confirmation prompts, or any reusable logic: `grep -r "keyword" src/` +3. **Check utilities** - Browse `src/utils/` and `src/base-command.ts` for existing helpers + +### Search Examples + +| If you need... | Search for... | +|----------------|---------------| +| Error handling in JSON mode | `grep -r "Error.*json\|jsonError" src/` | +| User confirmation prompts | `grep -r "confirm\|prompt" src/utils/` | +| Common flag patterns | Look at 2-3 similar commands | +| Test patterns | Look at existing tests in same directory | + +### The Rule + +**If you're solving a problem that other commands probably solve, spend 2 minutes searching before implementing.** Finding an existing pattern is faster than inventing one and having it rejected in review. + +When in doubt: `grep -r "what-you-need" src/` → read how others did it → follow that pattern. ## ✅ Correct Practices diff --git a/README.md b/README.md index d97885b3..b3050432 100644 --- a/README.md +++ b/README.md @@ -103,12 +103,11 @@ See [MCP Server section](#mcp-server) for more details on how to use the MCP Ser * [`ably apps channel-rules update NAMEORID`](#ably-apps-channel-rules-update-nameorid) * [`ably apps create`](#ably-apps-create) * [`ably apps current`](#ably-apps-current) -* [`ably apps delete [ID]`](#ably-apps-delete-id) +* [`ably apps delete [APPID]`](#ably-apps-delete-appid) * [`ably apps list`](#ably-apps-list) * [`ably apps logs`](#ably-apps-logs) * [`ably apps logs history`](#ably-apps-logs-history) * [`ably apps logs subscribe`](#ably-apps-logs-subscribe) -* [`ably apps set-apns-p12 ID`](#ably-apps-set-apns-p12-id) * [`ably apps stats [ID]`](#ably-apps-stats-id) * [`ably apps switch [APPID]`](#ably-apps-switch-appid) * [`ably apps update ID`](#ably-apps-update-id) @@ -142,6 +141,8 @@ See [MCP Server section](#mcp-server) for more details on how to use the MCP Ser * [`ably channels publish CHANNEL MESSAGE`](#ably-channels-publish-channel-message) * [`ably channels subscribe CHANNELS`](#ably-channels-subscribe-channels) * [`ably config`](#ably-config) +* [`ably config path`](#ably-config-path) +* [`ably config show`](#ably-config-show) * [`ably connections`](#ably-connections) * [`ably connections logs [TOPIC]`](#ably-connections-logs-topic) * [`ably connections stats`](#ably-connections-stats) @@ -149,7 +150,7 @@ See [MCP Server section](#mcp-server) for more details on how to use the MCP Ser * [`ably help [COMMANDS]`](#ably-help-commands) * [`ably integrations`](#ably-integrations) * [`ably integrations create`](#ably-integrations-create) -* [`ably integrations delete RULEID`](#ably-integrations-delete-ruleid) +* [`ably integrations delete INTEGRATIONID`](#ably-integrations-delete-integrationid) * [`ably integrations get RULEID`](#ably-integrations-get-ruleid) * [`ably integrations list`](#ably-integrations-list) * [`ably integrations update RULEID`](#ably-integrations-update-ruleid) @@ -169,9 +170,30 @@ See [MCP Server section](#mcp-server) for more details on how to use the MCP Ser * [`ably logs push subscribe`](#ably-logs-push-subscribe) * [`ably mcp`](#ably-mcp) * [`ably mcp start-server`](#ably-mcp-start-server) +* [`ably push`](#ably-push) +* [`ably push batch-publish`](#ably-push-batch-publish) +* [`ably push channels`](#ably-push-channels) +* [`ably push channels list`](#ably-push-channels-list) +* [`ably push channels list-channels`](#ably-push-channels-list-channels) +* [`ably push channels remove`](#ably-push-channels-remove) +* [`ably push channels remove-where`](#ably-push-channels-remove-where) +* [`ably push channels save`](#ably-push-channels-save) +* [`ably push config`](#ably-push-config) +* [`ably push config clear-apns`](#ably-push-config-clear-apns) +* [`ably push config clear-fcm`](#ably-push-config-clear-fcm) +* [`ably push config set-apns`](#ably-push-config-set-apns) +* [`ably push config set-fcm`](#ably-push-config-set-fcm) +* [`ably push config show`](#ably-push-config-show) +* [`ably push devices`](#ably-push-devices) +* [`ably push devices get DEVICEID`](#ably-push-devices-get-deviceid) +* [`ably push devices list`](#ably-push-devices-list) +* [`ably push devices remove DEVICEID`](#ably-push-devices-remove-deviceid) +* [`ably push devices remove-where`](#ably-push-devices-remove-where) +* [`ably push devices save`](#ably-push-devices-save) +* [`ably push publish`](#ably-push-publish) * [`ably queues`](#ably-queues) * [`ably queues create`](#ably-queues-create) -* [`ably queues delete QUEUENAME`](#ably-queues-delete-queuename) +* [`ably queues delete QUEUEID`](#ably-queues-delete-queueid) * [`ably queues list`](#ably-queues-list) * [`ably rooms`](#ably-rooms) * [`ably rooms list`](#ably-rooms-list) @@ -182,7 +204,7 @@ See [MCP Server section](#mcp-server) for more details on how to use the MCP Ser * [`ably rooms messages reactions send ROOM MESSAGESERIAL REACTION`](#ably-rooms-messages-reactions-send-room-messageserial-reaction) * [`ably rooms messages reactions subscribe ROOM`](#ably-rooms-messages-reactions-subscribe-room) * [`ably rooms messages send ROOM TEXT`](#ably-rooms-messages-send-room-text) -* [`ably rooms messages subscribe ROOM`](#ably-rooms-messages-subscribe-room) +* [`ably rooms messages subscribe ROOMS`](#ably-rooms-messages-subscribe-rooms) * [`ably rooms occupancy`](#ably-rooms-occupancy) * [`ably rooms occupancy get ROOM`](#ably-rooms-occupancy-get-room) * [`ably rooms occupancy subscribe ROOM`](#ably-rooms-occupancy-subscribe-room) @@ -535,7 +557,6 @@ COMMANDS ably apps delete Delete an app ably apps list List all apps in the current account ably apps logs Stream or retrieve app logs - ably apps set-apns-p12 Upload Apple Push Notification Service P12 certificate for an app ably apps stats Get app stats with optional live updates ably apps switch Switch to a different Ably app ably apps update Update an app @@ -811,17 +832,17 @@ EXAMPLES _See code: [src/commands/apps/current.ts](https://github.com/ably/ably-cli/blob/v0.15.0/src/commands/apps/current.ts)_ -## `ably apps delete [ID]` +## `ably apps delete [APPID]` Delete an app ``` USAGE - $ ably apps delete [ID] [--access-token ] [--api-key ] [--client-id ] [--env ] + $ ably apps delete [APPID] [--access-token ] [--api-key ] [--client-id ] [--env ] [--endpoint ] [--host ] [--json | --pretty-json] [--token ] [-v] [-f] [--app ] ARGUMENTS - ID App ID to delete (uses current app if not specified) + APPID App ID to delete (uses current app if not specified) FLAGS -f, --force Skip confirmation prompt @@ -992,48 +1013,6 @@ EXAMPLES _See code: [src/commands/apps/logs/subscribe.ts](https://github.com/ably/ably-cli/blob/v0.15.0/src/commands/apps/logs/subscribe.ts)_ -## `ably apps set-apns-p12 ID` - -Upload Apple Push Notification Service P12 certificate for an app - -``` -USAGE - $ ably apps set-apns-p12 ID --certificate [--access-token ] [--api-key ] [--client-id ] - [--env ] [--endpoint ] [--host ] [--json | --pretty-json] [--token ] [-v] [--password - ] [--use-for-sandbox] - -ARGUMENTS - ID App ID to set the APNS certificate for - -FLAGS - -v, --verbose Output verbose logs - --access-token= Overrides any configured access token used for the Control API - --api-key= Overrides any configured API key used for the product APIs - --certificate= (required) Path to the P12 certificate file - --client-id= Overrides any default client ID when using API authentication. Use "none" to explicitly - set no client ID. Not applicable when using token authentication. - --endpoint= Override the endpoint for all product API calls - --env= Override the environment for all product API calls - --host= Override the host endpoint for all product API calls - --json Output in JSON format - --password= Password for the P12 certificate - --pretty-json Output in colorized JSON format - --token= Authenticate using an Ably Token or JWT Token instead of an API key - --use-for-sandbox Whether to use this certificate for the APNS sandbox environment - -DESCRIPTION - Upload Apple Push Notification Service P12 certificate for an app - -EXAMPLES - $ ably apps set-apns-p12 app-id --certificate /path/to/certificate.p12 - - $ ably apps set-apns-p12 app-id --certificate /path/to/certificate.p12 --password "YOUR_CERTIFICATE_PASSWORD" - - $ ably apps set-apns-p12 app-id --certificate /path/to/certificate.p12 --use-for-sandbox -``` - -_See code: [src/commands/apps/set-apns-p12.ts](https://github.com/ably/ably-cli/blob/v0.15.0/src/commands/apps/set-apns-p12.ts)_ - ## `ably apps stats [ID]` Get app stats with optional live updates @@ -1227,7 +1206,7 @@ FLAGS --pretty-json Output in colorized JSON format --token= Authenticate using an Ably Token or JWT Token instead of an API key --token-only Output only the token string without any formatting or additional information - --ttl= [default: 3600] Time to live in seconds + --ttl= [default: 3600] Time to live in seconds (default: 3600, 1 hour) DESCRIPTION Creates an Ably Token with capabilities @@ -1279,7 +1258,7 @@ FLAGS --pretty-json Output in colorized JSON format --token= Authenticate using an Ably Token or JWT Token instead of an API key --token-only Output only the token string without any formatting or additional information - --ttl= [default: 3600] Time to live in seconds + --ttl= [default: 3600] Time to live in seconds (default: 3600, 1 hour) DESCRIPTION Creates an Ably JWT token with capabilities @@ -1772,7 +1751,7 @@ Run a subscriber benchmark test ``` USAGE $ ably bench subscriber CHANNEL [--access-token ] [--api-key ] [--client-id ] [--env ] - [--endpoint ] [--host ] [--json | --pretty-json] [--token ] [-v] + [--endpoint ] [--host ] [--json | --pretty-json] [--token ] [-v] [-d ] ARGUMENTS CHANNEL The channel name to subscribe to @@ -1845,13 +1824,14 @@ ARGUMENTS MESSAGE The message to publish (JSON format or plain text, not needed if using --spec) FLAGS - -e, --encoding= The encoding for the message - -n, --name= The event name (if not specified in the message JSON) + -e, --encoding= The encoding for the message (not used with --spec) + -n, --name= The event name (if not specified in the message JSON, not used with --spec) -v, --verbose Output verbose logs --access-token= Overrides any configured access token used for the Control API --api-key= Overrides any configured API key used for the product APIs - --channels= Comma-separated list of channel names to publish to - --channels-json= JSON array of channel names to publish to + --channels= Comma-separated list of channel names to publish to (mutually exclusive with + --channels-json and --spec) + --channels-json= JSON array of channel names to publish to (mutually exclusive with --channels and --spec) --client-id= Overrides any default client ID when using API authentication. Use "none" to explicitly set no client ID. Not applicable when using token authentication. --endpoint= Override the endpoint for all product API calls @@ -1860,7 +1840,7 @@ FLAGS --json Output in JSON format --pretty-json Output in colorized JSON format --spec= Complete batch spec JSON (either a single BatchSpec object or an array of BatchSpec - objects) + objects). When used, --channels, --channels-json, --name, and --encoding are ignored --token= Authenticate using an Ably Token or JWT Token instead of an API key DESCRIPTION @@ -1904,14 +1884,14 @@ FLAGS --cipher= Decryption key for encrypted messages (AES-128) --client-id= Overrides any default client ID when using API authentication. Use "none" to explicitly set no client ID. Not applicable when using token authentication. - --direction=