Initial commit

This commit is contained in:
Zhongwei Li
2025-11-29 18:48:05 +08:00
commit 694b4f5c2c
12 changed files with 3661 additions and 0 deletions

464
commands/sng-issue.md Normal file
View File

@@ -0,0 +1,464 @@
# GitHub Issue Management Command
You are helping the user create, update, and manage GitHub issues following Sngular's project management best practices.
## Instructions
1. **Determine the action**:
- Create a new issue
- Update an existing issue
- Close an issue
- List issues with filters
- Link related issues
- Bulk operations on issues
2. **Verify GitHub repository**:
- Check if in a git repository
- Verify GitHub remote is configured
- Confirm user has `gh` CLI installed and authenticated
3. **Gather issue details**:
- Title (clear, concise, action-oriented)
- Description (problem statement, context, impact)
- Labels (type, priority, component, status)
- Assignees (who should work on this)
- Milestone (which release or sprint)
- Projects (which project board)
## Issue Creation
### Issue Template Structure
```markdown
## Problem Statement
Clear description of the issue, bug, or feature request.
## Current Behavior
What is happening now? (for bugs)
## Expected Behavior
What should happen instead?
## Steps to Reproduce
(For bugs)
1. Step 1
2. Step 2
3. Step 3
## Proposed Solution
(For features)
High-level approach to implementing this feature.
## Acceptance Criteria
- [ ] Criterion 1
- [ ] Criterion 2
- [ ] Criterion 3
## Technical Details
- Affected components:
- Dependencies:
- Estimated effort:
## Additional Context
Screenshots, logs, or relevant information.
## Related Issues
- Relates to #123
- Blocks #456
- Blocked by #789
```
### Issue Types & Labels
**Type Labels**:
- `bug` - Something isn't working
- `feature` - New feature or enhancement
- `documentation` - Documentation improvements
- `refactor` - Code refactoring
- `performance` - Performance improvements
- `security` - Security-related issues
- `tech-debt` - Technical debt
**Priority Labels**:
- `priority: critical` - Urgent, blocking work
- `priority: high` - Important, should be done soon
- `priority: medium` - Normal priority
- `priority: low` - Nice to have
**Status Labels**:
- `status: triage` - Needs initial review
- `status: ready` - Ready for development
- `status: in-progress` - Currently being worked on
- `status: review` - In code review
- `status: blocked` - Blocked by dependencies
- `status: on-hold` - Paused temporarily
**Component Labels**:
- `frontend` - UI/UX related
- `backend` - Server-side code
- `database` - Database changes
- `devops` - Infrastructure/deployment
- `api` - API changes
## GitHub CLI Commands
### Creating Issues
```bash
# Create basic issue
gh issue create --title "Issue title" --body "Issue description"
# Create issue with labels and assignee
gh issue create \
--title "Add user authentication" \
--body "$(cat issue-template.md)" \
--label "feature,backend,priority: high" \
--assignee username
# Create issue with milestone
gh issue create \
--title "Fix login bug" \
--body "Description" \
--label "bug,priority: critical" \
--milestone "Sprint 24"
# Create issue and assign to project
gh issue create \
--title "Implement dashboard" \
--body "Description" \
--label "feature" \
--project "Q4 Roadmap"
# Interactive issue creation
gh issue create
```
### Viewing Issues
```bash
# List all open issues
gh issue list
# List issues with specific label
gh issue list --label "bug"
# List issues assigned to user
gh issue list --assignee @me
# List issues in specific state
gh issue list --state closed
# List with custom columns
gh issue list --json number,title,labels,state
# View specific issue
gh issue view 123
# View issue in browser
gh issue view 123 --web
```
### Updating Issues
```bash
# Edit issue title
gh issue edit 123 --title "New title"
# Add labels
gh issue edit 123 --add-label "bug,priority: high"
# Remove labels
gh issue edit 123 --remove-label "priority: low"
# Add assignee
gh issue edit 123 --add-assignee username
# Remove assignee
gh issue edit 123 --remove-assignee username
# Set milestone
gh issue edit 123 --milestone "v2.0"
# Update body
gh issue edit 123 --body "New description"
# Add comment
gh issue comment 123 --body "This is a comment"
# Close issue
gh issue close 123
# Close with comment
gh issue close 123 --comment "Fixed in PR #456"
# Reopen issue
gh issue reopen 123
```
### Linking Issues
```bash
# Reference in comment
gh issue comment 123 --body "Related to #456"
# Link as blocking
gh issue comment 123 --body "Blocks #456"
# Link as blocked by
gh issue comment 123 --body "Blocked by #789"
# Link to PR
gh issue comment 123 --body "Fixed in PR #100"
```
### Bulk Operations
```bash
# Close multiple issues
gh issue list --label "wontfix" --json number --jq '.[].number' | \
xargs -I {} gh issue close {}
# Add label to multiple issues
gh issue list --search "authentication" --json number --jq '.[].number' | \
xargs -I {} gh issue edit {} --add-label "security"
# Assign all unassigned bugs
gh issue list --label "bug" --json number,assignees --jq '.[] | select(.assignees | length == 0) | .number' | \
xargs -I {} gh issue edit {} --add-assignee username
```
## Issue Templates
### Bug Report Template
```markdown
## Bug Description
Brief description of the bug.
## Environment
- OS: [e.g., macOS 14.0]
- Browser: [e.g., Chrome 120]
- Version: [e.g., 2.0.1]
## Steps to Reproduce
1. Go to '...'
2. Click on '...'
3. Scroll down to '...'
4. See error
## Expected Behavior
What you expected to happen.
## Actual Behavior
What actually happened.
## Screenshots/Logs
If applicable, add screenshots or logs.
## Possible Solution
(Optional) Suggest a fix or reason for the bug.
## Additional Context
Any other context about the problem.
```
### Feature Request Template
```markdown
## Feature Description
Clear description of the feature you'd like to see.
## Problem Statement
What problem does this feature solve?
## Proposed Solution
How should this feature work?
## Alternatives Considered
What other approaches did you consider?
## User Stories
- As a [user type], I want to [action], so that [benefit]
## Acceptance Criteria
- [ ] Criterion 1
- [ ] Criterion 2
## Technical Considerations
- Dependencies:
- Performance impact:
- Security implications:
- Breaking changes:
## Priority & Impact
- Priority: [High/Medium/Low]
- User impact: [High/Medium/Low]
- Implementation effort: [Large/Medium/Small]
```
## Best Practices
### Writing Good Issue Titles
**Good**:
- "Add CSV export for user data"
- "Fix pagination bug on dashboard"
- "Improve API response time for /users endpoint"
- "Update authentication flow to support OAuth"
**Bad**:
- "Bug" (not descriptive)
- "Feature request" (too vague)
- "This doesn't work" (no context)
- "URGENT FIX ASAP!!!" (not professional)
### Title Format
- **Bugs**: "Fix [issue] in [component]"
- **Features**: "Add [feature] to [component]"
- **Improvements**: "Improve [aspect] of [component]"
- **Refactoring**: "Refactor [component] to [goal]"
### Writing Good Descriptions
1. **Be specific**: Include exact error messages, versions, conditions
2. **Provide context**: Explain why this matters, who it affects
3. **Include steps**: For bugs, clear reproduction steps
4. **Add visuals**: Screenshots, diagrams, recordings when helpful
5. **Link related work**: Reference related issues, PRs, docs
6. **Set expectations**: Clarify scope, acceptance criteria
### Label Strategy
- Use consistent label taxonomy across the project
- Limit to 3-5 labels per issue for clarity
- Always include: type, priority, and component labels
- Use status labels to track progress
- Create custom labels for recurring themes
### Assigning Issues
- Assign when someone actively works on it
- Don't assign too far in advance
- One primary assignee, others as collaborators
- Unassign if work is paused or blocked
## Workflow Examples
### Example 1: Create Bug Report
```bash
# User reports: "Login page is broken on mobile"
gh issue create \
--title "Fix login page layout on mobile devices" \
--body "$(cat <<'EOF'
## Bug Description
The login form is not responsive on mobile devices below 768px width.
## Environment
- Device: iPhone 14
- OS: iOS 17.0
- Browser: Safari
## Steps to Reproduce
1. Open application on mobile device
2. Navigate to /login
3. Observe layout issues
## Expected Behavior
Login form should be centered and fully visible on mobile.
## Actual Behavior
Form elements overflow screen, submit button is cut off.
## Screenshots
[Attach screenshots]
## Acceptance Criteria
- [ ] Form is responsive on screens < 768px
- [ ] All elements visible without scrolling
- [ ] Touch targets are at least 44x44px
- [ ] Tested on iOS Safari and Android Chrome
EOF
)" \
--label "bug,frontend,priority: high" \
--assignee frontend-team
```
### Example 2: Feature Request with Requirements
```bash
gh issue create \
--title "Add user profile settings page" \
--body "$(cat ./docs/requirements/user-profile.md)" \
--label "feature,frontend,backend" \
--milestone "v2.0" \
--project "Q4 Features"
```
### Example 3: Link Related Issues
```bash
# This PR fixes issue #123 and is related to #124
gh issue comment 123 --body "Fixed in PR #200"
gh issue close 123
gh issue comment 124 --body "Implementation approach discussed in #123"
```
### Example 4: Triage Issues
```bash
# Review new issues
gh issue list --label "status: triage"
# Add priority and status
gh issue edit 123 --add-label "priority: high,status: ready" --remove-label "status: triage"
# Assign to team member
gh issue edit 123 --add-assignee developer1
```
## Integration with Project Boards
```bash
# List projects
gh project list
# View project
gh project view 1
# Add issue to project
gh project item-add 1 --url https://github.com/owner/repo/issues/123
# Move issue on board
gh project item-edit --project-id 1 --id ITEM_ID --field-id STATUS_FIELD_ID --value "In Progress"
```
## Advanced Filtering
```bash
# Issues created in last week
gh issue list --search "created:>=$(date -v-7d +%Y-%m-%d)"
# High priority unassigned bugs
gh issue list --label "bug,priority: high" --search "no:assignee"
# Issues mentioning "authentication"
gh issue list --search "authentication in:title,body"
# Issues assigned to me that are in progress
gh issue list --assignee @me --label "status: in-progress"
```
## Questions to Ask
Before creating or updating an issue:
1. "What type of issue is this? (bug, feature, improvement)"
2. "What is the clear, actionable title?"
3. "Do you have specific details like steps to reproduce or requirements?"
4. "What priority should this have?"
5. "Should this be assigned to anyone?"
6. "Should this be added to a milestone or project?"
7. "Are there related issues we should link to?"
Ask the user: "What would you like to do with GitHub issues?"

