or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

index.md
tile.json

index.mddocs/

@commitlint/prompt-cli

Interactive commit message prompt CLI that uses commitlint configuration rules to guide users in creating compliant commit messages. The tool integrates with git to provide a structured, rule-based commit workflow.

Package Information

  • Package Name: @commitlint/prompt-cli
  • Package Type: npm
  • Language: TypeScript (compiled to ES Modules)
  • Installation: npm install -g @commitlint/prompt-cli @commitlint/config-angular
  • Node.js: Requires v18 or higher

Core Installation & Setup

Global installation with a commitlint configuration:

npm install -g @commitlint/prompt-cli @commitlint/config-angular
echo "export default {extends: ['@commitlint/config-angular']};" > commitlint.config.js

Basic Usage

The package provides a single commit command that replaces the standard git commit workflow:

# Stage your changes
git add .

# Use interactive commit prompt
commit

The command will:

  1. Check if there are staged changes in git
  2. Launch interactive prompt for commit message creation
  3. Automatically execute git commit with the formatted message

Capabilities

Interactive Commit Prompting

The primary functionality provided through the commit binary command.

commit
# Exit codes:
# 0 - Success (commit created)
# 1 - No staged changes or other error

Behavior:

  • Validates that git staging area contains changes
  • Displays error message if no staged changes: "Nothing to commit. Stage your changes via "git add" execute "commit" again"
  • Exits with code 1 if no staged changes found
  • Launches interactive prompt using @commitlint/prompt library if staged changes exist
  • Prompts for commit message components (type, scope, subject, body, footer) based on commitlint rules
  • Automatically executes git commit -m "<formatted_message>" upon completion

Requirements:

  • Must be run in a git repository
  • Requires commitlint configuration file (e.g., commitlint.config.js)
  • Requires staged changes in git

Dependencies:

  • Uses @commitlint/prompt for interactive prompting functionality
  • Uses inquirer for command-line user interface
  • Uses tinyexec for git command execution

Configuration

The tool relies on commitlint configuration files to determine commit message rules and structure. Common configuration approaches:

Using preset configuration:

// commitlint.config.js
export default {
  extends: ['@commitlint/config-angular']
};

Custom configuration:

// commitlint.config.js
export default {
  rules: {
    'type-enum': [2, 'always', ['feat', 'fix', 'docs', 'style', 'refactor', 'test', 'chore']],
    'subject-max-length': [2, 'always', 50],
    'header-max-length': [2, 'always', 72]
  }
};

Error Handling

The CLI handles several error scenarios:

  • No staged changes: Displays helpful message and exits with code 1
  • Missing commitlint config: Handled by @commitlint/load dependency
  • Git command failures: Errors are piped to stderr from git subprocess
  • Prompt errors: Caught and logged, returns empty commit message

Integration Points

With Git

  • Executes git diff --cached to check for staged changes
  • Executes git commit -m <message> to create commits
  • Pipes git command output to stdout/stderr

With Commitlint Ecosystem

  • Loads configuration using @commitlint/load
  • Uses @commitlint/prompt for interactive prompting based on loaded rules
  • Compatible with all commitlint configuration presets and custom rules

Common Usage Patterns

Basic workflow:

git add .
commit
# Follow interactive prompts

With specific commitlint config:

# Install with desired config preset
npm install -g @commitlint/prompt-cli @commitlint/config-conventional

# Create config file
echo "export default {extends: ['@commitlint/config-conventional']};" > commitlint.config.js

# Use normally
git add .
commit

Integration in package.json:

{
  "scripts": {
    "commit": "commit"
  },
  "devDependencies": {
    "@commitlint/prompt-cli": "^19.8.1",
    "@commitlint/config-angular": "^19.8.1"
  }
}

Notes

  • This is a pure CLI tool with no programmatic API
  • All functionality is accessed through the commit binary command
  • The tool is designed to replace git commit in developer workflows
  • Written in TypeScript and compiled to ES Modules for distribution
  • Requires Node.js v18 or higher
  • Part of the commitlint monorepo ecosystem