---
name: cli-tools
description: "WHAT: Yarn scripts for React Native monorepo development. WHEN: running dev builds, testing, linting, code generation. KEYWORDS: yarn, dev:ios, dev:android, test, lint, typecheck, generate, turbo, build, clean."
---

# CLI Tools

## Core Principles

**Always use yarn scripts, never run tools directly.** Run `yarn dev:ios` not `npx react-native run-ios`. Yarn scripts include necessary environment variables, flags, and configurations. Direct tool invocation skips project-specific setup.

**Always use yarn, never npm.** The project uses Yarn 4.5.0 with workspace configuration. Running `npm install` or `npm run` breaks workspace resolution and dependency management.

**Always check package.json or this document for exact script names.** Don't assume conventions. The project uses `yarn dev:ios` not `yarn ios`. Custom naming prevents conflicts with React Native CLI.

**Always use code generation scripts for scaffolding.** Run `yarn generate:module` for modules, `yarn graphql:generate` for GraphQL types. Plop templates follow project conventions for file structure and naming.

**Why**: Consistent CLI usage ensures reproducible builds, prevents environment-specific issues, automates complex setup sequences, and maintains code quality through pre-commit hooks.

## When to Use This Skill

Use these commands when:

- Running the app locally on iOS or Android
- Building the library for distribution
- Running tests with Jest
- Linting code with ESLint
- Type checking with TypeScript
- Generating new modules or components
- Scaffolding GraphQL types from schema
- Cleaning build artifacts
- Setting up development environment
- Running accessibility checks
- Opening Xcode or Android Studio
- Managing git hooks with Husky
- Orchestrating monorepo builds with Turbo

## Development Commands

### Running the App

Start Metro bundler and run app on iOS or Android.

```bash
# Start Metro bundler (terminal 1)
yarn start

# Run iOS app (terminal 2)
yarn dev:ios

# Run Android app (terminal 2)
yarn dev:android
```

**What dev:ios and dev:android do:**
1. Prompt for local path to YourCompany iOS/Android repositories (cached in `.env.local_dev_paths`)
2. **iOS**: Build debug XCFramework if needed, symlink to local iOS repo, run metro bundler
3. **Android**: Configure AAR symlink to local Android repo, run metro bundler
4. Enable live development with local changes reflected in consumer apps

**Why**: These commands handle environment configuration, native builds, and symlink setup automatically. Live development without publishing to npm or Maven.

### Shell App

Test modules in isolation using the shell app.

```bash
# Run shell app on iOS
yarn app ios

# Run shell app on Android
yarn app android

# Generic command syntax
yarn app <command>
```

**Why**: The shell app (`app/*` workspace) allows developing modules without full YourCompany consumer apps. Faster iteration for module development.

### Building

Compile library for distribution with TypeScript definitions.

```bash
# Build library (CommonJS, ES modules, TypeScript definitions)
yarn build

# Type checking without emitting files
yarn typecheck
```

**Why**: `yarn build` uses react-native-builder-bob with correct configuration for multiple module formats. `yarn typecheck` runs TypeScript compiler with project-specific tsconfig.

## Code Quality

### Linting

Run ESLint with accessibility checks.

```bash
# Run ESLint on all source files
yarn lint

# Accessibility baseline checks (runs on staged files)
yarn a11y:check

# Accessibility check with verbose output
yarn a11y:check:verbose

# Check all files for accessibility issues
yarn a11y:check:all

# Generate new accessibility baseline
yarn a11y:baseline:gen

# Update existing accessibility baseline
yarn a11y:baseline:update

# Generate accessibility report
yarn a11y:report
```

**Why**: `yarn lint` includes custom ESLint rules and React Native plugins. Accessibility commands track baseline and flag regressions. Pre-commit hooks run these automatically.

### Testing

Run Jest tests with React Native preset.

```bash
# Run all tests
yarn test

# Run specific test file
yarn jest <path-to-test>

# Run tests in watch mode
yarn jest --watch

# Run tests with coverage
yarn jest --coverage

# Update snapshots
yarn jest -u
```

**Why**: `yarn test` runs with project-specific Jest configuration, React Native transformers, and module resolution. Direct `jest` usage provides more control for debugging.

### Maestro E2E Tests

