This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Replyke CLI is a shadcn-style component distribution system for Replyke comment systems. It allows users to install pre-built, customizable React and React Native comment components directly into their projects using a CLI tool.
# Build CLI (from root)
pnpm build
# Watch mode for development
pnpm dev
# Type checking
cd packages/cli && pnpm typecheck
# Run CLI directly during development
pnpm cli init
pnpm cli add comments-threadedFrom a separate test project:
# Initialize Replyke config
node /path/to/cli/packages/cli/dist/index.js init
# Add components
node /path/to/cli/packages/cli/dist/index.js add comments-threaded
node /path/to/cli/packages/cli/dist/index.js add comments-socialThis is a pnpm workspace monorepo with two main parts:
packages/cli/- The CLI tool itself (published as@replyke/cli)registry/- Component registry containing all installable components
Entry Point: index.ts
- Uses Commander.js for CLI commands
- Two main commands:
initandadd
Commands:
-
init.ts- Project initialization- Detects project type (React/React Native/Expo)
- Prompts user for platform, styling (styled/tailwind), and install path
- Creates
replyke.jsonconfig file - Checks and optionally installs peer dependencies
-
add.ts- Component installation- Reads
replyke.jsonconfig - Fetches component metadata from registry
- Downloads component files (locally during dev, from GitHub in production)
- Transforms imports (changes
../files/to../components/) - Organizes files into directory structure
- Creates barrel export
index.ts - Excludes development-only files (package.json, lockfiles, etc.)
- Reads
Utilities:
-
registry.ts- Registry fetching logic- Tries local registry first (for development)
- Falls back to GitHub raw URLs for production
- Path resolution:
registry/{platform}/{component}/{style}/registry.json
-
transform.ts- Import path transformation- Converts registry structure to user's project structure
- Changes
from '../files/foo'tofrom '../components/foo'
-
detect.ts- Project type detection- Reads package.json to identify React vs React Native vs Expo
-
dependencies.ts- Dependency management- Checks for required peer dependencies
- Offers to auto-install missing deps
- Detects package manager (npm/yarn/pnpm)
registry/
├── react/ # React web components
│ ├── comments-threaded/
│ │ ├── styled/ # Inline styles variant
│ │ │ ├── registry.json # Component metadata
│ │ │ ├── files/ # Component files
│ │ │ ├── hooks/ # React hooks
│ │ │ ├── utils/ # Utilities
│ │ │ └── context/ # Context providers
│ │ └── tailwind/ # Tailwind variant
│ └── comments-social/
│ ├── styled/
│ └── tailwind/
└── react-native/ # React Native components
└── comments-social/
└── styled/
registry.json Format:
{
"name": "comments-threaded",
"platform": "react",
"style": "styled",
"version": "1.0.0",
"description": "...",
"dependencies": ["@replyke/react-js@^6.0.0"],
"files": [
{
"path": "files/component.tsx",
"type": "component",
"description": "..."
}
],
"registryUrl": "https://raw.githubusercontent.com/replyke/cli/main/registry/react/comments-threaded/styled",
"exports": {
"mainComponent": "ThreadedCommentSection",
"mainFile": "threaded-comment-section",
"typeExports": ["ThreadedStyleCallbacks"]
}
}- User runs
add comments-threaded - CLI reads
replyke.jsonto get platform/style preferences - Fetches
registry.jsonfromregistry/{platform}/{component}/{style}/ - Downloads each file listed in registry.json
- Transforms imports (registry structure → user's project structure)
- Files are organized into directories:
files/→{componentsPath}/{component}/components/hooks/→{componentsPath}/{component}/hooks/utils/→{componentsPath}/{component}/utils/context/→{componentsPath}/{component}/context/
- Creates barrel export
index.tsthat re-exports the main component - Development files (package.json, lockfiles, etc.) are excluded
Components are distributed as source code (not npm packages) following the shadcn approach:
- Users get full source code in their project
- Components can be customized directly
- No hidden dependencies on core packages' internals
- Styles are inline and editable (or Tailwind classes)
- All @replyke/comments-*-core dependencies have been removed
Fully Working:
- React web components (threaded, social) with styled and tailwind variants
- React Native social comments with styled variant
- CLI init and add commands
- Local registry (for development)
- GitHub registry (for production/npx usage)
Known Limitations:
- No
diffcommand yet (for updating installed components) - React Native threaded comments not yet converted
- Only basic import transformation (no complex alias support yet)
When copying components from registry to user's project, imports must be transformed:
- Registry structure uses
files/,hooks/,utils/,context/ - User's project uses
components/,hooks/,utils/,context/ - Transform:
from '../files/foo'→from '../components/foo'
Components require these peer dependencies:
- React:
@replyke/react-js,@replyke/ui-core-react-js - React Native:
@replyke/react-native,@replyke/ui-core-react-native - Expo:
@replyke/expo,@replyke/ui-core-react-native
- Local Development: Registry is loaded from
registry/directory (relative to CLI package) - Production (npx): Registry is fetched from GitHub raw URLs
- This dual approach allows testing locally before publishing
- Create directory:
registry/{platform}/{component-name}/{style}/ - Add
registry.jsonwith metadata - Add component files in appropriate subdirectories:
files/- Main component fileshooks/- React hooksutils/- Utility functionscontext/- Context providers
- Ensure no @replyke/comments-*-core imports (components should be self-contained)
- Use relative imports between files
- Add
exportsmetadata to registry.json for proper barrel export generation
After making changes to CLI:
- Build:
pnpm build - Create a test React/React Native project
- Run CLI from built dist:
node packages/cli/dist/index.js init - Add components:
node packages/cli/dist/index.js add comments-threaded - Verify files copied correctly and imports resolve