MCPcopy Create free account
hub / github.com/codeaashu/claude-code / loadSkillsFromCommandsDir

Function loadSkillsFromCommandsDir

src/skills/loadSkillsDir.ts:566–623  ·  view source on GitHub ↗

* Loads skills from legacy /commands/ directories. * Supports both directory format (SKILL.md) and single .md file format. * Commands from /commands/ default to user-invocable: true

(
  cwd: string,
)

Source from the content-addressed store, hash-verified

564 * Commands from /commands/ default to user-invocable: true
565 */
566async function loadSkillsFromCommandsDir(
567 cwd: string,
568): Promise<SkillWithPath[]> {
569 try {
570 const markdownFiles = await loadMarkdownFilesForSubdir('commands', cwd)
571 const processedFiles = transformSkillFiles(markdownFiles)
572
573 const skills: SkillWithPath[] = []
574
575 for (const {
576 baseDir,
577 filePath,
578 frontmatter,
579 content,
580 source,
581 } of processedFiles) {
582 try {
583 const isSkillFormat = isSkillFile(filePath)
584 const skillDirectory = isSkillFormat ? dirname(filePath) : undefined
585 const cmdName = getCommandName({
586 baseDir,
587 filePath,
588 frontmatter,
589 content,
590 source,
591 })
592
593 const parsed = parseSkillFrontmatterFields(
594 frontmatter,
595 content,
596 cmdName,
597 'Custom command',
598 )
599
600 skills.push({
601 skill: createSkillCommand({
602 ...parsed,
603 skillName: cmdName,
604 displayName: undefined,
605 markdownContent: content,
606 source,
607 baseDir: skillDirectory,
608 loadedFrom: 'commands_DEPRECATED',
609 paths: undefined,
610 }),
611 filePath,
612 })
613 } catch (error) {
614 logError(error)
615 }
616 }
617
618 return skills
619 } catch (error) {
620 logError(error)
621 return []
622 }
623}

Callers 1

loadSkillsDir.tsFile · 0.85

Calls 7

transformSkillFilesFunction · 0.85
createSkillCommandFunction · 0.85
isSkillFileFunction · 0.70
getCommandNameFunction · 0.70
logErrorFunction · 0.50
pushMethod · 0.45

Tested by

no test coverage detected