495
commands/sng-kanban.md Normal file
View File

@@ -0,0 +1,495 @@
# GitHub Project Board (Kanban) Management Command
You are helping the user create, manage, and organize GitHub Project boards (Kanbans) following Sngular's agile project management best practices.
## Instructions
1. **Determine the action**:
- Create a new project board
- View existing project boards
- Add issues/PRs to a board
- Move items between columns
- Update project fields (status, priority, etc.)
- Generate project reports
- Archive or close projects
2. **Verify GitHub access**:
- Check if in a GitHub repository
- Verify `gh` CLI is installed and authenticated
- Confirm user has appropriate permissions
- Check for GitHub Projects (V2) availability
3. **Understand project structure**:
- Board name and purpose
- Workflow stages (columns/status)
- Custom fields (priority, size, sprint, etc.)
- Automation rules
- Views and filters
## GitHub Projects Overview
### Project Types
**Repository Project**: Attached to a single repository
- Good for: Single product development
- Access: Repository collaborators
**Organization Project**: Spans multiple repositories
- Good for: Cross-team initiatives, programs
- Access: Organization members
**User Project**: Personal project boards
- Good for: Individual task tracking
### Board Layouts
**Board View**: Classic kanban columns (Todo, In Progress, Done)
**Table View**: Spreadsheet-like view with custom fields
**Roadmap View**: Timeline view for planning
## GitHub CLI Commands
### Viewing Projects
```bash
# List all projects in organization
gh project list --owner ORGANIZATION
# List projects for current repository
gh project list
# View specific project
gh project view PROJECT_NUMBER
# View project in browser
gh project view PROJECT_NUMBER --web
# View project as JSON for scripting
gh project view PROJECT_NUMBER --format json
```
### Creating Projects
```bash
# Create repository project
gh project create --owner OWNER --title "Sprint 24" --body "Sprint 24 work items"
# Create organization project
gh project create --org ORGANIZATION --title "Q4 Roadmap" --body "Q4 2024 initiatives"
# Create project with specific format
gh project create --title "Product Backlog" --format board
```
### Managing Project Items
```bash
# Add issue to project
gh project item-add PROJECT_NUMBER --owner OWNER --url https://github.com/owner/repo/issues/123
# Add PR to project
gh project item-add PROJECT_NUMBER --owner OWNER --url https://github.com/owner/repo/pull/456
# Remove item from project
gh project item-delete --id ITEM_ID --project-id PROJECT_ID
# List items in project
gh project item-list PROJECT_NUMBER --owner OWNER
# List items with specific status
gh project item-list PROJECT_NUMBER --owner OWNER --format json | \
jq '.items[] | select(.status == "In Progress")'
```
### Updating Item Fields
```bash
# Update item status
gh project item-edit \
--project-id PROJECT_ID \
--id ITEM_ID \
--field-id STATUS_FIELD_ID \
--value "In Progress"
# Update priority
gh project item-edit \
--project-id PROJECT_ID \
--id ITEM_ID \
--field-id PRIORITY_FIELD_ID \
--value "High"
# Update sprint
gh project item-edit \
--project-id PROJECT_ID \
--id ITEM_ID \
--field-id SPRINT_FIELD_ID \
--value "Sprint 24"
# Update multiple fields
gh project item-edit \
--project-id PROJECT_ID \
--id ITEM_ID \
--field-id STATUS_FIELD_ID \
--value "Done" \
--field-id COMPLETED_DATE_FIELD_ID \
--value "2024-11-04"
```
### Managing Project Fields
```bash
# List all fields in project
gh project field-list PROJECT_NUMBER --owner OWNER
# Create new field
gh project field-create PROJECT_NUMBER \
--owner OWNER \
--name "Story Points" \
--data-type "NUMBER"
# Create single-select field
gh project field-create PROJECT_NUMBER \
--owner OWNER \
--name "Priority" \
--data-type "SINGLE_SELECT" \
--options "High,Medium,Low"
# Delete field
gh project field-delete PROJECT_NUMBER --field-id FIELD_ID
```
## Common Kanban Board Configurations
### Basic Scrum Board
**Columns**:
1. **Backlog**: All items not yet started
2. **Sprint Backlog**: Items planned for current sprint
3. **In Progress**: Actively being worked on
4. **In Review**: Code review or testing
5. **Done**: Completed items
**Custom Fields**:
- Priority: High / Medium / Low
- Story Points: 1, 2, 3, 5, 8, 13
- Sprint: Sprint 1, Sprint 2, etc.
- Assignee: Team member
### Feature Development Board
**Columns**:
1. **Ideas**: Proposals and feature requests
2. **Refined**: Requirements documented
3. **Ready**: Approved and ready for development
4. **In Development**: Active coding
5. **In Review**: Code review
6. **In Testing**: QA testing
7. **Deployed**: Live in production
**Custom Fields**:
- Feature Area: Frontend / Backend / DevOps
- Size: Small / Medium / Large
- Target Release: v1.0, v1.1, etc.
- Customer Impact: High / Medium / Low
### Bug Tracking Board
**Columns**:
1. **Triage**: New bugs needing review
2. **Confirmed**: Verified and reproduced
3. **Prioritized**: Assigned priority
4. **In Progress**: Being fixed
5. **Fixed**: Code merged
6. **Verified**: QA confirmed fix
**Custom Fields**:
- Severity: Critical / High / Medium / Low
- Affected Version: Version numbers
- Root Cause: Code bug / Configuration / External
- Customer Reported: Yes / No
## Workflow Automation
### Automated Column Movements
**Auto-move to "In Progress"** when:
- Issue is assigned
- PR is opened
- Branch is created
**Auto-move to "In Review"** when:
- PR is ready for review
- Issue is labeled "review"
**Auto-move to "Done"** when:
- PR is merged
- Issue is closed
### Example Automation Setup
While GitHub Projects V2 automation is typically configured via the UI, you can use GitHub Actions:
```yaml
# .github/workflows/project-automation.yml
name: Project Board Automation
on:
issues:
types: [opened, assigned, closed]
pull_request:
types: [opened, ready_for_review, closed]
jobs:
update-project:
runs-on: ubuntu-latest
steps:
- name: Move issue to In Progress
if: github.event_name == 'issues' && github.event.action == 'assigned'
uses: actions/github-script@v7
with:
script: |
// Update project item status
// (Implementation depends on project structure)
- name: Move PR to In Review
if: github.event_name == 'pull_request' && github.event.action == 'ready_for_review'
uses: actions/github-script@v7
with:
script: |
// Update project item status
- name: Move to Done
if: (github.event_name == 'issues' && github.event.action == 'closed') || (github.event_name == 'pull_request' && github.event.pull_request.merged)
uses: actions/github-script@v7
with:
script: |
// Update project item status to Done
```
## Project Management Workflows
### Sprint Planning
1. **Review backlog**:
```bash
gh project item-list PROJECT_NUMBER --owner OWNER --format json | \
jq '.items[] | select(.status == "Backlog")'
```
2. **Select items for sprint**:
```bash
# Move items to Sprint Backlog
gh project item-edit \
--project-id PROJECT_ID \
--id ITEM_ID \
--field-id STATUS_FIELD_ID \
--value "Sprint Backlog" \
--field-id SPRINT_FIELD_ID \
--value "Sprint 24"
```
3. **Assign to team members**:
```bash
gh issue edit 123 --add-assignee username
```
4. **Set priorities and estimates**:
```bash
gh project item-edit \
--project-id PROJECT_ID \
--id ITEM_ID \
--field-id STORY_POINTS_FIELD_ID \
--value 5
```
### Daily Standup Report
```bash
# Items in progress
echo "In Progress:"
gh project item-list PROJECT_NUMBER --owner OWNER --format json | \
jq -r '.items[] | select(.status == "In Progress") | "- #\(.content.number): \(.content.title) (@\(.assignees[0].login))"'
# Items in review
echo "\nIn Review:"
gh project item-list PROJECT_NUMBER --owner OWNER --format json | \
jq -r '.items[] | select(.status == "In Review") | "- #\(.content.number): \(.content.title)"'
# Blocked items
echo "\nBlocked:"
gh issue list --label "status: blocked" --json number,title,assignees
```
### Sprint Retrospective
```bash
# Completed items count
COMPLETED=$(gh project item-list PROJECT_NUMBER --owner OWNER --format json | \
jq '[.items[] | select(.status == "Done")] | length')
echo "Completed items: $COMPLETED"
# Velocity calculation
STORY_POINTS=$(gh project item-list PROJECT_NUMBER --owner OWNER --format json | \
jq '[.items[] | select(.status == "Done" and .storyPoints != null) | .storyPoints] | add')
echo "Total story points: $STORY_POINTS"
# Cycle time (for closed issues)
gh issue list --state closed --search "closed:>=$(date -v-14d +%Y-%m-%d)" --json number,closedAt,createdAt
```
## Best Practices
### Board Organization
1. **Keep columns focused**: 3-7 columns is optimal
2. **Define column criteria**: Clear rules for when items move
3. **Limit WIP**: Set work-in-progress limits per column
4. **Regular grooming**: Weekly backlog refinement
5. **Clear ownership**: Each item should have an assignee
### Field Usage
1. **Consistent values**: Use predefined options for consistency
2. **Required fields**: Priority, Status, Assignee as minimum
3. **Meaningful estimates**: Story points or t-shirt sizes
4. **Track progress**: Use dates, sprints, milestones
### Team Workflows
1. **Daily updates**: Team members update their items daily
2. **Pull model**: Team members pull work from backlog
3. **Visual management**: Use labels and colors effectively
4. **Transparency**: Keep board public and accessible
5. **Retrospectives**: Review and improve process regularly
### Reporting
Generate insights from your board:
```bash
# Sprint burndown data
gh project item-list PROJECT_NUMBER --format json | \
jq '[.items[] | select(.sprint == "Sprint 24")] |
{total: length, done: [.[] | select(.status == "Done")] | length}'
# Items by priority
gh project item-list PROJECT_NUMBER --format json | \
jq 'group_by(.priority) | map({priority: .[0].priority, count: length})'
# Team workload
gh issue list --assignee username --json state | \
jq 'group_by(.state) | map({state: .[0].state, count: length})'
```
## Example Workflows
### Create New Sprint Board
```bash
# Create project
PROJECT_NUMBER=$(gh project create \
--owner ORGANIZATION \
--title "Sprint 24 - Nov 4-17" \
--body "Sprint 24 work items for Product Team" \
--format json | jq -r '.number')
echo "Created project #$PROJECT_NUMBER"
# Add backlog items to sprint
gh issue list --label "sprint-24" --json number --jq '.[].number' | \
while read issue_number; do
gh project item-add $PROJECT_NUMBER \
--owner ORGANIZATION \
--url "https://github.com/OWNER/REPO/issues/$issue_number"
echo "Added issue #$issue_number"
done
```
### Move All Ready Items to Sprint
```bash
# Get all items with status "Ready"
gh project item-list PROJECT_NUMBER --format json | \
jq -r '.items[] | select(.status == "Ready") | .id' | \
while read item_id; do
gh project item-edit \
--project-id PROJECT_ID \
--id $item_id \
--field-id STATUS_FIELD_ID \
--value "Sprint Backlog"
echo "Moved item $item_id to Sprint Backlog"
done
```
### Generate Sprint Report
```bash
#!/bin/bash
# sprint-report.sh
PROJECT_NUMBER=$1
SPRINT_NAME=$2
echo "# Sprint Report: $SPRINT_NAME"
echo "Generated: $(date)"
echo ""
# Get all items
ITEMS=$(gh project item-list $PROJECT_NUMBER --format json)
# Total items
TOTAL=$(echo "$ITEMS" | jq '[.items[] | select(.sprint == "'$SPRINT_NAME'")] | length')
echo "Total items: $TOTAL"
# Completed items
COMPLETED=$(echo "$ITEMS" | jq '[.items[] | select(.sprint == "'$SPRINT_NAME'" and .status == "Done")] | length')
echo "Completed: $COMPLETED"
# In progress
IN_PROGRESS=$(echo "$ITEMS" | jq '[.items[] | select(.sprint == "'$SPRINT_NAME'" and .status == "In Progress")] | length')
echo "In progress: $IN_PROGRESS"
# Completion rate
RATE=$(echo "scale=2; $COMPLETED * 100 / $TOTAL" | bc)
echo "Completion rate: ${RATE}%"
# Story points
TOTAL_POINTS=$(echo "$ITEMS" | jq '[.items[] | select(.sprint == "'$SPRINT_NAME'" and .storyPoints != null) | .storyPoints] | add')
COMPLETED_POINTS=$(echo "$ITEMS" | jq '[.items[] | select(.sprint == "'$SPRINT_NAME'" and .status == "Done" and .storyPoints != null) | .storyPoints] | add')
echo ""
echo "Total story points: $TOTAL_POINTS"
echo "Completed points: $COMPLETED_POINTS"
```
## Integration with Issues
```bash
# Create issue and add to project in one workflow
ISSUE_NUMBER=$(gh issue create \
--title "Implement user dashboard" \
--body "Requirements..." \
--label "feature,frontend" \
--assignee username \
--json number --jq '.number')
gh project item-add PROJECT_NUMBER \
--owner OWNER \
--url "https://github.com/OWNER/REPO/issues/$ISSUE_NUMBER"
echo "Created issue #$ISSUE_NUMBER and added to project"
```
## Questions to Ask
Before managing project boards:
1. "What is the purpose of this project board?"
2. "What workflow stages do you need? (e.g., Todo, In Progress, Done)"
3. "What custom fields should we track? (priority, sprint, story points)"
4. "Is this a repository or organization-level project?"
5. "Should we set up any automation rules?"
6. "Do you want to add existing issues to this board?"
7. "What views do you need? (Board, Table, Roadmap)"
Ask the user: "What would you like to do with GitHub project boards?"

