Git metadata extractor

From lightspeedwp/.github · View interactive version

Git metadata extractor is an AI agent skill from the GitHub repository lightspeedwp/.github. Extract git metadata (commits, branch, issues) for handoff context

How to use this skill

Skill file

Git Metadata Extractor Skill

Overview

Extracts commit history, branch information, and related issue numbers from a git repository. This skill provides structured metadata for building handoff prompts, tracking work completed in a session, and generating project context for AI systems.

When to Use

Input Parameters

Required

Optional

Output Format

{
  branch: "feat/chat-closure-agent-impl",
  parsedBranch: {
    type: "feat",
    scope: "chat-closure",
    title: "agent-impl"
  },
  repoType: "control-plane",
  commits: [
    {
      hash: "abc123",
      message: "feat: Add feature (#1234)",
      author: "John Doe",
      date: "2026-08-12T10:00:00Z"
    }
  ],
  issueNumbers: ["#1234"],
  gitState: {
    isClean: true,
    staged: [],
    uncommitted: [],
    hasChanges: false
  },
  memoryState: {
    exists: true,
    indexExists: true,
    files: ["session-1234.md"],
    lastUpdated: "2026-08-12T09:00:00Z"
  },
  timestamp: "2026-08-12T11:00:00Z"
}

Usage Examples

Basic Usage

const { analyzeRepository } = require('./shared/core-analysis')

const metadata = analyzeRepository('.')
console.log(`Branch: ${metadata.branch}`)
console.log(`Repo type: ${metadata.repoType}`)
console.log(`Related issues: ${metadata.issueNumbers.join(', ')}`)

Extract Branch Information

const { parseBranchName, getCurrentBranch } = require('./shared/core-analysis')

const branch = getCurrentBranch('.')
const parsed = parseBranchName(branch)
console.log(`Feature: ${parsed.scope}`)

Get Commit History

const { getRecentCommits } = require('./shared/core-analysis')

const commits = getRecentCommits('.', 10)
commits.forEach(c => {
  console.log(`${c.hash} — ${c.message} (${c.author})`)
})

Find Related Issues

const { getRecentCommits, extractIssueNumbers } = require('./shared/core-analysis')

const commits = getRecentCommits('.')
const issues = extractIssueNumbers(commits)
console.log(`Found issues: ${issues.join(', ')}`)

Detect Repository Type

const { detectRepoType } = require('./shared/core-analysis')

try {
  const type = detectRepoType('.')
  console.log(`This is a ${type} repository`)
  // Output: "This is a control-plane repository"
} catch (error) {
  console.error(`Repository type could not be determined: ${error.message}`)
}

Check Git State

const { analyzeGitState } = require('./shared/core-analysis')

const state = analyzeGitState('.')
if (state.isClean) {
  console.log('Working directory is clean')
} else {
  console.log(`Staged: ${state.staged.length} files`)
  console.log(`Modified: ${state.uncommitted.length} files`)
}

Check Memory System

const { readMemoryState } = require('./shared/core-analysis')

const memory = readMemoryState('.')
if (memory.exists) {
  console.log(`Found ${memory.files.length} memory entries`)
  console.log(`Last updated: ${memory.lastUpdated}`)
}

Supported Repository Types

| Type | Indicators | Use Case |

|------|-----------|----------|

| control-plane | .github/projects/active/ + .github/labels.yml | LightSpeed .github repository |

| wordpress-plugin | plugin.php + composer.json | WordPress plugin repository |

| wordpress-theme | style.css + theme.json | WordPress theme repository |

Branch Name Format

Expected format: {type}/{scope}-{title}

Examples:

Valid prefixes: feat, fix, hotfix, chore, docs, ci, test, refactor, security, perf, build, deps, design, a11y, ux, ops, etc.

Error Handling

This skill throws errors in these scenarios:

Example Error Handling

const coreAnalysis = require('./shared/core-analysis')

try {
  const metadata = coreAnalysis.analyzeRepository('.')
} catch (error) {
  if (error.message.includes('Invalid branch name')) {
    console.error('Branch must follow convention: feat/{scope}-{title}')
  } else if (error.message.includes('Unknown repository type')) {
    console.error('Repository type not supported')
  } else {
    console.error(`Analysis failed: ${error.message}`)
  }
}

Integration with Memory System

The skill checks for existing memory system state:

const { readMemoryState } = require('./shared/core-analysis')

const metadata = coreAnalysis.analyzeRepository('.')
if (metadata.memoryState.exists) {
  // Memory system is active
  const memoryEntries = metadata.memoryState.files
  console.log(`Previous entries: ${memoryEntries.length}`)
}

Testing

This skill includes Jest unit tests with 90%+ coverage:

npm test -- core-analysis.test.js

Test fixtures are available in tests/fixtures/:

Related Skills

Version History

v1.0.0 (2026-08-12)


Maintained by the 🤖 LightSpeedWP Automation Team

_Docs signed by 🤖 Copilot for LightSpeedWP – always fresh!_

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.