hyva-exec-shell-cmd
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseExecute Shell Commands in Magento Environment
在Magento环境中执行Shell命令
This utility skill detects the Magento development environment and provides the appropriate command wrapper for executing shell commands.
本实用技能可检测Magento开发环境,并为执行Shell命令提供相应的命令包装器。
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).
当其他技能需要在Magento环境中执行命令时,应引用本技能。检测到的包装器可确保命令在正确的上下文(容器或本地)中运行。
Step 1: Detect Environment
步骤1:检测环境
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 is the directory containing this SKILL.md file (e.g., ).
<skill_path>.claude/skills/hyva-exec-shell-cmdThe optional argument specifies the Magento installation directory. If omitted, the script uses the current working directory.
magento_root_pathOutput: , , , or
wardendocker-magentoddevlocal重要提示: 请从Magento项目根目录执行此脚本,或提供路径作为参数。
在任何需要执行Shell命令的技能启动时,运行一次此检测:
bash
<skill_path>/scripts/detect_env.sh [magento_root_path]其中是包含本SKILL.md文件的目录(例如:)。
<skill_path>.claude/skills/hyva-exec-shell-cmd可选的参数用于指定Magento安装目录。如果省略,脚本将使用当前工作目录。
magento_root_path输出:、、或
wardendocker-magentoddevlocalStep 2: Apply Command Wrapper
步骤2:应用命令包装器
Based on detected environment, wrap commands as follows:
| Environment | Command Wrapper | Description |
|---|---|---|
| Warden | | Docker environment managed by Warden |
| docker-magento | | Mark Shust's docker-magento setup |
| DDEV | | DDEV containerized environment |
| Local | Run | Native environment without containers |
根据检测到的环境,按以下方式包装命令:
| 环境 | 命令包装器 | 说明 |
|---|---|---|
| Warden | | 由Warden管理的Docker环境 |
| docker-magento | | Mark Shust的docker-magento环境配置 |
| DDEV | | DDEV容器化环境 |
| Local | 直接运行 | 无容器的原生环境 |
Examples
示例
Single command
单个命令
bash
undefinedbash
undefinedWarden
Warden
warden env exec -T php-fpm bash -c "bin/magento cache:clean"
warden env exec -T php-fpm bash -c "bin/magento cache:clean"
docker-magento
docker-magento
bin/clinotty bash -c "bin/magento cache:clean"
bin/clinotty bash -c "bin/magento cache:clean"
DDEV
DDEV
ddev exec bin/magento cache:clean
ddev exec bin/magento cache:clean
Local
Local
bin/magento cache:clean
undefinedbin/magento cache:clean
undefinedCommand with directory change
包含目录切换的命令
bash
undefinedbash
undefinedWarden
Warden
warden env exec -T php-fpm bash -c "cd vendor/hyva-themes/magento2-default-theme/web/tailwind && npm run build"
warden env exec -T php-fpm bash -c "cd vendor/hyva-themes/magento2-default-theme/web/tailwind && npm run build"
docker-magento
docker-magento
bin/clinotty bash -c "cd vendor/hyva-themes/magento2-default-theme/web/tailwind && npm run build"
bin/clinotty bash -c "cd vendor/hyva-themes/magento2-default-theme/web/tailwind && npm run build"
DDEV
DDEV
ddev exec bash -c "vendor/hyva-themes/magento2-default-theme/web/tailwind && npm run build"
ddev exec bash -c "vendor/hyva-themes/magento2-default-theme/web/tailwind && npm run build"
Local
Local
cd vendor/hyva-themes/magento2-default-theme/web/tailwind && npm run build
undefinedcd vendor/hyva-themes/magento2-default-theme/web/tailwind && npm run build
undefinedCommands That Do NOT Require Wrapping
无需包装的命令
Some commands run on the host system and should NOT be wrapped:
- commands (runs on host, not in container)
composer - commands
git - File operations on the host filesystem (,
ls,findfor files accessible from host)cp - CLI commands
warden - CLI commands
ddev
部分命令在主机系统上运行,不应进行包装:
- 命令(在主机而非容器中运行)
composer - 命令
git - 主机文件系统上的文件操作(如、
ls、find,针对主机可访问的文件)cp - CLI命令
warden - CLI命令
ddev
Integration Pattern
集成模式
Skills that need to execute commands should:
- Reference this skill: "Use the skill to determine the command wrapper"
hyva-exec-shell-cmd - Detect environment once using Step 1
- Store the wrapper pattern for use throughout the skill
- Apply the wrapper to all container commands per Step 2
需要执行命令的技能应遵循以下步骤:
- 引用本技能:“使用技能确定命令包装器”
hyva-exec-shell-cmd - 使用步骤1检测一次环境
- 存储包装器模式,以便在整个技能中使用
- 根据步骤2对所有容器命令应用包装器