github-issue-from-templates
npx skills add https://github.com/dfitchett/agent-skills --skill github-issue-from-templates
Agent 安装分布
Skill 文档
GitHub Issue Creation â Data-Driven Workflow Engine
This skill creates GitHub issues by dynamically fetching field definitions from GitHub issue templates at runtime. Template metadata (triggers, labels, defaults, formatting rules) is stored in per-template JSON config files under assets/. The skill itself contains no hardcoded field definitions.
File Structure
~/.claude/skills/github-issue-from-templates/
SKILL.md # This file â generic workflow engine
references/
schema.json # JSON Schema for template config files
assets/
*.json # Template configs (one per issue type)
Workflow
Step 1: Template Selection
- Read all
.jsonfiles from~/.claude/skills/github-issue-from-templates/assets/. - For each config, compare the user’s request against
triggers.keywords(case-insensitive substring match) andtriggers.description. - Single match: Proceed with that template. Confirm the selection with the user briefly (e.g., “I’ll use the [template name] template.”).
- Multiple matches: Present the matching templates by
nameanddescriptionand ask the user to choose. - No match: Present all available templates by
nameanddescriptionand ask the user to choose.
Step 2: Fetch Template from GitHub
Use the GitHub MCP get_file_contents tool to fetch the template file:
owner: <config.repository.owner>
repo: <config.repository.repo>
path: <config.templateSource.path>
Then parse based on config.templateSource.format:
Format: yml (Form-based templates)
Parse the YAML content and extract:
- Title pattern: From the top-level
title:field (e.g.,"[Issue Type] [Short descriptive title]") - Template-level labels: From the top-level
labels:array - Template-level assignees: From the top-level
assignees:array - Fields: From the
body:array. For each entry:- Skip entries where
type: markdownâ these are instructional text, not fields - For all other entries, extract:
idâ unique field identifiertypeâdropdown,input,textareaattributes.labelâ human-readable field nameattributes.descriptionâ help text for the fieldattributes.optionsâ available choices (for dropdowns)attributes.placeholderâ example/guidance textvalidations.requiredâ whether the field must be filled
- Skip entries where
Format: md (Frontmatter + markdown templates)
Parse the frontmatter (between --- delimiters) and extract:
- Title pattern: From
title:(e.g.,'[A11y]: Product - Feature - Request') - Template-level labels: From
labels:(may be a string or array) - Template-level assignees: From
assignees:(may be a string or array)
Parse the markdown body to identify:
- Sections:
##headings define major sections - Checkbox groups: Lines matching
- [ ] Item textgrouped under a heading or bold label - Labeled fields: Bold-labeled list items like
- **Team name:**under a section - Self-verification checklists: Sections like “Yes, I have” contain items the skill should satisfy automatically
Step 3: Gather Information
For each extracted field, apply the following logic in order:
-
Pre-fill from user request: If the user already provided a value for this field in their initial message, pre-fill it and confirm during the preview step.
-
Apply defaults: Check
config.fieldDefaults[fieldId].valueâ if present, use as the default. Also checkconfig.defaultsfor matching keys. -
Check skip conditions: Check
config.fieldSkipConditions[fieldId]â if anonlyWhencondition exists and is not met, skip this field entirely. -
Prompt if needed: If the field is required (
validations.required: true) and no value has been determined, prompt the user. Use the field’slabelas the question anddescription/placeholderas guidance. -
Apply gathering notes: Use
config.fieldDefaults[fieldId].gatheringNotesfor additional guidance on how to present or gather this field.
Gathering style:
- Be conversational â don’t present a wall of questions
- Batch related questions together (e.g., ask for summary and description in one turn)
- For dropdowns, present the options from the template
- For fields with defaults, mention the default and ask if it’s correct
- Skip optional fields that the user hasn’t mentioned unless they’re likely relevant
Step 4: Compose Issue
Title
Build the title by substituting placeholders in the title pattern:
- Use
config.title.overrideif present; otherwise use the pattern extracted from the template in Step 2 - Replace placeholder text with gathered field values using reasoning (e.g.,
[Issue Type]â the value of theissue-typefield,[Short descriptive title]â thesummaryfield value)
Body
Render the issue body following the structure from the fetched template:
- yml templates: Render each field as a
### Field Labelsection with the gathered value. Useno responsefor empty optional sections. Maintain the exact field order from the template. - md templates: Reconstruct the markdown body with gathered values filled in. Check the appropriate checkboxes, fill in labeled fields, and include all sections.
Labels
Build the label set:
- Start with
config.labels.default - Merge in template-level labels (from the fetched template’s
labels:field) â avoid duplicates - Apply
config.labels.conditionalrules:keyword: Check if any keyword appears in the user’s request (case-insensitive)fieldValue: Check if the specified field has the specified valuefieldTransform: Derive a label from a field value using the specified transform (e.g.,lowercase-hyphenateconverts “Document Status” to “document-status”)
- Apply any additional label logic defined in the template config’s
notes
Assignees
Merge config.assignees.default with template-level assignees. If config.assignees.promptUser is true, ask the user if they want to assign anyone else.
Step 5: Preview & Confirm
Present the composed issue to the user for review:
**Title**: [composed title]
**Labels**: label1, label2, label3
**Assignees**: @user1, @user2
**Project**: [project board name] â [status]
**Body**:
[rendered body preview]
Ask for confirmation or edits. If the user requests changes, apply them and re-preview.
Step 6: Create Issue
Use GitHub MCP issue_write with:
method: create
owner: <config.repository.owner>
repo: <config.repository.repo>
title: <composed title>
body: <composed body>
labels: <label array>
assignees: <assignee array>
Step 7: Post-Creation
Display the result using config.postCreation.displayFormat, substituting {issueNumber} and {issueUrl} with actual values.
Display each item from config.postCreation.additionalNotes as a follow-up note.
Link Formatting Rules
When rendering links in the issue body, apply the rules from config.linkFormatting.rules in order. For each link:
- Check each rule’s
matchdescription to determine if it applies - Apply the
formatspecified by the matching rule - Use
customTextas link text if provided
Common patterns:
- GitHub issue/PR URLs as list items â raw URL (no markdown wrapping) so GitHub renders title + status
- Design links â markdown link with
(see design)as text - All other links â standard markdown
[descriptive text](url)
Acceptance Criteria
When config.acceptanceCriteria is defined:
- Start with
config.acceptanceCriteria.defaultItemsas baseline criteria - Ask the user for additional criteria
- Render using
config.acceptanceCriteria.formatting.style(checklist=- [ ] item,bullets=- item) - Avoid the prefixes listed in
config.acceptanceCriteria.formatting.avoidPrefixes
Error Handling
Template fetch failure
If get_file_contents fails:
- Notify the user that the template could not be fetched
- Suggest checking repository access permissions
- Offer to create the issue manually without template structure
JSON config parse failure
If a template config file is malformed:
- Skip that template during selection
- Notify the user which config failed to parse
GitHub MCP failure (issue creation)
If issue_write fails:
- Stop the operation immediately
- Notify the user of the failure
- Provide context about potential causes: authentication token issues, permissions, rate limits, invalid repository access
- Offer to display the composed issue body so the user can create it manually
Adding a New Template
To add support for a new issue type:
- Create a new
.jsonfile in~/.claude/skills/github-issue-from-templates/assets/ - Follow the schema defined in
references/schema.json - Set
repository.ownerandrepository.repoto the target GitHub repository - Set
templateSource.pathto the repo-relative path of the GitHub issue template - Set
templateSource.formattoymlormdbased on the template type - Define
triggers.keywordsfor automatic template matching - Add any
fieldDefaults,fieldSkipConditions, label rules, and formatting overrides - No changes to this SKILL.md file are needed
Section Formatting Conventions
- Use
no responsefor any section where no information was provided â never omit sections - Include all template sections in the exact order they appear in the fetched template
- Use bullet points for lists
- Use proper markdown formatting
- Label names: lowercase with hyphens (e.g.,
document-status,bmt-team-2)