← Gitignore Generator
Your token

Gitignore Generator API

Building the .gitignore, checking file names, the .env.example maker and every download run free in the browser and need no API. The API is for the one metered step: send a stack, the rules and a list of file names, and get back, as JSON, rules to add, files to take out of git and ignored files to keep. The page checks every rule and path against the file list and applies only what it can verify.

Base URL: https://api.skillsafe.ai/v1/app-api. Every response is {"data": ...} or {"error": {"code", "message"}}; read error.code and error.message rather than the HTTP status alone.

The task field

This app has one task. Always send "task": "review".

taskWhat it doesReply
reviewReads the stack, the rules and the file names and suggests rules to add (each with a reason and an example path from the list), paths to remove from git when the list is already committed, ignored paths that belong in git, and up to three notes. It never writes a whole .gitignore and never sees file contents.One JSON object

Input fields

FieldTypeMeaning
taskstring"review"
stackstringTemplate names, comma separated, e.g. "Node.js, Next.js, macOS".
gitignorestringThe current rules, comments removed (the page sends at most 9,000 characters).
filesstringFile names, one per line. Ignored folders are collapsed to dir/ (N files); the page sends at most 400 lines, spread across every top-level folder. May be empty.
files_notestringEmpty, or a sentence saying how many names were left out.
trackedstring"yes" when the list came from git ls-files, else "no".
findingsstringJSON text: secrets_open, hidden, ignored_count. Send "{}" if you have none.

The reply

