magecli

module
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2026 License: MIT

README

magecli

CI Go Report Card Go Reference Release

A CLI tool for querying Magento 2 stores via the REST API. Built for AI agents (Claude Code, Codex) and developers.

Full documentation, examples, and AI agent integration guide: https://atlanticbt.github.io/magecli/

Install

Linux / macOS (one-liner):

curl -fsSL https://raw.githubusercontent.com/atlanticbt/magecli/main/install.sh | sh

Windows (PowerShell):

irm https://raw.githubusercontent.com/atlanticbt/magecli/main/install.ps1 | iex

From Go:

go install github.com/atlanticbt/magecli/cmd/magecli@latest

From source:

git clone https://github.com/atlanticbt/magecli.git && cd magecli
make build
# Binary at bin/magecli

The install scripts detect your OS/architecture, download the latest release from GitHub, verify the SHA-256 checksum, and place the binary in your PATH. Use --dir to change the install location or --version to pin a specific release:

curl -fsSL https://raw.githubusercontent.com/atlanticbt/magecli/main/install.sh | sh -s -- --dir ~/.local/bin --version v1.0.0

Quick Start

# 1. Authenticate with your Magento store
magecli auth login https://store.example.com --token <integration-bearer-token>

# 2. Create a context (read-only by default)
magecli context create production --host store.example.com --set-active

# Or allow write operations via the api command
# magecli context create production --host store.example.com --set-active --allow-writes

# 3. Query products
magecli product list --filter "name like %shirt%" --json
magecli product view SKU123 --json --jq '.name'
magecli category tree --json
magecli inventory status SKU123 --json

Commands

Command Description
auth login/status/logout Manage authentication
context create/list/use/delete Manage store contexts
product list/search/view/media/children/options/url Catalog products
category tree/view/products Category browsing
attribute view/options/sets Product attributes
inventory status Stock status
store views/config/groups/websites Store configuration
config list/get/dump System configuration
promo catalog-rule/cart-rule/coupon list/view Promotions & coupons
cms page list/view, cms block list/view CMS content
api Raw REST API escape hatch (read-only by default)
update Self-update to the latest release

Authentication

Magento 2.3.2+ requires authentication for all REST API access. magecli uses Integration Access Tokens (permanent bearer tokens) created in the Magento Admin.

Creating an Integration Token
  1. Log in to the Magento Admin Panel
  2. Navigate to System > Extensions > Integrations
  3. Click Add New Integration
  4. On the Integration Info tab:
    • Enter a name (e.g., magecli)
    • Leave the callback/identity URLs blank
  5. On the API tab:
    • Select the resource access the integration needs (use All for full read access, or scope to specific resources like Catalog, CMS, etc.)
  6. Click Save and then Activate
  7. Confirm the permissions in the popup — Magento will display four tokens:
    • Consumer Key
    • Consumer Secret
    • Access Token — this is the one magecli needs
    • Access Token Secret
  8. Copy the Access Token value
Storing the Token
# Store token in OS keyring
magecli auth login https://store.example.com --token <access-token>

# Or use environment variable
export MAGECLI_TOKEN=<access-token>

# On headless servers without a keyring, use the insecure file store
magecli auth login https://store.example.com --token <access-token> --allow-insecure-store

Filtering & Sorting

magecli product list --filter "name like %shirt%" --filter "price gt 50" --sort "price:ASC" --limit 20

Operators: eq, neq, gt, gteq, lt, lteq, like, nlike, in, nin, null, notnull, from, to, finset

Output Formats

magecli product list --json                          # JSON
magecli product list --yaml                          # YAML
magecli product list --json --jq '.items[].sku'     # jq filter
magecli product list --json --template '...'         # Go template

Updating

magecli update          # Update to the latest release
magecli update --force  # Reinstall even if already on the latest version

Downloads the latest release from GitHub, verifies the SHA-256 checksum, and replaces the binary in place.

AI Agent Integration

Install the magecli skill for Claude Code or Codex:

npx skills add atlanticbt/magecli

License

MIT

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL