用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/fabioc-aloha/Alex_Skill_Mall --skill build-script-path-rot命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
| name | build-script-path-rot |
| description | Hardcoded paths in build scripts break when directory structure changes: |
| lastReviewed | 2026-04-30T00:00:00.000Z |
Hardcoded paths in build scripts break when directory structure changes:
// Bad: hardcoded path
const srcDir = './src/components';
const outDir = './dist/components';
// After restructure: src/components → packages/ui/src
// Script breaks silently or with confusing errors
const path = require('path');
const pkg = require('./package.json');
// Paths defined in package.json
const srcDir = path.resolve(__dirname, pkg.directories?.src || 'src');
const outDir = path.resolve(__dirname, pkg.directories?.dist || 'dist');
// package.json
{
"directories": {
"src": "packages/ui/src",
"dist": "dist"
}
}
// build.config.js
module.exports = {
srcDir: './packages/ui/src',
outDir: './dist',
assets: './assets'
};
// build.cjs
const config = require('./build.config.js');
const srcDir = path.resolve(__dirname, config.srcDir);
// Find src directory by looking for markers
function findSrcDir() {
const candidates = ['src', 'packages/ui/src', 'lib'];
for (const dir of candidates) {
if (fs.existsSync(path.join(dir, 'index.ts'))) {
return dir;
}
}
throw new Error('Could not find source directory');
}
| Pattern | Risk |
|---|---|
'./src/' hardcoded | Will break on restructure |
process.cwd() + '/src' | Breaks if script run from different dir |
Relative paths without path.resolve | Platform-specific issues |
// Always resolve from script location
const scriptDir = __dirname;
const projectRoot = path.resolve(scriptDir, '..');
const srcDir = path.resolve(projectRoot, 'src');
// Or from package.json location
const pkgPath = require.resolve('./package.json');
const projectRoot = path.dirname(pkgPath);
build paths configuration portability
基于 SOC 职业分类