agentleFS
reaatechreaatech/mcp-changelog/skills/git-integration/SKILL.md

git-integration

Skill0 starsChanged 3 months agoMITView on GitHub

The git-integration skill provides capabilities for resolving git references, extracting files from git history, and enumerating tags. This is the foundational skill for mcp-changelog's git-native design.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Batch operations: Use git cat-file --batch for multiple file reads

    line 194
  2. Distinctive:

    Parallel reads: Use Promise.all for independent file reads

    line 197

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Git Integration Skill

Purpose

The git-integration skill provides capabilities for resolving git references, extracting files from git history, and enumerating tags. This is the foundational skill for mcp-changelog's git-native design.

Capabilities

1. Git Reference Resolution

  • Resolve tag names, commit SHAs, and branch names to concrete commits
  • Parse git range notation (e.g., v1.2.0..v1.3.0)
  • Handle symbolic refs (HEAD, branch names)
  • Validate that refs exist before use

2. Tree Reading

  • List files in a git tree at a specific ref
  • Extract file contents from a git tree
  • Support recursive directory listing
  • Handle binary vs text file detection

3. Tag Enumeration

  • List all git tags matching a semver pattern
  • Sort tags by creation date or semver order
  • Filter lightweight vs annotated tags
  • Resolve tag objects to commit SHAs

Usage Examples

Resolving Git References

import { GitResolver } from '@reaatech/mcp-changelog/git';

const resolver = new GitResolver({ repoPath: '/path/to/repo' });

// Resolve a tag
const ref = await resolver.resolveRef('v1.2.0');
console.log(ref);
// { type: 'tag', name: 'v1.2.0', sha: 'abc123...' }

// Resolve a commit SHA
const commitRef = await resolver.resolveRef('abc123');
console.log(commitRef);
// { type: 'commit', name: 'abc123', sha: 'abc123...' }

// Parse a range
const range = await resolver.parseRange('v1.2.0..v1.3.0');
console.log(range);
// { from: GitRef, to: GitRef }

Reading Files from Git History

import { TreeReader } from '@reaatech/mcp-changelog/git';

const reader = new TreeReader({ repoPath: '/path/to/repo' });

// Read a file at a specific ref
const content = await reader.readFile('v1.2.0', 'schema.json');
console.log(content);
// '{"version": "1.2.0", "tools": [...]}'

// List files at a ref
const files = await reader.listFiles('v1.2.0');
console.log(files);
// ['schema.json', 'README.md', 'src/index.ts']

// List files in a subdirectory
const srcFiles = await reader.listFiles('v1.2.0', 'src/');
console.log(srcFiles);
// ['src/index.ts', 'src/types.ts']

Tag Enumeration

import { TagLister } from '@reaatech/mcp-changelog/git';

const lister = new TagLister({ repoPath: '/path/to/repo' });

// List all tags
const tags = await lister.listTags();
console.log(tags);
// [
//   { type: 'tag', name: 'v1.0.0', sha: '...' },
//   { type: 'tag', name: 'v1.1.0', sha: '...' },
//   { type: 'tag', name: 'v2.0.0', sha: '...' }
// ]

// List tags matching a pattern
const semverTags = await lister.listTags('^v\\d+\\.\\d+\\.\\d+$');
console.log(semverTags);
// Only semver tags

Configuration Options

interface GitIntegrationConfig {
  // Path to git repository (default: current working directory)
  repoPath: string;

  // Whether to cache git operations within a run
  cache: boolean;

  // Timeout for git operations in milliseconds
  timeout: number;

  // Tag pattern for filtering (default: match all)
  tagPattern?: string;
}

const config: GitIntegrationConfig = {
  repoPath: process.cwd(),
  cache: true,
  timeout: 30000,
  tagPattern: '^v\\d+\\.\\d+\\.\\d+$',
};

Best Practices

1. Always Validate Refs

// Good: Validate before use
const ref = await resolver.resolveRef(userInput);
if (!ref) {
  throw new GitRefNotFoundError(userInput);
}

// Bad: Assume ref exists
const sha = await git.revParse(userInput); // May throw cryptic error

2. Cache Git Operations

// Good: Cache within a run
const resolver = new GitResolver({ repoPath, cache: true });
const schemas = await Promise.all(
  refs.map(ref => resolver.readFile(ref, 'schema.json'))
);

// Bad: Redundant git calls
for (const ref of refs) {
  const r = new GitResolver({ repoPath }); // New instance = no cache
  await r.readFile(ref, 'schema.json');
}

3. Handle Detached HEAD

// Good: Graceful handling
try {
  const content = await reader.readFile('HEAD', 'schema.json');
} catch (error) {
  if (error.code === 'DETACHED_HEAD') {
    // Use fallback approach
  }
  throw error;
}

Error Handling

// Git ref not found
class GitRefNotFoundError extends Error {
  constructor(ref: string) {
    super(`Git reference "${ref}" not found`);
    this.name = 'GitRefNotFoundError';
  }
}

// File not found at ref
class GitFileNotFoundError extends Error {
  constructor(ref: string, path: string) {
    super(`File "${path}" not found at ref "${ref}"`);
    this.name = 'GitFileNotFoundError';
  }
}

// Invalid range syntax
class InvalidRangeError extends Error {
  constructor(range: string) {
    super(`Invalid git range: "${range}". Expected format: <from>..<to>`);
    this.name = 'InvalidRangeError';
  }
}

Performance Considerations

  • Batch operations: Use git cat-file --batch for multiple file reads
  • Shallow clones: Support --depth for large repos
  • Cache invalidation: Clear cache between runs, not within
  • Parallel reads: Use Promise.all for independent file reads

Testing Strategies

describe('GitResolver', () => {
  it('should resolve a valid tag', async () => {
    const resolver = new GitResolver({ repoPath: testRepo });
    const ref = await resolver.resolveRef('v1.0.0');
    expect(ref).toMatchObject({ type: 'tag', name: 'v1.0.0' });
    expect(ref.sha).toMatch(/^[0-9a-f]{40}$/);
  });

  it('should throw for non-existent ref', async () => {
    const resolver = new GitResolver({ repoPath: testRepo });
    await expect(resolver.resolveRef('nonexistent'))
      .rejects.toThrow(GitRefNotFoundError);
  });

  it('should parse a valid range', async () => {
    const resolver = new GitResolver({ repoPath: testRepo });
    const range = await resolver.parseRange('v1.0.0..v2.0.0');
    expect(range.from.name).toBe('v1.0.0');
    expect(range.to.name).toBe('v2.0.0');
  });
});

Remote Git Access (GitHub API)

For GitHub Action mode, support fetching files from remote repos:

import { Octokit } from 'octokit';

class GitHubTreeReader {
  constructor(private octokit: Octokit, private owner: string, private repo: string) {}

  async readFile(ref: string, path: string): Promise<string> {
    const { data } = await this.octokit.rest.repos.getContent({
      owner: this.owner,
      repo: this.repo,
      path,
      ref,
    });

    if ('content' in data) {
      return Buffer.from(data.content, 'base64').toString('utf-8');
    }
    throw new Error('Expected file content but got directory');
  }
}

Resources

  • ARCHITECTURE.md - System architecture
  • Git Integration section - Detailed module spec
  • simple-git docs - Git library reference
  • mcp-schema-evolution schema-diffing skill - Related diffing patterns

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.