| 89 | } |
| 90 | |
| 91 | func runSkillInit(root string) { |
| 92 | skillsDir := root + "/.codemap/skills" |
| 93 | if err := os.MkdirAll(skillsDir, 0755); err != nil { |
| 94 | fmt.Fprintf(os.Stderr, "Error creating skills directory: %v\n", err) |
| 95 | os.Exit(1) |
| 96 | } |
| 97 | |
| 98 | template := `--- |
| 99 | name: my-skill |
| 100 | description: Describe when this skill should activate and what it does |
| 101 | priority: 5 |
| 102 | keywords: ["keyword1", "keyword2"] |
| 103 | languages: ["go"] |
| 104 | --- |
| 105 | |
| 106 | # My Skill |
| 107 | |
| 108 | Instructions for the AI agent when this skill is activated. |
| 109 | |
| 110 | ## When to use |
| 111 | |
| 112 | Describe the situations where this skill applies. |
| 113 | |
| 114 | ## Steps |
| 115 | |
| 116 | 1. First step |
| 117 | 2. Second step |
| 118 | 3. Third step |
| 119 | ` |
| 120 | |
| 121 | path := skillsDir + "/my-skill.md" |
| 122 | if _, err := os.Stat(path); err == nil { |
| 123 | fmt.Printf("Skill template already exists at %s\n", path) |
| 124 | return |
| 125 | } |
| 126 | |
| 127 | if err := os.WriteFile(path, []byte(template), 0644); err != nil { |
| 128 | fmt.Fprintf(os.Stderr, "Error writing template: %v\n", err) |
| 129 | os.Exit(1) |
| 130 | } |
| 131 | |
| 132 | fmt.Printf("Created skill template at %s\n", path) |
| 133 | fmt.Println("Edit the file to define your custom skill.") |
| 134 | fmt.Println("Run 'codemap skill list' to verify it loads.") |
| 135 | } |