Run end-to-end tests on iOS simulator or Android emulator.

```bash
# Run Maestro tests on iOS simulator
./scripts/maestro-test.sh ios

# Run Maestro tests on Android emulator
./scripts/maestro-test.sh android

# Run specific test directory
./scripts/maestro-test.sh ios ./MaestroTests/onboarding/
```

**Why**: Maestro tests validate complete user journeys on actual devices/simulators. Script automatically detects running emulators and executes YAML test flows.

## Code Generation

### Module Scaffolding

Generate modules and components with Plop templates.

```bash
# Generate new module (follows project conventions)
yarn generate:module

# Extend existing module
yarn extend:module

# Generate brand assets
yarn generate:brand-assets
```

**Why**: Plop templates follow project conventions for file structure, naming, and boilerplate. Consistent module organization across features.

### Data Layer

Generate types and code from schemas.

```bash
# Generate GraphQL types and operations
yarn graphql:generate

# Generate native data access layer
yarn generate:data-access:native

# Generate Swift types from TypeScript
yarn generate:swift-types
```

**Why**: Code generation ensures type safety between TypeScript, GraphQL schemas, and native Swift code. Prevents runtime type errors.

## Platform-Specific Commands

### iOS

Manage iOS dependencies and build artifacts.

```bash
# Install iOS dependencies (CocoaPods)
yarn install:ios

# Clean iOS build artifacts
yarn clean:ios

# Open Xcode workspace
yarn open:xcode
```

**Why**: These scripts handle CocoaPods installation and Xcode workspace management. `clean:ios` removes derived data and build caches.

### Android

Manage Android build artifacts and tools.

```bash
# Clean Android build artifacts and Gradle caches
yarn clean:android

# Open Android Studio
yarn open:androidstudio
```

**Why**: `clean:android` runs Gradle tasks that properly clear all build caches. Opens Android Studio with correct project structure.

## Building Native Artifacts

### iOS XCFramework

Build React Shared Modules as XCFramework for iOS.

```bash
# Build for both device and simulator (for distribution)
./scripts/build_spm_frameworks.sh --target both

# Build for device only
./scripts/build_spm_frameworks.sh --target device

# Build for simulator only (for local testing)
./scripts/build_spm_frameworks.sh --target simulator
```

**Why**: XCFramework consumed by YourCompany iOS app via Swift Package Manager. Simulator-only builds are faster for local iteration.

### Android AAR

Build Android Archive for YourCompany Android app.

```bash
# Build AAR locally
cd app/android && ./gradlew :modules:bundleReleaseAar

# Publish to local Maven repository
cd app/android && ./gradlew :modules:publishToMavenLocal
```

**Why**: AAR contains compiled code, resources, and JavaScript bundle. Publishing to local Maven allows testing AAR changes before release.

## Environment Setup

Configure development environment and git hooks.

```bash
# Set up development environment
yarn setup:env

# Install git hooks (runs automatically after install)
yarn prepare
```

**Why**: `setup:env` configures environment variables and dependencies. `prepare` installs Husky git hooks for pre-commit checks (lint-staged, a11y).

## Localization

Manage translation files and synchronization.

```bash
# Run localization helper utilities
yarn localization:helpers
```

**Why**: Manages translation file validation and synchronization with Lokalise translation management system.

## Developer Tools

Open toolbox UI for common development tasks.

```bash
# Open toolbox UI (new version)
yarn toolbox

# Open toolbox UI (deprecated version)
yarn toolbox:deprecated
```

**Why**: Toolbox provides UI for feature flag management, environment switching, and other development utilities.

## Workspace Commands

Run commands in specific workspaces within monorepo.

```bash
# Run command in app workspace
yarn app <command>

# Run command in specific workspace
yarn workspace @repo/toolbox <command>
```

**Why**: Yarn workspaces enable monorepo management. Workspace commands ensure dependencies and scripts run in correct package context.

## Pre-Commit Hooks

### lint-staged

Runs automatically on `git commit` via Husky. Manually run:

```bash
# Run lint-staged on staged files
yarn lint-staged
```

**Checks on staged files:**
- **TypeScript/TSX files** (`.ts`, `.tsx`):
  - ESLint with auto-fix (`--fix`)
  - Prettier formatting
  - Accessibility baseline check (non-test files in `src/`)