607
commands/sng-repo.md Normal file
View File

@@ -0,0 +1,607 @@
# GitHub Repository Management Command
You are helping the user manage GitHub repositories, including setup, configuration, and administrative tasks following Sngular's best practices.
## Instructions
1. **Determine the action**:
- View repository information
- Clone or fork repository
- Configure repository settings
- Manage branches and protection rules
- Set up webhooks and integrations
- Manage collaborators and teams
- Configure Actions and workflows
- Archive or transfer repository
2. **Verify GitHub access**:
- Check `gh` CLI authentication
- Verify user permissions
- Confirm organization membership if needed
## GitHub CLI Commands
### Repository Information
```bash
# View current repository
gh repo view
# View specific repository
gh repo view OWNER/REPO
# View in browser
gh repo view OWNER/REPO --web
# Get repository details as JSON
gh repo view OWNER/REPO --json name,description,owner,url,isPrivate,defaultBranch
```
### Creating Repositories
```bash
# Create new repository
gh repo create my-new-repo --public --description "My project description"
# Create private repository
gh repo create my-private-repo --private
# Create with README and license
gh repo create my-repo --public --add-readme --license mit
# Create from template
gh repo create my-project --template OWNER/TEMPLATE-REPO --public
# Create in organization
gh repo create ORGANIZATION/repo-name --public
# Clone after creation
gh repo create my-repo --public --clone
```
### Cloning and Forking
```bash
# Clone repository
gh repo clone OWNER/REPO
# Clone to specific directory
gh repo clone OWNER/REPO ./my-directory
# Fork repository
gh repo fork OWNER/REPO
# Fork and clone
gh repo fork OWNER/REPO --clone
# Fork to organization
gh repo fork OWNER/REPO --org ORGANIZATION
```
### Repository Settings
```bash
# Edit repository details
gh repo edit OWNER/REPO --description "New description"
# Enable/disable features
gh repo edit OWNER/REPO --enable-wiki=true
gh repo edit OWNER/REPO --enable-issues=true
gh repo edit OWNER/REPO --enable-projects=true
# Change default branch
gh repo edit OWNER/REPO --default-branch main
# Set homepage URL
gh repo edit OWNER/REPO --homepage "https://example.com"
# Add topics
gh repo edit OWNER/REPO --add-topic "javascript,react,frontend"
# Change visibility
gh repo edit OWNER/REPO --visibility private
```
### Branch Management
```bash
# List branches
gh api repos/OWNER/REPO/branches
# Get default branch
gh repo view OWNER/REPO --json defaultBranchRef --jq '.defaultBranchRef.name'
# Rename default branch (requires git)
git branch -m master main
git push -u origin main
gh repo edit OWNER/REPO --default-branch main
git push origin --delete master
```
### Branch Protection
```bash
# View branch protection
gh api repos/OWNER/REPO/branches/main/protection
# Enable branch protection (via API)
gh api -X PUT repos/OWNER/REPO/branches/main/protection \
-f required_status_checks='{"strict":true,"contexts":["ci/test"]}' \
-f enforce_admins=true \
-f required_pull_request_reviews='{"required_approving_review_count":2}' \
-f restrictions=null
# Require PR reviews
gh api -X PUT repos/OWNER/REPO/branches/main/protection \
-f required_pull_request_reviews='{"required_approving_review_count":1,"dismiss_stale_reviews":true}'
# Require status checks
gh api -X PUT repos/OWNER/REPO/branches/main/protection/required_status_checks \
-f strict=true \
-f contexts='["ci/test","ci/lint"]'
```
### Collaborators and Teams
```bash
# List collaborators
gh api repos/OWNER/REPO/collaborators
# Add collaborator
gh api -X PUT repos/OWNER/REPO/collaborators/USERNAME \
-f permission=push
# Remove collaborator
gh api -X DELETE repos/OWNER/REPO/collaborators/USERNAME
# List teams with access (organization repos)
gh api repos/ORGANIZATION/REPO/teams
# Add team
gh api -X PUT repos/ORGANIZATION/REPO/teams/TEAM-SLUG \
-f permission=push
# Permission levels: pull, push, admin, maintain, triage
```
### Repository Secrets
```bash
# List secrets
gh secret list --repo OWNER/REPO
# Set secret
gh secret set SECRET_NAME --repo OWNER/REPO --body "secret-value"
# Set secret from file
gh secret set SECRET_NAME --repo OWNER/REPO < secret.txt
# Delete secret
gh secret delete SECRET_NAME --repo OWNER/REPO
```
### Actions and Workflows
```bash
# List workflows
gh workflow list
# View workflow
gh workflow view workflow.yml
# Run workflow
gh workflow run workflow.yml
# View workflow runs
gh run list
# View specific run
gh run view RUN_ID
# Download artifacts
gh run download RUN_ID
# Enable/disable workflow
gh workflow enable workflow.yml
gh workflow disable workflow.yml
```
### Webhooks
```bash
# List webhooks
gh api repos/OWNER/REPO/hooks
# Create webhook
gh api repos/OWNER/REPO/hooks \
-f name=web \
-f active=true \
-f events='["push","pull_request"]' \
-f config='{"url":"https://example.com/webhook","content_type":"json"}'
# Delete webhook
gh api -X DELETE repos/OWNER/REPO/hooks/HOOK_ID
```
### Repository Analytics
```bash
# View traffic (views, clones)
gh api repos/OWNER/REPO/traffic/views
gh api repos/OWNER/REPO/traffic/clones
# Popular content
gh api repos/OWNER/REPO/traffic/popular/paths
# Referrers
gh api repos/OWNER/REPO/traffic/popular/referrers
# Languages
gh api repos/OWNER/REPO/languages
# Contributors
gh api repos/OWNER/REPO/contributors
```
### Repository Maintenance
```bash
# Archive repository
gh repo archive OWNER/REPO
# Unarchive repository
gh repo archive OWNER/REPO --unarchive
# Delete repository (careful!)
gh repo delete OWNER/REPO --confirm
# Transfer repository
gh api -X POST repos/OWNER/REPO/transfer \
-f new_owner=NEW-OWNER
```
## Common Setup Tasks
### Initialize New Repository
```bash
#!/bin/bash
# setup-repo.sh
REPO_NAME=$1
ORG_NAME=${2:-}
DESCRIPTION=${3:-""}
# Create repository
if [ -n "$ORG_NAME" ]; then
gh repo create "$ORG_NAME/$REPO_NAME" \
--public \
--description "$DESCRIPTION" \
--add-readme \
--license mit \
--clone
else
gh repo create "$REPO_NAME" \
--public \
--description "$DESCRIPTION" \
--add-readme \
--license mit \
--clone
fi
cd "$REPO_NAME" || exit
# Initialize git flow
git checkout -b develop
# Create .gitignore
cat > .gitignore <<EOF
node_modules/
.env
.DS_Store
dist/
build/
*.log
EOF
# Create basic README
cat > README.md <<EOF
# $REPO_NAME
$DESCRIPTION
## Installation
\`\`\`bash
npm install
\`\`\`
## Usage
\`\`\`bash
npm start
\`\`\`
## Testing
\`\`\`bash
npm test
\`\`\`
## Contributing
Please read CONTRIBUTING.md for details.
## License
MIT
EOF
# Commit initial setup
git add .
git commit -m "Initial repository setup"
git push origin main
git push origin develop
echo "Repository $REPO_NAME created and initialized!"
```
### Configure Branch Protection
```bash
#!/bin/bash
# protect-main-branch.sh
OWNER=$1
REPO=$2
echo "Configuring branch protection for main branch..."
# Require PR reviews
gh api -X PUT repos/$OWNER/$REPO/branches/main/protection \
--input - <<EOF
{
"required_status_checks": {
"strict": true,
"contexts": ["ci/test", "ci/lint"]
},
"enforce_admins": true,
"required_pull_request_reviews": {
"required_approving_review_count": 1,
"dismiss_stale_reviews": true,
"require_code_owner_reviews": true
},
"restrictions": null,
"required_linear_history": true,
"allow_force_pushes": false,
"allow_deletions": false
}
EOF
echo "Branch protection configured!"
```
### Setup GitHub Actions
```bash
# Create .github/workflows directory
mkdir -p .github/workflows
# Create CI workflow
cat > .github/workflows/ci.yml <<'EOF'
name: CI
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
- run: npm ci
- run: npm test
- run: npm run lint
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
- run: npm ci
- run: npm run build
EOF
git add .github/workflows/ci.yml
git commit -m "Add CI workflow"
git push
```
### Configure Repository Labels
```bash
#!/bin/bash
# setup-labels.sh
OWNER=$1
REPO=$2
# Delete default labels
gh label delete bug --repo $OWNER/$REPO --yes
gh label delete documentation --repo $OWNER/$REPO --yes
gh label delete enhancement --repo $OWNER/$REPO --yes
# Create custom labels
gh label create "type: bug" --color "d73a4a" --description "Something isn't working" --repo $OWNER/$REPO
gh label create "type: feature" --color "0075ca" --description "New feature or request" --repo $OWNER/$REPO
gh label create "type: docs" --color "0075ca" --description "Documentation improvements" --repo $OWNER/$REPO
gh label create "type: refactor" --color "fbca04" --description "Code refactoring" --repo $OWNER/$REPO
gh label create "priority: critical" --color "b60205" --description "Critical priority" --repo $OWNER/$REPO
gh label create "priority: high" --color "d93f0b" --description "High priority" --repo $OWNER/$REPO
gh label create "priority: medium" --color "fbca04" --description "Medium priority" --repo $OWNER/$REPO
gh label create "priority: low" --color "0e8a16" --description "Low priority" --repo $OWNER/$REPO
gh label create "status: ready" --color "0e8a16" --description "Ready for development" --repo $OWNER/$REPO
gh label create "status: in-progress" --color "fbca04" --description "Currently being worked on" --repo $OWNER/$REPO
gh label create "status: blocked" --color "d93f0b" --description "Blocked by dependencies" --repo $OWNER/$REPO
gh label create "status: needs-review" --color "0075ca" --description "Needs code review" --repo $OWNER/$REPO
echo "Labels configured!"
```
### Setup Issue Templates
```bash
# Create issue templates directory
mkdir -p .github/ISSUE_TEMPLATE
# Bug report template
cat > .github/ISSUE_TEMPLATE/bug_report.md <<'EOF'
---
name: Bug Report
about: Create a report to help us improve
title: '[BUG] '
labels: 'type: bug, status: triage'
assignees: ''
---
## Bug Description
A clear description of what the bug is.
## Steps to Reproduce
1. Go to '...'
2. Click on '...'
3. See error
## Expected Behavior
What you expected to happen.
## Actual Behavior
What actually happened.
## Environment
- OS: [e.g., macOS 14.0]
- Browser: [e.g., Chrome 120]
- Version: [e.g., 2.0.1]
## Additional Context
Add any other context about the problem here.
EOF
# Feature request template
cat > .github/ISSUE_TEMPLATE/feature_request.md <<'EOF'
---
name: Feature Request
about: Suggest an idea for this project
title: '[FEATURE] '
labels: 'type: feature, status: triage'
assignees: ''
---
## Feature Description
Clear description of the feature you'd like to see.
## Problem Statement
What problem does this feature solve?
## Proposed Solution
How should this feature work?
## Alternatives Considered
What other approaches did you consider?
## Additional Context
Add any other context or screenshots about the feature request.
EOF
git add .github/ISSUE_TEMPLATE
git commit -m "Add issue templates"
git push
```
## Repository Best Practices
### README Structure
A good README should include:
1. Project title and description
2. Installation instructions
3. Usage examples
4. API documentation (if applicable)
5. Contributing guidelines
6. License information
7. Contact information
8. Badges (build status, coverage, version)
### Branch Strategy
**Git Flow**:
- `main` - Production-ready code
- `develop` - Development branch
- `feature/*` - Feature branches
- `hotfix/*` - Emergency fixes
- `release/*` - Release preparation
**GitHub Flow** (simpler):
- `main` - Always deployable
- `feature-branches` - Short-lived feature branches
- Deploy from main
### Security Best Practices
1. **Enable security features**:
```bash
gh repo edit OWNER/REPO --enable-security-alerts=true
gh repo edit OWNER/REPO --enable-vulnerability-alerts=true
```
2. **Use branch protection**:
- Require PR reviews
- Require status checks
- Enforce linear history
- No force pushes
3. **Secrets management**:
- Never commit secrets
- Use GitHub Secrets
- Rotate secrets regularly
- Use separate secrets per environment
4. **Dependency management**:
- Enable Dependabot
- Review security advisories
- Keep dependencies updated
### Documentation
Essential documentation files:
- `README.md` - Project overview
- `CONTRIBUTING.md` - Contribution guidelines
- `CODE_OF_CONDUCT.md` - Community standards
- `LICENSE` - License information
- `CHANGELOG.md` - Version history
- `.github/PULL_REQUEST_TEMPLATE.md` - PR template
## Questions to Ask
Before managing repositories:
1. "What do you want to do with the repository?"
2. "Is this a new repository or existing one?"
3. "Should it be public or private?"
4. "Do you need branch protection rules?"
5. "Should we set up CI/CD workflows?"
6. "Do you need to add collaborators or teams?"
7. "Should we configure issue templates?"
Ask the user: "What repository management task would you like to perform?"

