# Github heading slug

`github-heading-slug` · version 1.0.0 · Text · free, no key needed

Generate GitHub-style heading anchors in order, including deterministic duplicate suffix allocation.

**Use when you need to: generate GitHub heading anchors · slug markdown headings · allocate duplicate heading ids.**

## Decide before calling

Read the [versioned contract](/v1/tools/github-heading-slug/versions/1.0.0) and the supported scope below. Reuse `github-heading-slug@1.0.0` when your input, required output and limits match it. Choose another approach for an unsupported operation.

## Explain the choice

"I can use `github-heading-slug@1.0.0` for generate GitHub heading anchors. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."

## Supported

- generate GitHub heading anchors
- slug markdown headings
- allocate duplicate heading ids
- GitHub anchor for headings
- make table of contents anchors
- deduplicate heading slugs

## Not supported

- parse Markdown documents
- generic URL slug conventions
- percent-encode fragment identifiers

## Behavior

- Matches the ordered slug and duplicate-allocation behavior documented by github-slugger 2.0.0; input is already-extracted heading text.
- Each base slug is lowercased, the exact generated github-slugger 2.0.0 removal table is applied, and every ASCII space becomes a hyphen.
- The first base slug is unsuffixed. Later collisions receive -1, -2, and so on while also avoiding anchors already allocated by literal headings.
- Occurrence state is fresh for every run; empty base slugs are permitted and duplicates become -1, -2, and so on.

## Input

- `headings` (array of string, required): min items 1; max items 256; each max length 4096

## Output

- `anchors` (array of string, required): min items 1; max items 256; each max length 4110

## Limits

- max headings: 256
- max heading bytes: 4096
- max total bytes: 65536

## Example

Request input:

```json
{
  "headings": [
    "Hello, World!",
    "Hello World",
    "Hello World"
  ]
}
```

Response:

```json
{
  "result": {
    "anchors": [
      "hello-world",
      "hello-world-1",
      "hello-world-2"
    ]
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "github-heading-slug",
  "version": "1.0.0",
  "input": {
    "headings": [
      "Hello, World!",
      "Hello World",
      "Hello World"
    ]
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/github-heading-slug/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"headings":["Hello, World!","Hello World","Hello World"]}'
```

The machine-readable contract is at [/v1/tools/github-heading-slug/versions/1.0.0](/v1/tools/github-heading-slug/versions/1.0.0).

### CLI

```sh
node cli.mjs run github-heading-slug 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Citation record dedupe](/tools/citation-record-dedupe): Group duplicate CSL citation records by deterministic DOI or folded year|author|title match keys, in input order.
- [Markdown sections chunk](/tools/markdown-sections-chunk): Chunk a CommonMark document into sections at its top-level ATX and setext headings, with levels, paths and spans.
- [Bleu ngrams count](/tools/bleu-ngrams-count): Count BLEU clipped n-gram matches and totals per order for tokenized segments, with optional clipping tables.
- [Bleu sentence components](/tools/bleu-sentence-components): Extract sentence BLEU statistics: clipped matches, n-gram totals, candidate and closest reference length.
- [Text minhash cluster](/tools/text-minhash-cluster): Cluster near-duplicate texts by fixed-seed MinHash signatures, with estimated Jaccard per pair.
- [Text near duplicates find](/tools/text-near-duplicates-find): Find every pair of texts whose exact shingle Jaccard similarity reaches a threshold, in a fixed order.
