Cosmiconfig setup
Skill a5c-ai/babysitter/library/specializations/cli-mcp-development/skills/cosmiconfig-setup
Set up cosmiconfig for hierarchical configuration loading from multiple sources and formats.From its SKILL.md
npx -y skills add a5c-ai/babysitter --skill cosmiconfig-setupAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
SKILL.md
1.8 KB, 307 tokens by cl100k_base, as published. Nobody here has run it
Cosmiconfig Setup
Set up cosmiconfig for hierarchical config loading.
Capabilities
- Configure cosmiconfig search paths
- Set up format loaders (JSON, YAML, TOML)
- Create TypeScript config support
- Implement config caching
- Handle config validation
Generated Patterns
import { cosmiconfig, cosmiconfigSync } from 'cosmiconfig';
import { TypeScriptLoader } from 'cosmiconfig-typescript-loader';
const moduleName = 'myapp';
const explorer = cosmiconfig(moduleName, {
searchPlaces: [
'package.json',
`.${moduleName}rc`,
`.${moduleName}rc.json`,
`.${moduleName}rc.yaml`,
`.${moduleName}rc.yml`,
`.${moduleName}rc.js`,
`.${moduleName}rc.ts`,
`.${moduleName}rc.cjs`,
`${moduleName}.config.js`,
`${moduleName}.config.ts`,
`${moduleName}.config.cjs`,
],
loaders: {
'.ts': TypeScriptLoader(),
},
});
export async function loadConfig(searchFrom?: string) {
const result = await explorer.search(searchFrom);
if (!result || result.isEmpty) {
return { config: getDefaultConfig(), filepath: null };
}
return { config: { ...getDefaultConfig(), ...result.config }, filepath: result.filepath };
}
Target Processes
- configuration-management-system
- cli-application-bootstrap
- mcp-server-bootstrap
What ships with it: 1 file
416 B alongside SKILL.md
- README.md416 B