[FEATURE] Claude Code requires some built-in environment variables to facilitate the development of custom plugins.
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
I defined a custom claude code skill. claude code can easily perform tasks according to the workflow I specified and run the scripts in the scripts directory correctly. However, when I integrate it into the plugin, errors occur!
When claude code runs the script steps in the skill, it looks for the script from the current working path instead of from the skill directory:
Specifically, when using the slash command /git-commit-squash:commit-squash, claude code cannot obtain the corresponding skill directory, resulting in the inability to execute some scripts correctly. It is necessary to explicitly use the absolute path to work properly. But I can work properly when using skill (skill remains at ~/.claude/skills).
directory tree:
git-commit-skills/
├── .claude-plugin/
│ └── plugin.json
├── commands/
│ └── commit-squash.md
└── skills/
└── commit-squash/
├── SKILL.md
├── commit_message_rules.md
└── scripts/
└── analyze_repo.py
Proposed Solution
If there are some fixed environment variables that are automatically loaded when the slash command is executed, such as $PLUGIN_DIR (pointing to the git-commit-squash directory) and $SKILL_DIR (pointing to the commit-squash skill directory), then I can conveniently define the workflow in the slash command. Improve the portability of the plugin.
Alternative Solutions
At present, the problem is solved by prompting claude code to find the corresponding skill directory and then mapping it to the corresponding file.
# ~/.claude/plugins/marketplaces/gudsen-plugin/git-commit-skills/commands/commit-squash.md
---
description: Squash multiple commits from the target branch into a single commit
---
**Locate Skill Directory**:
Search for files with the path `*/skills/commit-squash/SKILL.md` (under ~/.claude/plugins).
Once found, remember the absolute path of the directory where this file is located. All subsequent files will be based on this directory.
`find ~/.claude -name "SKILL.md" -path "*/skills/commit-squash/*" 2>/dev/null || echo "SKILL.md file not found"`
Example: If `/home/user/.claude/plugins/git-commit-squash/skills/commit-squash/SKILL.md` is found,
Then the skill directory is: `/home/user/.claude/plugins/git-commit-squash/skills/commit-squash`
**Execute Skill**:
Using the found skill directory path:
1. Read `SKILL.md` in that directory to understand the workflow
2. Refer to `commit_message_rules.md` in that directory to understand commit specifications
3. Strictly follow the workflow. When running scripts, use `scripts/analyze_repo.py` from that directory
**Important**: When executing Python scripts, use the full path in the format:
`python "<absolute_path_to_skill_directory>/scripts/analyze_repo.py" <branch_name>`
Now start: Search and locate the SKILL.md file.
Priority
High - Significant impact on productivity
Feature Category
CLI commands and flags
Use Case Example
- I implemented a custom claude code skill
- Based on the convenience of the plugin, I ported this skill to the plugin to make it easier for other colleagues to use this skill together and to facilitate the management and maintenance of the skill.
- With "built-in environment variables", the portability of skills will be higher.
Additional Context
No response