add-package — команда для Claude Code: что делает и как установить
Разворачивает новый пакет в монорепозитории с готовой структурой папок, tsconfig.json и регистрацией в nx.json или lerna.json.
npx claude-code-templates@latest --command project-management/add-packageЧто делает add-package
Команда анализирует переданное имя и тип пакета: library, application, tool, shared, service или component-library. Каталог создаётся внутри packages/, apps/ или libs/. Сразу разворачивается базовая структура с папками src/, tests/ и файлами документации, а для приложений добавляется каталог public/ под статические ресурсы.
Дальше формируются конфигурационные файлы. Скрипт генерирует package.json со скриптами сборки и точками входа, а также настраивает tsconfig.json, расширяющий базовые настройки рабочего пространства. Пакет регистрируется в nx.json или lerna.json. Для библиотек компонентов подготавливается Storybook, а для консольных утилит настраиваются бинарные экспорты.
Шаблону нужны разрешения на вызовы Read, Write, Edit, Bash и Glob. Без подготовленного монорепозитория финальная проверка сборки и зависимостей завершится с ошибкой.
Какие задачи решает
- создать структуру директорий нового пакета внутри
packages/,apps/илиlibs/ - сгенерировать
package.jsonиtsconfig.jsonпод стандарты монорепозитория - зарегистрировать новый пакет в конфигурациях
nx.jsonилиlerna.json - настроить базовые скрипты сборки, тестирования и экспорта модулей
Примеры запросов агенту
- /add-package
ui-kit --library - /add-package
admin-panel --application - /add-package sync-cli tool
Как установить add-package
1Через claude-code-templates
npx claude-code-templates@latest --command project-management/add-package2Вручную: положить файлы
.claude/commands/add-package.mdВызов — /add-package. Для всех проектов — ~/.claude/commands/
Вручную: положить файлы
~/.codex/prompts/add-package.mdВызов — /prompts:add-package. В Codex этот формат помечен устаревшим, замена — скиллы
Вручную: положить файлы
.github/prompts/add-package.prompt.mdВручную: положить файлы
.gemini/commands/add-package.tomlGemini хранит команды в TOML: текст запроса — в поле prompt
Вопросы о add-package
Как установить add-package в Claude Code?
Выполните в терминале команду npx claude-code-templates@latest --command project-management/add-package. Файл с инструкцией сохранится по пути .claude/commands/add-package.md.
Что делает команда add-package?
Она автоматически создаёт каталог пакета, раскладывает стартовые файлы, привязывает модуль к монорепозиторию и проверяет сборку.
Какие инструменты нужны для работы add-package?
Команде требуются встроенные инструменты Read, Write, Edit, Bash и Glob. Они используются для записи конфигураций, чтения настроек репозитория и запуска тестовой сборки.
Исходный текст
add-package.md · MIT
---
allowed-tools: Read, Write, Edit, Bash, Glob
argument-hint: "[package-name] [package-type] | --library | --application | --tool"
description: Add and configure new package to workspace with proper structure and dependencies
---
# Add Package to Workspace
Add and configure new project dependencies: **$ARGUMENTS**
## Instructions
1. **Package Definition and Analysis**
- Parse package name and type from arguments: `$ARGUMENTS` (format: name [type])
- If no arguments provided, prompt for package name and type
- Validate package name follows workspace naming conventions
- Determine package type: library, application, tool, shared, service, component-library
- Check for naming conflicts with existing packages
2. **Package Structure Creation**
- Create package directory in appropriate workspace location (packages/, apps/, libs/)
- Set up standard package directory structure based on type:
- `src/` for source code
- `tests/` or `__tests__/` for testing
- `docs/` for package documentation
- `examples/` for usage examples (if library)
- `public/` for static assets (if application)
- Create package-specific configuration files
3. **Package Configuration Setup**
- Generate package.json with proper metadata:
- Name following workspace conventions
- Version aligned with workspace strategy
- Dependencies and devDependencies
- Scripts for build, test, lint, dev
- Entry points and exports configuration
- Configure TypeScript (tsconfig.json) extending workspace settings
- Set up package-specific linting and formatting rules
4. **Package Type-Specific Setup**
- **Library**: Configure build system, export definitions, API documentation
- **Application**: Set up routing, environment configuration, build optimization
- **Tool**: Configure CLI setup, binary exports, command definitions
- **Shared**: Set up common utilities, type definitions, shared constants
- **Service**: Configure server setup, API routes, database connections
- **Component Library**: Set up Storybook, component exports, styling system
5. **Workspace Integration**
- Register package in workspace configuration (nx.json, lerna.json, etc.)
- Configure package dependencies and peer dependencies
- Set up cross-package imports and references
- Configure workspace-wide build order and dependencies
- Add package to workspace scripts and task runners
6. **Development Environment**
- Configure package-specific development server (if applicable)
- Set up hot reloading and watch mode
- Configure debugging and source maps
- Set up development proxy and API mocking (if needed)
- Configure environment variable management
7. **Testing Infrastructure**
- Set up testing framework configuration for the package
- Create initial test files and examples
- Configure test coverage reporting
- Set up package-specific test scripts
- Configure integration testing with other workspace packages
8. **Build and Deployment**
- Configure build system for the package type
- Set up build artifacts and output directories
- Configure bundling and optimization
- Set up package publishing configuration (if library)
- Configure deployment scripts (if application)
9. **Documentation and Examples**
- Create package README with installation and usage instructions
- Set up API documentation generation
- Create usage examples and demos
- Document package architecture and design decisions
- Add package to workspace documentation
10. **Validation and Integration Testing**
- Verify package builds successfully
- Test package installation and imports
- Validate workspace dependency resolution
- Test development workflow and hot reloading
- Verify CI/CD pipeline includes new package
- Test cross-package functionality and integration
© davila7 · MIT · davila7/claude-code-templates