job.output.output is text holding one JSON object (sometimes inside a ```json fence): add (a list of {pattern, reason, example}, at most 12), untrack (a list of {path, reason}, empty unless tracked is "yes"), keep (a list of {path, reason}) and notes (0 to 3 strings). Before applying a suggestion, check its path is in your list and that a new rule does not hide a manifest, lock file or README: the page does both. If the balance ran low, truncated is true and the object may stop early; the page keeps every item that arrived whole.

Worked example

Input (input.json), a small Go service:

{
  "task": "review",
  "stack": "Go, Linux, Vim",
  "gitignore": "*.exe\n*.exe~\n*.dll\n*.so\n*.dylib\n*.test\n*.out\ncoverage.html\ncoverage.txt\ncoverage.xml\n*.coverprofile\nprofile.cov\ngo.work\ngo.work.sum\n.env\n*~\n.fuse_hidden*\n.directory\n.Trash-*\n.nfs*\nnohup.out\n[._]*.s[a-v][a-z]\n!*.svg\n[._]*.sw[a-p]\n[._]s[a-rt-v][a-z]\n[._]ss[a-gi-z]\n[._]sw[a-p]\nSession.vim\nSessionx.vim\n.netrwhist\n*~\ntags\n[._]*.un~\n.env\n.env.*\n!.env.example\n!.env.sample\n!.env.template\n*.pem\n*.key\n*.p12\n*.pfx\n*.jks\n*.keystore\nid_rsa\nid_dsa\nid_ecdsa\nid_ed25519\ncredentials.json\nclient_secret*.json\nservice-account*.json\n.npmrc\n.pypirc\n.netrc\n.git-credentials\n.htpasswd\n*.local.settings.json\nsecrets/\n.secrets/",
  "files": "cmd/api/main.go\ninternal/store/store.go\ninternal/store/store_test.go\ngo.mod\ngo.sum\nMakefile\nDockerfile\nREADME.md\nbin/api\ntmp/main\n.air.toml\ncoverage.out\ndeploy/prod.tfvars\ndeploy/main.tf\nconfig/service-account.json\nvendor/github.com/lib/pq/conn.go\n.env.example\n.env",
  "files_note": "",
  "tracked": "no",
  "findings": "{\"secrets_open\":[\"deploy/prod.tfvars\"],\"hidden\":[],\"ignored_count\":3}"
}

Reply:

```json
{
  "add": [
    {"pattern": "*.tfvars", "reason": "Terraform variable files usually hold environment secrets and are not covered by the secrets block.", "example": "deploy/prod.tfvars"},
    {"pattern": "bin/", "reason": "Compiled binaries are build output and are rebuilt from source.", "example": "bin/api"},
    {"pattern": "tmp/", "reason": "Live-reload tools write temporary build output here; it is local-only.", "example": "tmp/main"}
  ],
  "untrack": [],
  "keep": [],
  "notes": [
    "deploy/prod.tfvars is not ignored yet: add *.tfvars and, if it was ever committed, rotate any secret inside it.",
    "vendor/ is not ignored. Commit it only if you build with go mod vendor; otherwise add vendor/ and rely on go.sum."
  ]
}
```

On the page, this reply adds *.tfvars, bin/ and tmp/, each matching one of the listed files, and the secret-looking deploy/prod.tfvars is ignored afterwards.

Errors

HTTPWhat to do
401The token is missing, expired or a guest token on a run. Get a personal token on the token page.
402The balance is below what the run reserves. Top up at skillsafe.ai/account/billing.
400The body is not a JSON object of the fields above.
429Wait and retry with the same Idempotency-Key.

Step 1 — a tiny client helper

One function that sends JSON and unwraps the {data, error} envelope.

BASE="https://api.skillsafe.ai/v1/app-api"
TOKEN="paste-your-token-here"   # from https://gitignore-generator.skillsafe.ai/tokens.html
api() { # api METHOD PATH [JSON-BODY]
  curl -s -X "$1" "$BASE$2" -H "Content-Type: application/json" \
    ${TOKEN:+-H "Authorization: Bearer $TOKEN"} ${3:+--data "$3"}
}

Step 2 — a token

A guest token is enough for /me and /estimate. A run is metered, so it needs your personal token: sign in on the token page and copy it.

# a guest token (enough for /me and /estimate); a run needs your personal token from /tokens.html
TOKEN=$(curl -s -X POST "$BASE/guest" -H "Content-Type: application/json" -d '{"slug":"gitignore-generator"}' | jq -r '.data.token')

Step 3 — who am I, and my balance

subject_type is guest or user; credits is the balance (1 credit = $0.0001).

api GET /me | jq '.data | {subject_type, credits}' 

Step 4 — price a run for free

/estimate charges nothing and starts no job. hold_credits is the amount reserved while a run is in flight, not the price; the run is charged what it uses.

# input.json: the run input object - {"task": "review", "stack": "Go, Linux", "gitignore": "...", "files": "...", "files_note": "", "tracked": "no", "findings": "{}"}
api POST /estimate "$(cat input.json)" | jq '.data | {hold_credits, min_credits, model, model_alias, markup_bps, warnings}' 

Step 5 — run it and wait for the job

Send an Idempotency-Key derived from the input: a retry with the same key is never billed twice.

KEY="gitignore-generator:review:$(shasum -a 256 input.json | cut -c1-16):a1"
JOB=$(curl -s -X POST "$BASE/run" -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" \
  -H "Idempotency-Key: $KEY" --data @input.json | jq -r '.data.job_id')
while :; do
  J=$(api GET "/jobs/$JOB"); S=$(echo "$J" | jq -r '.data.status')
  case "$S" in succeeded|failed|cancelled) break;; esac; sleep 2
done
echo "$J" | jq -r '.data.output.output' > reply.json   # one JSON object: add, untrack, keep, notes
echo "$J" | jq '.data | {charged_credits, truncated}' 

Step 6 — or stream it

/run-stream sends Server-Sent Events while the job runs and the finished job at the end.

# Server-Sent Events: tick/delta events while the job runs, then a final event with the job
curl -N -s -X POST "$BASE/run-stream" -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" \
  -H "Idempotency-Key: gitignore-generator:review:$(shasum -a 256 input.json | cut -c1-16):a1" --data @input.json