home / skills / hyva-themes / hyva-ai-tools / hyva-exec-shell-cmd

hyva-exec-shell-cmd skill

/skills/hyva-exec-shell-cmd

This skill detects Magento development environment and provides the correct shell command wrapper for executing commands.

npx playbooks add skill hyva-themes/hyva-ai-tools --skill hyva-exec-shell-cmd

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
3.3 KB
---
name: hyva-exec-shell-cmd
description: Utility skill to detect Magento development environment and determine command wrapper. This skill should be used by other skills that need to execute shell commands in the Magento environment. It detects Warden, docker-magento, DDEV, and local environments and provides the appropriate command wrapper.
---

# Execute Shell Commands in Magento Environment

This utility skill detects the Magento development environment and provides the appropriate command wrapper for executing shell commands.

## Usage

Other skills should reference this skill when they need to execute commands in the Magento environment. The detected wrapper ensures commands run in the correct context (container or local).

## Step 1: Detect Environment

**Important:** Execute this script from the Magento project root directory, or provide the path as an argument.

Run this detection once at the start of any skill that needs to execute shell commands:

```bash
<skill_path>/scripts/detect_env.sh [magento_root_path]
```

Where `<skill_path>` is the directory containing this SKILL.md file (e.g., `.claude/skills/hyva-exec-shell-cmd`).

The optional `magento_root_path` argument specifies the Magento installation directory. If omitted, the script uses the current working directory.

Output: `warden`, `docker-magento`, `ddev`, or `local`

## Step 2: Apply Command Wrapper

Based on detected environment, wrap commands as follows:

| Environment | Command Wrapper | Description |
|-------------|-----------------|-------------|
| Warden | `warden env exec -T php-fpm bash -c "<command>"` | Docker environment managed by Warden |
| docker-magento | `bin/clinotty bash -c "<command>"` | Mark Shust's docker-magento setup |
| DDEV | `ddev exec <command>` | DDEV containerized environment |
| Local | Run `<command>` directly | Native environment without containers |

## Examples

### Single command

```bash
# Warden
warden env exec -T php-fpm bash -c "bin/magento cache:clean"

# docker-magento
bin/clinotty bash -c "bin/magento cache:clean"

# DDEV
ddev exec bin/magento cache:clean

# Local
bin/magento cache:clean
```

### Command with directory change

```bash
# Warden
warden env exec -T php-fpm bash -c "cd vendor/hyva-themes/magento2-default-theme/web/tailwind && npm run build"

# docker-magento
bin/clinotty bash -c "cd vendor/hyva-themes/magento2-default-theme/web/tailwind && npm run build"

# DDEV
ddev exec bash -c "vendor/hyva-themes/magento2-default-theme/web/tailwind && npm run build"

# Local
cd vendor/hyva-themes/magento2-default-theme/web/tailwind && npm run build
```

## Commands That Do NOT Require Wrapping

Some commands run on the host system and should NOT be wrapped:

- `composer` commands (runs on host, not in container)
- `git` commands
- File operations on the host filesystem (`ls`, `find`, `cp` for files accessible from host)
- `warden` CLI commands
- `ddev` CLI commands

## Integration Pattern

Skills that need to execute commands should:

1. Reference this skill: "Use the `hyva-exec-shell-cmd` skill to determine the command wrapper"
2. Detect environment once using Step 1
3. Store the wrapper pattern for use throughout the skill
4. Apply the wrapper to all container commands per Step 2

<!-- Copyright © Hyvä Themes https://hyva.io. All rights reserved. Licensed under OSL 3.0 -->

Overview

This skill detects the Magento development environment and returns the correct shell command wrapper to run commands in the proper context. It supports Warden, docker-magento, DDEV, and local (host) environments. Other skills call this utility once at startup and then apply the returned wrapper when executing container-scoped commands.

How this skill works

Run the provided detection script from the Magento project root (or pass the project path) to identify the environment: warden, docker-magento, ddev, or local. The skill outputs the environment type and a corresponding wrapper pattern that other skills use to prefix or wrap shell commands so they execute in the right container or on the host. Commands that must run on the host (composer, git, host file ops, warden/ddev CLI) are left unwrapped.

When to use it

  • Any skill that needs to run bin/magento or other PHP containerized commands
  • Tasks that run build steps inside the project container (npm/build commands in container)
  • CI or local automation that must adapt to developer environments (Warden, DDEV, docker-magento, local)
  • One-time environment detection at skill startup to cache the wrapper
  • Wrapping remote or container operations while keeping host commands unwrapped

Best practices

  • Detect the environment once at skill initialization and cache the wrapper for reuse
  • Only wrap commands that must run inside the PHP/application container (bin/magento, bash -c ...)
  • Do not wrap host-only commands: composer, git, warden/ddev CLIs, and direct filesystem operations
  • When composing multi-step commands, wrap the entire compound command in a single wrapper invocation
  • Run the detection script from the Magento project root or pass the absolute project path

Example use cases

  • Run bin/magento cache:clean consistently across developer setups by applying the detected wrapper
  • Execute a frontend build inside the container: cd vendor/hyva-themes/.../tailwind && npm run build wrapped appropriately
  • Automated scripts that deploy or test modules and must adapt to Warden, DDEV, docker-magento, or local
  • CI steps that call containerized php or CLI tools while leaving composer and git on the host
  • A skill that runs integration tests inside the container uses the wrapper to run phpunit or setup commands

FAQ

What output does the detection script produce?

It prints one of: warden, docker-magento, ddev, or local so callers know which wrapper to use.

Which commands should never be wrapped?

Host commands like composer, git, host filesystem operations, and the warden/ddev CLI should be run directly on the host and not wrapped.