- **JavaScript files** (`.js`):
  - ESLint with auto-fix
  - Prettier formatting

- **JSON, Markdown, YAML files**:
  - Prettier formatting

- **Team governance files** (`.teams/*.json`, `**/.claim.json`):
  - JSON schema validation with ajv
  - Claims validation check

**Why**: Lint-staged ensures only valid, formatted code is committed. Faster than running checks on all files (only processes staged changes).

### Prettier

Format code with Prettier.

```bash
# Format specific files
yarn prettier --write <file>

# Check formatting without fixing
yarn prettier --check <file>

# Format all files (use with caution)
yarn prettier --write .
```

**Why**: Direct prettier invocation for formatting files outside git workflows. Prefer lint-staged for pre-commit formatting.

### ESLint

Lint code with ESLint.

```bash
# Lint specific files with auto-fix
yarn eslint <file> --fix

# Lint without a11y checks (matches lint-staged behavior)
ESLINT_DISABLE_A11Y=1 yarn eslint <file> --fix
```

**Why**: Direct ESLint usage for debugging linting issues. Use `yarn lint` for full project lint run.

## Monorepo Orchestration

### Turbo

Run scripts across workspaces with caching.

```bash
# Run turbo commands across workspaces
yarn turbo run <script-name>

# Examples
yarn turbo run build
yarn turbo run lint
yarn turbo run check-types
```

**Why**: Turbo 2.5.6 orchestrates script execution across monorepo. Creates dependency graph, runs scripts in parallel, caches results to avoid redundant work.

**Note**: Turbo expects consistent script names across packages (`build`, `lint`, `check-types`, `dev`).

### Husky

Manage git hooks.

```bash
# Manually reinstall git hooks
yarn husky install

# Test pre-commit hook manually
yarn husky run pre-commit
```

**Why**: Husky 9.1.7 manages git hooks. Hooks install automatically via `yarn prepare` but can be manually reinstalled if needed.

## TypeScript Compiler

Type check and build type definitions.

```bash
# Type check without emitting files (use yarn typecheck instead)
yarn tsc --noEmit

# Build type definitions
yarn tsc --project tsconfig.build.json
```

**Why**: Direct `tsc` usage rarely needed since `yarn typecheck` and `yarn build` handle this. Useful for debugging type errors with specific compiler flags.

## Common Mistakes to Avoid

❌ **Don't run underlying tools directly**:

```bash
# ❌ Wrong - missing environment config
npx react-native run-ios
./gradlew clean
eslint src
jest
```

**Why**: Direct tool invocation skips project-specific environment variables, flags, and configurations. May work differently on different machines.

✅ **Do use yarn scripts**:

```bash
# ✅ Correct - includes all necessary config
yarn dev:ios
yarn clean:android
yarn lint
yarn test
```

**Why**: Yarn scripts abstract complex command sequences, handle environment setup, and ensure consistent behavior across team.

❌ **Don't use npm commands**:

```bash
# ❌ Wrong - breaks workspace resolution
npm run test
npm install
npm run dev:ios
```

**Why**: Project uses Yarn 4.5.0 with workspace configuration and custom resolutions. npm breaks workspace dependency management.

✅ **Do use yarn commands**:

```bash
# ✅ Correct - uses Yarn workspace resolution
yarn test
yarn install
yarn dev:ios
```

**Why**: Yarn 4.5.0 manages monorepo with workspace dependencies. Consistent package manager across team.

❌ **Don't assume standard script names**:

```bash
# ❌ Wrong - these scripts don't exist
yarn ios
yarn android
yarn run
```

**Why**: Project uses custom naming conventions. Script names may differ from common React Native conventions.

✅ **Do check package.json for exact names**:

```bash
# ✅ Correct - use actual script names
yarn dev:ios
yarn dev:android
yarn start
```

**Why**: Custom naming prevents conflicts with React Native CLI. Check `package.json` or this document for exact script names.

❌ **Don't manually create modules**:

```bash
# ❌ Wrong - manual file creation
mkdir src/modules/new-feature
touch src/modules/new-feature/index.ts
```

**Why**: Manual creation skips project conventions for file structure, naming, and boilerplate.

✅ **Do use code generation scripts**:

```bash
# ✅ Correct - uses Plop templates
yarn generate:module

# Follow prompts for module name, type, etc.
```

**Why**: Plop templates follow project conventions automatically. Consistent module organization, imports, exports, and tests.

## Quick Reference

**Development:**
- `yarn start` - Start Metro bundler
- `yarn dev:ios` - Run iOS app with local symlinks
- `yarn dev:android` - Run Android app with local symlinks
- `yarn app <command>` - Run shell app commands

**Building:**
- `yarn build` - Compile library for distribution
- `yarn typecheck` - Type check without emitting

**Code Quality:**
- `yarn lint` - Run ESLint
- `yarn a11y:check` - Accessibility baseline check
- `yarn test` - Run Jest tests

**Code Generation:**
- `yarn generate:module` - Scaffold new module
- `yarn graphql:generate` - Generate GraphQL types
- `yarn generate:swift-types` - Generate Swift types

**Platform:**
- `yarn install:ios` - Install CocoaPods
- `yarn clean:ios` - Clean iOS artifacts
- `yarn clean:android` - Clean Android artifacts
- `yarn open:xcode` - Open Xcode workspace
- `yarn open:androidstudio` - Open Android Studio

**Native Builds:**
- `./scripts/build_spm_frameworks.sh --target simulator` - Build iOS XCFramework
- `cd app/android && ./gradlew :modules:bundleReleaseAar` - Build Android AAR

**Setup:**
- `yarn setup:env` - Configure environment
- `yarn prepare` - Install git hooks

**Utilities:**
- `yarn localization:helpers` - Translation utilities
- `yarn toolbox` - Developer toolbox UI

**Monorepo:**
- `yarn turbo run <script>` - Run across workspaces
- `yarn workspace <name> <command>` - Run in specific workspace

**Pre-Commit:**
- `yarn lint-staged` - Run pre-commit checks
- `yarn prettier --write <file>` - Format code
- `yarn eslint <file> --fix` - Lint and fix

**Testing:**
- `yarn jest <path>` - Run specific test
- `yarn jest --watch` - Watch mode
- `yarn jest --coverage` - Coverage report
- `./scripts/maestro-test.sh ios` - E2E tests

**Never use:**
- ❌ `npm install` - Use `yarn install`
- ❌ `npm run <script>` - Use `yarn <script>`
- ❌ `npx react-native run-ios` - Use `yarn dev:ios`
- ❌ `./gradlew clean` - Use `yarn clean:android`

**Full CLI reference**: `previous-standards/global/cli-tools.md`


---
Source attribution: David-Li0406
Original project: https://github.com/David-Li0406/meta-skill-evloving/blob/ca3a335628981df10c36e00cb9850df2c247ab9a/skill-flow/data/skills-refined-36k/skillsmp/cli-tools-1/SKILL.md
License: Apache-2.0
License information: https://www.apache.org/licenses/LICENSE-2.0
Original upstream instructions; downloaded from Dave AI.

## Upstream license notice

Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

   END OF TERMS AND CONDITIONS

   APPENDIX: How to apply the Apache License to your work.

      To apply the Apache License to your work, attach the following
      boilerplate notice, with the fields enclosed by brackets "[]"
      replaced with your own identifying information. (Don't include
      the brackets!)  The text should be enclosed in the appropriate
      comment syntax for the file format. We also recommend that a
      file or class name and description of purpose be included on the
      same "printed page" as the copyright notice for easier
      identification within third-party archives.

   Copyright [yyyy] [name of copyright owner]

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.



# Dave AI resource metadata

Creator / publisher: David-Li0406
Original project: https://github.com/David-Li0406/meta-skill-evloving/blob/ca3a335628981df10c36e00cb9850df2c247ab9a/skill-flow/data/skills-refined-36k/skillsmp/cli-tools-1/SKILL.md
Attribution basis: Source repository record

Fields of work: Development & Engineering, Product Management
Roles: Frontend Developer, Mobile Developer, Product Manager
Specialties: Backend, Mobile
Tools: React Native, Yarn
Country applicability: Country not specified
Classification basis: Source catalog labels
Instruction SHA-256: 8dbade5c03555c8baa1e2486ee11122ddc6e120241691143bcbac8618dbf2317