View File

@@ -0,0 +1,239 @@
# Requirements Analysis Command
You are helping the user analyze, document, and manage project requirements following Sngular's project management best practices.
## Instructions
1. **Determine the scope**:
- Ask what feature or project needs requirements analysis
- Identify if this is for a new feature, enhancement, or bug fix
- Determine if there's an existing GitHub issue to update
- Check for existing documentation to review
2. **Gather context**:
- Review project documentation in `./docs`
- Analyze relevant codebase sections
- Check existing requirements or specifications
- Review similar features or patterns in the project
- Identify stakeholders and their needs
3. **Analyze requirements**:
- **Functional Requirements**: What the system must do
- **Non-Functional Requirements**: Performance, security, scalability, accessibility
- **User Stories**: As a [user], I want [goal], so that [benefit]
- **Acceptance Criteria**: Clear, testable conditions for completion
- **Dependencies**: Other features, services, or systems required
- **Constraints**: Technical, business, or time limitations
- **Assumptions**: Things we're assuming to be true
- **Risks**: Potential issues or challenges
4. **Structure the documentation**:
```markdown
## [Feature Name] - Requirements
### Overview
Brief description of the feature and its purpose.
### Business Context
- Why is this needed?
- What problem does it solve?
- What is the expected business impact?
### Functional Requirements
#### FR-1: [Requirement Title]
**Priority**: Must-have / Should-have / Could-have / Won't-have
**Description**: Detailed description of what needs to be implemented
**Acceptance Criteria**:
- [ ] Criterion 1
- [ ] Criterion 2
- [ ] Criterion 3
#### FR-2: [Next Requirement]
...
### Non-Functional Requirements
#### NFR-1: Performance
- Response time: < 200ms for API calls
- Page load time: < 2 seconds
- Support for 1000 concurrent users
#### NFR-2: Security
- Authentication required
- Role-based access control
- Data encryption at rest and in transit
#### NFR-3: Accessibility
- WCAG 2.1 AA compliance
- Screen reader support
- Keyboard navigation
### User Stories
**US-1**: As a [user type], I want to [action], so that [benefit]
- Acceptance Criteria:
- [ ] Criterion 1
- [ ] Criterion 2
### Technical Specifications
#### Data Models
```typescript
interface Model {
id: string
// ...
}
```
#### API Endpoints
- `POST /api/resource` - Create new resource
- `GET /api/resource/:id` - Retrieve resource
#### UI Components
- ComponentName: Description and purpose
### Dependencies
- External APIs or services required
- Third-party libraries needed
- Database schema changes
- Infrastructure requirements
### Assumptions
- List of assumptions made during analysis
### Risks & Mitigation
| Risk | Impact | Likelihood | Mitigation Strategy |
|------|--------|------------|---------------------|
| Risk 1 | High | Medium | Mitigation plan |
### Testing Strategy
- Unit tests for business logic
- Integration tests for API endpoints
- E2E tests for user workflows
- Performance testing approach
- Security testing considerations
### Implementation Phases
**Phase 1**: Core functionality (2 weeks)
- [ ] Task 1
- [ ] Task 2
**Phase 2**: Advanced features (1 week)
- [ ] Task 3
- [ ] Task 4
**Phase 3**: Polish & optimization (3 days)
- [ ] Task 5
- [ ] Task 6
### Success Metrics
- How will we measure success?
- KPIs to track
- User adoption goals
### Open Questions
- [ ] Question 1 that needs clarification
- [ ] Question 2 requiring stakeholder input
```
5. **GitHub Integration** (if applicable):
- Check if working in a GitHub repository
- Ask for issue number to update
- Create or update GitHub issue with requirements
- Add appropriate labels: `requirements`, `documentation`
- Link related issues if any
6. **Save documentation**:
- Save requirements to `./docs/requirements/[feature-name].md`
- Update main requirements index if it exists
- Create a summary for quick reference
## GitHub Commands
```bash
# View repository info
gh repo view
# List existing issues
gh issue list
# View specific issue
gh issue view <issue-number>
# Create new issue with requirements
gh issue create --title "Requirements: [Feature Name]" --body "$(cat requirements.md)" --label "requirements,documentation"
# Add requirements as comment to existing issue
gh issue comment <issue-number> --body "$(cat requirements.md)"
# Update issue labels
gh issue edit <issue-number> --add-label "requirements-defined"
# Link issues
gh issue comment <issue-number> --body "Related to #<other-issue-number>"
```
## Requirements Prioritization (MoSCoW Method)
- **Must-have**: Critical for launch, non-negotiable
- **Should-have**: Important but not critical, can be scheduled for later if needed
- **Could-have**: Nice to have, adds value but not essential
- **Won't-have**: Not planned for this release, explicitly excluded
## Best Practices
### Writing Good Requirements
✅ **Good**:
- "The system shall allow users to export data in CSV, JSON, and XML formats"
- "API response time must be under 200ms for 95% of requests"
- "The login form must be accessible via keyboard navigation"
❌ **Bad**:
- "The system should be fast" (not measurable)
- "It should be user-friendly" (too vague)
- "We might need export functionality" (not decisive)
### Acceptance Criteria Guidelines
Each acceptance criterion should be:
- **Specific**: Clearly defined without ambiguity
- **Measurable**: Can be verified through testing
- **Achievable**: Technically feasible within constraints
- **Relevant**: Directly related to the requirement
- **Testable**: Can write automated or manual tests
### INVEST Principles for User Stories
- **Independent**: Can be developed separately
- **Negotiable**: Open to discussion and refinement
- **Valuable**: Provides clear value to users
- **Estimable**: Team can estimate effort
- **Small**: Can be completed in one sprint
- **Testable**: Can verify it's done
## Questions to Ask
Before starting requirements analysis:
1. "What is the main goal or problem this feature addresses?"
2. "Who are the primary users and what are their needs?"
3. "Are there existing issues or documentation I should review?"
4. "What are the must-have features vs. nice-to-have?"
5. "Are there any technical constraints or dependencies?"
6. "What is the expected timeline or deadline?"
7. "How will success be measured?"
8. "Should I create a new GitHub issue or update an existing one?"
## Example Workflow
1. User: "Analyze requirements for user authentication feature"
2. Claude: Reviews codebase, checks for existing auth patterns
3. Claude: Asks clarifying questions about auth method (OAuth, JWT, etc.)
4. Claude: Creates comprehensive requirements document
5. Claude: Saves to `./docs/requirements/user-authentication.md`
6. Claude: Creates GitHub issue or updates existing one
7. Claude: Provides summary and next steps
Ask the user: "What feature or project would you like me to analyze requirements for?"