@unity-china/codely-cli 1.0.0-beta.52 → 1.0.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,381 @@
1
+ ---
2
+ name: skill-creator
3
+ description: Guide for creating effective skills. This skill should be used when users want to create a new skill (or update an existing skill) that extends Codely CLI's capabilities with specialized knowledge, workflows, or tool integrations.
4
+ ---
5
+
6
+ # Skill Creator
7
+
8
+ This skill provides guidance for creating effective skills.
9
+
10
+ ## About Skills
11
+
12
+ Skills are modular, self-contained packages that extend Codely CLI's capabilities by providing specialized knowledge, workflows, and tools. Think of them as "onboarding guides" for specific domains or tasks—they transform Codely CLI from a general-purpose agent into a specialized agent equipped with procedural knowledge that no model can fully possess.
13
+
14
+ ### What Skills Provide
15
+
16
+ 1. Specialized workflows - Multi-step procedures for specific domains
17
+ 2. Tool integrations - Instructions for working with specific file formats or APIs
18
+ 3. Domain expertise - Company-specific knowledge, schemas, business logic
19
+ 4. Bundled resources - Scripts, references, and assets for complex and repetitive tasks
20
+
21
+ ## Core Principles
22
+
23
+ ### Concise is Key
24
+
25
+ The context window is a public good. Skills share the context window with everything else Codely CLI needs: system prompt, conversation history, other Skills' metadata, and the actual user request.
26
+
27
+ **Default assumption: Codely CLI is already very smart.** Only add context Codely CLI doesn't already have. Challenge each piece of information: "Does Codely CLI really need this explanation?" and "Does this paragraph justify its token cost?"
28
+
29
+ Prefer concise examples over verbose explanations.
30
+
31
+ ### Set Appropriate Degrees of Freedom
32
+
33
+ Match the level of specificity to the task's fragility and variability:
34
+
35
+ **High freedom (text-based instructions)**: Use when multiple approaches are valid, decisions depend on context, or heuristics guide the approach.
36
+
37
+ **Medium freedom (pseudocode or scripts with parameters)**: Use when a preferred pattern exists, some variation is acceptable, or configuration affects behavior.
38
+
39
+ **Low freedom (specific scripts, few parameters)**: Use when operations are fragile and error-prone, consistency is critical, or a specific sequence must be followed.
40
+
41
+ Think of Codely CLI as exploring a path: a narrow bridge with cliffs needs specific guardrails (low freedom), while an open field allows many routes (high freedom).
42
+
43
+ ### Anatomy of a Skill
44
+
45
+ Every skill consists of a required SKILL.md file and optional bundled resources:
46
+
47
+ ```
48
+ skill-name/
49
+ ├── SKILL.md (required)
50
+ │ ├── YAML frontmatter metadata (required)
51
+ │ │ ├── name: (required)
52
+ │ │ └── description: (required)
53
+ │ └── Markdown instructions (required)
54
+ └── Bundled Resources (optional)
55
+ ├── scripts/ - Executable code (Node.js/Python/Bash/etc.)
56
+ ├── references/ - Documentation intended to be loaded into context as needed
57
+ └── assets/ - Files used in output (templates, icons, fonts, etc.)
58
+ ```
59
+
60
+ #### SKILL.md (required)
61
+
62
+ Every SKILL.md consists of:
63
+
64
+ - **Frontmatter** (YAML): Contains `name` and `description` fields. These are the only fields that Codely CLI reads to determine when the skill gets used, thus it is very important to be clear and comprehensive in describing what the skill is, and when it should be used.
65
+ - **Body** (Markdown): Instructions and guidance for using the skill. Only loaded AFTER the skill triggers (if at all).
66
+
67
+ #### Bundled Resources (optional)
68
+
69
+ ##### Scripts (`scripts/`)
70
+
71
+ Executable code (Node.js/Python/Bash/etc.) for tasks that require deterministic reliability or are repeatedly rewritten.
72
+
73
+ - **When to include**: When the same code is being rewritten repeatedly or deterministic reliability is needed
74
+ - **Example**: `scripts/rotate_pdf.cjs` for PDF rotation tasks
75
+ - **Benefits**: Token efficient, deterministic, may be executed without loading into context
76
+ - **Agentic Ergonomics**: Scripts must output LLM-friendly stdout. Suppress standard tracebacks. Output clear, concise success/failure messages, and paginate or truncate outputs (e.g., "Success: First 50 lines of processed file...") to prevent context window overflow.
77
+ - **Note**: Scripts may still need to be read by Codely CLI for patching or environment-specific adjustments
78
+
79
+ ##### References (`references/`)
80
+
81
+ Documentation and reference material intended to be loaded as needed into context to inform Codely CLI's process and thinking.
82
+
83
+ - **When to include**: For documentation that Codely CLI should reference while working
84
+ - **Examples**: `references/finance.md` for financial schemas, `references/mnda.md` for company NDA template, `references/policies.md` for company policies, `references/api_docs.md` for API specifications
85
+ - **Use cases**: Database schemas, API documentation, domain knowledge, company policies, detailed workflow guides
86
+ - **Benefits**: Keeps SKILL.md lean, loaded only when Codely CLI determines it's needed
87
+ - **Best practice**: If files are large (>10k words), include grep search patterns in SKILL.md
88
+ - **Avoid duplication**: Information should live in either SKILL.md or
89
+ references files, not both. Prefer references files for detailed information unless it's truly core to the skill—this keeps SKILL.md lean while making information discoverable without hogging the context window. Keep only essential procedural instructions and workflow guidance in SKILL.md; move detailed reference material, schemas, and examples to references files.
90
+
91
+ ##### Assets (`assets/`)
92
+
93
+ Files not intended to be loaded into context, but rather used within the output Codely CLI produces.
94
+
95
+ - **When to include**: When the skill needs files that will be used in the final output
96
+ - **Examples**: `assets/logo.png` for brand assets, `assets/slides.pptx` for PowerPoint templates, `assets/frontend-template/` for HTML/React boilerplate, `assets/font.ttf` for typography
97
+ - **Use cases**: Templates, images, icons, boilerplate code, fonts, sample documents that get copied or modified
98
+ - **Benefits**: Separates output resources from documentation, enables Codely CLI to use files without loading them into context
99
+
100
+ #### What to Not Include in a Skill
101
+
102
+ A skill should only contain essential files that directly support its functionality. Do NOT create extraneous documentation or auxiliary files, including:
103
+
104
+ - README.md
105
+ - INSTALLATION_GUIDE.md
106
+ - QUICK_REFERENCE.md
107
+ - CHANGELOG.md
108
+ - etc.
109
+
110
+ The skill should only contain the information needed for an AI agent to do the job at hand. It should not contain auxiliary context about the process that went into creating it, setup and testing procedures, user-facing documentation, etc. Creating additional documentation files just adds clutter and confusion.
111
+
112
+ ### Progressive Disclosure Design Principle
113
+
114
+ Skills use a three-level loading system to manage context efficiently:
115
+
116
+ 1. **Metadata (name + description)** - Always in context (~100 words)
117
+ 2. **SKILL.md body** - When skill triggers (<5k words)
118
+ 3. **Bundled resources** - As needed by Codely CLI (Unlimited because scripts can be executed without reading into context window)
119
+
120
+ #### Progressive Disclosure Patterns
121
+
122
+ Keep SKILL.md body to the essentials and under 500 lines to minimize context bloat. Split content into separate files when approaching this limit. When splitting out content into other files, it is very important to reference them from SKILL.md and describe clearly when to read them, to ensure the reader of the skill knows they exist and when to use them.
123
+
124
+ **Key principle:** When a skill supports multiple variations, frameworks, or options, keep only the core workflow and selection guidance in SKILL.md. Move variant-specific details (patterns, examples, configuration) into separate reference files.
125
+
126
+ **Pattern 1: High-level guide with references**
127
+
128
+ ```markdown
129
+ # PDF Processing
130
+
131
+ ## Quick start
132
+
133
+ Extract text with pdfplumber: [code example]
134
+
135
+ ## Advanced features
136
+
137
+ - **Form filling**: See [FORMS.md](FORMS.md) for complete guide
138
+ - **API reference**: See [REFERENCE.md](REFERENCE.md) for all methods
139
+ - **Examples**: See [EXAMPLES.md](EXAMPLES.md) for common patterns
140
+ ```
141
+
142
+ Codely CLI loads FORMS.md, REFERENCE.md, or EXAMPLES.md only when needed.
143
+
144
+ **Pattern 2: Domain-specific organization**
145
+
146
+ For Skills with multiple domains, organize content by domain to avoid loading irrelevant context:
147
+
148
+ ```
149
+ bigquery-skill/
150
+ ├── SKILL.md (overview and navigation)
151
+ └── reference/
152
+ ├── finance.md (revenue, billing metrics)
153
+ ├── sales.md (opportunities, pipeline)
154
+ ├── product.md (API usage, features)
155
+ └── marketing.md (campaigns, attribution)
156
+ ```
157
+
158
+ When a user asks about sales metrics, Codely CLI only reads sales.md.
159
+
160
+ Similarly, for skills supporting multiple frameworks or variants, organize by variant:
161
+
162
+ ```
163
+ cloud-deploy/
164
+ ├── SKILL.md (workflow + provider selection)
165
+ └── references/
166
+ ├── aws.md (AWS deployment patterns)
167
+ ├── gcp.md (GCP deployment patterns)
168
+ └── azure.md (Azure deployment patterns)
169
+ ```
170
+
171
+ When the user chooses AWS, Codely CLI only reads aws.md.
172
+
173
+ **Pattern 3: Conditional details**
174
+
175
+ Show basic content, link to advanced content:
176
+
177
+ ```markdown
178
+ # CSV Processing
179
+
180
+ ## Basic Analysis
181
+
182
+ Use pandas for loading and basic queries. See [PANDAS.md](PANDAS.md).
183
+
184
+ ## Advanced Operations
185
+
186
+ For massive files that exceed memory, see [STREAMING.md](STREAMING.md). For timestamp normalization, see [TIMESTAMPS.md](TIMESTAMPS.md).
187
+
188
+ Codely CLI reads REDLINING.md or OOXML.md only when the user needs those features.
189
+ ```
190
+
191
+ **Important guidelines:**
192
+
193
+ - **Avoid deeply nested references** - Keep references one level deep from SKILL.md. All reference files should link directly from SKILL.md.
194
+ - **Structure longer reference files** - For files longer than 100 lines, include a table of contents at the top so Codely CLI can see the full scope when previewing.
195
+
196
+ ## Skill Creation Process
197
+
198
+ Skill creation involves these steps:
199
+
200
+ 1. Understand the skill with concrete examples
201
+ 2. Plan reusable skill contents (scripts, references, assets)
202
+ 3. Initialize the skill (run node init_skill.cjs)
203
+ 4. Edit the skill (implement resources and write SKILL.md)
204
+ 5. Package the skill (run node package_skill.cjs)
205
+ 6. Install and reload the skill
206
+ 7. Iterate based on real usage
207
+
208
+ Follow these steps in order, skipping only if there is a clear reason why they are not applicable.
209
+
210
+ ### Skill Naming
211
+
212
+ - Use lowercase letters, digits, and hyphens only; normalize user-provided titles to hyphen-case (e.g., "Plan Mode" -> `plan-mode`).
213
+ - When generating names, generate a name under 64 characters (letters, digits, hyphens).
214
+ - Prefer short, verb-led phrases that describe the action.
215
+ - Namespace by tool when it improves clarity or triggering (e.g., `gh-address-comments`, `linear-address-issue`).
216
+ - Name the skill folder exactly after the skill name.
217
+
218
+ ### Step 1: Understanding the Skill with Concrete Examples
219
+
220
+ Skip this step only when the skill's usage patterns are already clearly understood. It remains valuable even when working with an existing skill.
221
+
222
+ To create an effective skill, clearly understand concrete examples of how the skill will be used. This understanding can come from either direct user examples or generated examples that are validated with user feedback.
223
+
224
+ For example, when building an image-editor skill, relevant questions include:
225
+
226
+ - "What functionality should the image-editor skill support? Editing, rotating, anything else?"
227
+ - "Can you give some examples of how this skill would be used?"
228
+ - "I can imagine users asking for things like 'Remove the red-eye from this image' or 'Rotate this image'. Are there other ways you imagine this skill being used?"
229
+ - "What would a user say that should trigger this skill?"
230
+
231
+ **Avoid interrogation loops:** Do not ask more than one or two clarifying questions at a time. Bias toward action: propose a concrete list of features or examples based on your initial understanding, and ask the user to refine them.
232
+
233
+ Conclude this step when there is a clear sense of the functionality the skill should support.
234
+
235
+ ### Step 2: Planning the Reusable Skill Contents
236
+
237
+ **When to skip:** Safe to skip when the skill is text-only (no scripts/references/assets) or the structure is trivial. Otherwise, briefly list planned resources before implementing.
238
+
239
+ To turn concrete examples into an effective skill, analyze each example by:
240
+
241
+ 1. Considering how to execute on the example from scratch
242
+ 2. Identifying what scripts, references, and assets would be helpful when executing these workflows repeatedly
243
+
244
+ Example: When building a `pdf-editor` skill to handle queries like "Help me rotate this PDF," the analysis shows:
245
+
246
+ 1. Rotating a PDF requires re-writing the same code each time
247
+ 2. A `scripts/rotate_pdf.cjs` script would be helpful to store in the skill
248
+
249
+ Example: When designing a `frontend-webapp-builder` skill for queries like "Build me a todo app" or "Build me a dashboard to track my steps," the analysis shows:
250
+
251
+ 1. Writing a frontend webapp requires the same boilerplate HTML/React each time
252
+ 2. An `assets/hello-world/` template containing the boilerplate HTML/React project files would be helpful to store in the skill
253
+
254
+ Example: When building a `big-query` skill to handle queries like "How many users have logged in today?" the analysis shows:
255
+
256
+ 1. Querying BigQuery requires re-discovering the table schemas and relationships each time
257
+ 2. A `references/schema.md` file documenting the table schemas would be helpful to store in the skill
258
+
259
+ To establish the skill's contents, analyze each concrete example to create a list of the reusable resources to include: scripts, references, and assets.
260
+
261
+ ### Step 3: Initializing the Skill
262
+
263
+ At this point, it is time to actually create the skill.
264
+
265
+ Skip this step only if the skill being developed already exists, and iteration or packaging is needed. In this case, continue to the next step.
266
+
267
+ When creating a new skill from scratch, always run the `init_skill.cjs` script. The script conveniently generates a new template skill directory that automatically includes everything a skill requires, making the skill creation process much more efficient and reliable.
268
+
269
+ **Note:** Use the absolute path to the script as provided in the `available_resources` section.
270
+
271
+ Usage:
272
+
273
+ ```bash
274
+ node <path-to-skill-creator>/scripts/init_skill.cjs <skill-name> --path <output-directory>
275
+ ```
276
+
277
+ The script:
278
+
279
+ - Creates the skill directory at the specified path
280
+ - Generates a SKILL.md template with proper frontmatter and TODO placeholders
281
+ - Creates example resource directories: `scripts/`, `references/`, and `assets/`
282
+ - Adds **example files** (`scripts/example_script.cjs`, `references/example_reference.md`, `assets/example_asset.txt`) to demonstrate structure
283
+
284
+ **Important:** All files generated by `init_skill.cjs` are examples. Keep only what your skill needs; delete the rest. Do not treat them as required—most skills will use only a subset or replace them entirely with skill-specific content.
285
+
286
+ ### Step 4: Edit the Skill
287
+
288
+ When editing the (newly-generated or existing) skill, remember that the skill is being created for another instance of Codely CLI to use. Include information that would be beneficial and non-obvious to Codely CLI. Consider what procedural knowledge, domain-specific details, or reusable assets would help another Codely CLI instance execute these tasks more effectively.
289
+
290
+ #### Learn Proven Design Patterns
291
+
292
+ Consult these helpful guides based on your skill's needs:
293
+
294
+ - **Multi-step processes**: See references/workflows.md for sequential workflows and conditional logic
295
+ - **Specific output formats or quality standards**: See references/output-patterns.md for template and example patterns
296
+
297
+ These files contain established best practices for effective skill design.
298
+
299
+ #### Start with Reusable Skill Contents
300
+
301
+ To begin implementation, start with the reusable resources identified above: `scripts/`, `references/`, and `assets/` files. Note that this step may require user input. For example, when implementing a `brand-guidelines` skill, the user may need to provide brand assets or templates to store in `assets/`, or documentation to store in `references/`.
302
+
303
+ Added scripts must be tested by actually running them to ensure there are no bugs and that the output matches what is expected. If there are many similar scripts, only a representative sample needs to be tested to ensure confidence that they all work while balancing time to completion.
304
+
305
+ Delete any example files and directories not needed for the skill. As noted in Step 3, `init_skill.cjs` generates example files only—keep what fits your skill, delete the rest.
306
+
307
+ #### Update SKILL.md
308
+
309
+ **Writing Guidelines:** Always use imperative/infinitive form.
310
+
311
+ ##### Frontmatter
312
+
313
+ Write the YAML frontmatter with `name` and `description`:
314
+
315
+ - `name`: The skill name
316
+ - `description`: This is the primary triggering mechanism for your skill, and helps Codely CLI understand when to use the skill.
317
+ - Include both what the Skill does and specific triggers/contexts for when to use it.
318
+ - **Must be a single-line string** (e.g., `description: Data ingestion...`). Quotes are optional.
319
+ - Include all "when to use" information here - Not in the body. The body is only loaded after triggering, so "When to Use This Skill" sections in the body are not helpful to Codely CLI.
320
+ - Example: `description: Data ingestion, cleaning, and transformation for tabular data. Use when Codely CLI needs to work with CSV/TSV files to analyze large datasets, normalize schemas, or merge sources.`
321
+
322
+ Do not include any other fields in YAML frontmatter.
323
+
324
+ ##### Body
325
+
326
+ Write instructions for using the skill and its bundled resources.
327
+
328
+ ### Step 5: Packaging a Skill
329
+
330
+ Once development of the skill is complete, it must be packaged into a distributable .skill file that gets shared with the user. The packaging process automatically validates the skill first (checking YAML and ensuring no TODOs remain) to ensure it meets all requirements:
331
+
332
+ **Note:** Use the absolute path to the script as provided in the `available_resources` section.
333
+
334
+ By default, the `.skill` file is written to `<tmp>/codely-skills`. Specify an output directory to override:
335
+
336
+ ```bash
337
+ node <path-to-skill-creator>/scripts/package_skill.cjs <path/to/skill-folder>
338
+ node <path-to-skill-creator>/scripts/package_skill.cjs <path/to/skill-folder> ./dist
339
+ ```
340
+
341
+ The packaging script will:
342
+
343
+ 1. **Validate** the skill automatically, checking:
344
+ - YAML frontmatter format and required fields
345
+ - Skill naming conventions and directory structure
346
+ - Description completeness and quality
347
+ - File organization and resource references
348
+
349
+ 2. **Package** the skill if validation passes, creating a .skill file named after the skill (e.g., `my-skill.skill`) that includes all files and maintains the proper directory structure for distribution. The .skill file is a zip file with a .skill extension.
350
+
351
+ If validation fails, the script will report the errors and exit without creating a package. Fix any validation errors and run the packaging command again.
352
+
353
+ ### Step 6: Installing and Reloading a Skill
354
+
355
+ Once the skill is packaged into a `.skill` file, offer to install it for the user. Ask whether they would like to install it locally in the current folder (workspace scope) or at the user level (user scope).
356
+
357
+ If the user agrees to an installation, perform it immediately using the `run_shell_command` tool:
358
+
359
+ - **Interactive (user confirms in terminal)**:
360
+ ```bash
361
+ codely skills install <path/to/skill-name.skill> --scope workspace
362
+ codely skills install <path/to/skill-name.skill> --scope user
363
+ ```
364
+ - **Non-interactive (scripted installs)**: Add `--consent` to skip the confirmation prompt:
365
+ ```bash
366
+ codely skills install <path/to/skill-name.skill> --scope workspace --consent
367
+ codely skills install <path/to/skill-name.skill> --scope user --consent
368
+ ```
369
+
370
+ **Important:** After the installation is complete, notify the user that they MUST manually execute the `/skills reload` command in their interactive Codely CLI session to enable the new skill. You (the agent) cannot run `/skills reload` on their behalf. They can then verify the installation by running `/skills list`.
371
+
372
+ ### Step 7: Iterate
373
+
374
+ After testing the skill, users may request improvements. Often this happens right after using the skill, with fresh context of how the skill performed.
375
+
376
+ **Iteration workflow:**
377
+
378
+ 1. Use the skill on real tasks
379
+ 2. Notice struggles or inefficiencies
380
+ 3. Identify how SKILL.md or bundled resources should be updated
381
+ 4. Implement changes and test again
@@ -0,0 +1,237 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ /**
8
+ * Skill Initializer - Creates a new skill from template
9
+ *
10
+ * Usage:
11
+ * node init_skill.cjs <skill-name> --path <path>
12
+ *
13
+ * Examples:
14
+ * node init_skill.cjs my-new-skill --path skills/public
15
+ */
16
+
17
+ const fs = require('node:fs');
18
+ const path = require('node:path');
19
+
20
+ const SKILL_TEMPLATE = `---
21
+ name: {skill_name}
22
+ description: TODO: Complete and informative explanation of what the skill does and when to use it. Include WHEN to use this skill - specific scenarios, file types, or tasks that trigger it.
23
+ ---
24
+
25
+ # {skill_title}
26
+
27
+ ## Overview
28
+
29
+ [TODO: 1-2 sentences explaining what this skill enables]
30
+
31
+ ## Structuring This Skill
32
+
33
+ [TODO: Choose the structure that best fits this skill's purpose. Common patterns:
34
+
35
+ **1. Workflow-Based** (best for sequential processes)
36
+ - Works well when there are clear step-by-step procedures
37
+ - Example: CSV-Processor skill with "Workflow Decision Tree" → "Ingestion" → "Cleaning" → "Analysis"
38
+ - Structure: ## Overview → ## Workflow Decision Tree → ## Step 1 → ## Step 2...
39
+
40
+ **2. Task-Based** (best for tool collections)
41
+ - Works well when the skill offers different operations/capabilities
42
+ - Example: PDF skill with "Quick Start" → "Merge PDFs" → "Split PDFs" → "Extract Text"
43
+ - Structure: ## Overview → ## Quick Start → ## Task Category 1 → ## Task Category 2...
44
+
45
+ **3. Reference/Guidelines** (best for standards or specifications)
46
+ - Works well for brand guidelines, coding standards, or requirements
47
+ - Example: Brand styling with "Brand Guidelines" → "Colors" → "Typography" → "Features"
48
+ - Structure: ## Overview → ## Guidelines → ## Specifications → ## Usage...
49
+
50
+ **4. Capabilities-Based** (best for integrated systems)
51
+ - Works well when the skill provides multiple interrelated features
52
+ - Example: Product Management with "Core Capabilities" → numbered capability list
53
+ - Structure: ## Overview → ## Core Capabilities → ### 1. Feature → ### 2. Feature...
54
+
55
+ Patterns can be mixed and matched as needed. Most skills combine patterns (e.g., start with task-based, add workflow for complex operations).
56
+
57
+ Delete this entire "Structuring This Skill" section when done - it's just guidance.]
58
+
59
+ ## [TODO: Replace with the first main section based on chosen structure]
60
+
61
+ [TODO: Add content here. See examples in existing skills:
62
+ - Code samples for technical skills
63
+ - Decision trees for complex workflows
64
+ - Concrete examples with realistic user requests
65
+ - References to scripts/templates/references as needed]
66
+
67
+ ## Resources
68
+
69
+ This skill includes example resource directories that demonstrate how to organize different types of bundled resources:
70
+
71
+ ### scripts/
72
+ Executable code that can be run directly to perform specific operations.
73
+
74
+ **Examples from other skills:**
75
+ - PDF skill: fill_fillable_fields.cjs, extract_form_field_info.cjs - utilities for PDF manipulation
76
+ - CSV skill: normalize_schema.cjs, merge_datasets.cjs - utilities for tabular data manipulation
77
+
78
+ **Appropriate for:** Node.cjs scripts (cjs), shell scripts, or any executable code that performs automation, data processing, or specific operations.
79
+
80
+ **Note:** Scripts may be executed without loading into context, but can still be read by Gemini CLI for patching or environment adjustments.
81
+
82
+ ### references/
83
+ Documentation and reference material intended to be loaded into context to inform Gemini CLI's process and thinking.
84
+
85
+ **Examples from other skills:**
86
+ - Product management: communication.md, context_building.md - detailed workflow guides
87
+ - BigQuery: API reference documentation and query examples
88
+ - Finance: Schema documentation, company policies
89
+
90
+ **Appropriate for:** In-depth documentation, API references, database schemas, comprehensive guides, or any detailed information that Gemini CLI should reference while working.
91
+
92
+ ### assets/
93
+ Files not intended to be loaded into context, but rather used within the output Gemini CLI produces.
94
+
95
+ **Examples from other skills:**
96
+ - Brand styling: PowerPoint template files (.pptx), logo files
97
+ - Frontend builder: HTML/React boilerplate project directories
98
+ - Typography: Font files (.ttf, .woff2)
99
+
100
+ **Appropriate for:** Templates, boilerplate code, document templates, images, icons, fonts, or any files meant to be copied or used in the final output.
101
+
102
+ ---
103
+
104
+ **Any unneeded directories can be deleted.** Not every skill requires all three types of resources.
105
+ `;
106
+
107
+ const EXAMPLE_SCRIPT = `#!/usr/bin/env node
108
+
109
+ /**
110
+ * Example helper script for {skill_name}
111
+ *
112
+ * This is a placeholder script that can be executed directly.
113
+ * Replace with actual implementation or delete if not needed.
114
+ *
115
+ * Example real scripts from other skills:
116
+ * - pdf/scripts/fill_fillable_fields.cjs - Fills PDF form fields
117
+ * - pdf/scripts/convert_pdf_to_images.cjs - Converts PDF pages to images
118
+ *
119
+ * Agentic Ergonomics:
120
+ * - Suppress tracebacks.
121
+ * - Return clean success/failure strings.
122
+ * - Truncate long outputs.
123
+ */
124
+
125
+ async function main() {
126
+ try {
127
+ // TODO: Add actual script logic here.
128
+ // This could be data processing, file conversion, API calls, etc.
129
+
130
+ // Example output formatting for an LLM agent
131
+ process.stdout.write("Success: Processed the task.\\n");
132
+ } catch (err) {
133
+ // Trap the error and output a clean message instead of a noisy stack trace
134
+ process.stderr.write(\`Failure: \${err.message}\\n\`);
135
+ process.exit(1);
136
+ }
137
+ }
138
+
139
+ main();
140
+ `;
141
+
142
+ const EXAMPLE_REFERENCE = `# Reference Documentation for {skill_title}
143
+
144
+ This is a placeholder for detailed reference documentation.
145
+ Replace with actual reference content or delete if not needed.
146
+
147
+ ## Structure Suggestions
148
+
149
+ ### API Reference Example
150
+ - Overview
151
+ - Authentication
152
+ - Endpoints with examples
153
+ - Error codes
154
+
155
+ ### Workflow Guide Example
156
+ - Prerequisites
157
+ - Step-by-step instructions
158
+ - Best practices
159
+ `;
160
+
161
+ function titleCase(name) {
162
+ return name
163
+ .split('-')
164
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
165
+ .join(' ');
166
+ }
167
+
168
+ async function main() {
169
+ const args = process.argv.slice(2);
170
+ if (args.length < 3 || args[1] !== '--path') {
171
+ console.log('Usage: node init_skill.cjs <skill-name> --path <path>');
172
+ process.exit(1);
173
+ }
174
+
175
+ const skillName = args[0];
176
+ const basePath = path.resolve(args[2]);
177
+
178
+ // Prevent path traversal
179
+ if (
180
+ skillName.includes(path.sep) ||
181
+ skillName.includes('/') ||
182
+ skillName.includes('\\')
183
+ ) {
184
+ console.error('❌ Error: Skill name cannot contain path separators.');
185
+ process.exit(1);
186
+ }
187
+
188
+ const skillDir = path.join(basePath, skillName);
189
+
190
+ // Additional check to ensure the resolved skillDir is actually inside basePath
191
+ if (!skillDir.startsWith(basePath)) {
192
+ console.error('❌ Error: Invalid skill name or path.');
193
+ process.exit(1);
194
+ }
195
+
196
+ if (fs.existsSync(skillDir)) {
197
+ console.error(`❌ Error: Skill directory already exists: ${skillDir}`);
198
+ process.exit(1);
199
+ }
200
+
201
+ const skillTitle = titleCase(skillName);
202
+
203
+ try {
204
+ fs.mkdirSync(skillDir, { recursive: true });
205
+ fs.mkdirSync(path.join(skillDir, 'scripts'));
206
+ fs.mkdirSync(path.join(skillDir, 'references'));
207
+ fs.mkdirSync(path.join(skillDir, 'assets'));
208
+
209
+ fs.writeFileSync(
210
+ path.join(skillDir, 'SKILL.md'),
211
+ SKILL_TEMPLATE.replace(/{skill_name}/g, skillName).replace(
212
+ /{skill_title}/g,
213
+ skillTitle,
214
+ ),
215
+ );
216
+ fs.writeFileSync(
217
+ path.join(skillDir, 'scripts/example_script.cjs'),
218
+ EXAMPLE_SCRIPT.replace(/{skill_name}/g, skillName),
219
+ { mode: 0o755 },
220
+ );
221
+ fs.writeFileSync(
222
+ path.join(skillDir, 'references/example_reference.md'),
223
+ EXAMPLE_REFERENCE.replace(/{skill_title}/g, skillTitle),
224
+ );
225
+ fs.writeFileSync(
226
+ path.join(skillDir, 'assets/example_asset.txt'),
227
+ 'Placeholder for assets.',
228
+ );
229
+
230
+ console.log(`✅ Skill '${skillName}' initialized at ${skillDir}`);
231
+ } catch (err) {
232
+ console.error(`❌ Error: ${err.message}`);
233
+ process.exit(1);
234
+ }
235
+ }
236
+
237
+ main();