Skip to content
Skills Library
DevOps & cloud · Tool integration

sn

/sn

Run ServiceNow operations through the `sn` CLI — read and write incidents, changes, problems, requests, CMDB CIs, catalog items, attachments, journal comments, update sets and ATF runs against the user's instance. Use whenever the user says sn, ServiceNow or SNOW, names an instance, pastes a record number (INC…, CHG…, RITM…, PRB…, TASK…), asks to look up or file or update a ticket, wants live record updates, or asks a question whose answer lives in a ServiceNow table.

Licence
MIT
Last repository change
26.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
5
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 26.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Run ServiceNow operations through the `sn` CLI — read and write incidents, changes, problems, requests, CMDB CIs, catalog items, attachments, journal comments, update sets and ATF runs against the user's instance. Use whenever the user says sn, ServiceNow or SNOW, names an instance, pastes a record number (INC…, CHG…, RITM…, PRB…, TASK…), asks to look up or file or update a ticket, wants live record updates, or asks a question whose answer lives in a ServiceNow table.

Original author description

Run ServiceNow operations through the `sn` CLI — read and write incidents, changes, problems, requests, CMDB CIs, catalog items, attachments, journal comments, update sets and ATF runs against the user's instance. Use whenever the user says sn, ServiceNow or SNOW, names an instance, pastes a record number (INC…, CHG…, RITM…, PRB…, TASK…), asks to look up or file or update a ticket, wants live record updates, or asks a question whose answer lives in a ServiceNow table.

How it works

  1. The one dangerous silent failure
  2. Shape traps — where the obvious jq returns nothing
  3. Exit codes and permission failures
  4. Values that don't round-trip
  5. Working as an agent
  6. Where to go next
Original SKILL.md headings · 126 lines, 1,189 words
SKILL.md preview
---
name: sn
description: Run ServiceNow operations through the `sn` CLI — read and write incidents, changes, problems, requests, CMDB CIs, catalog items, attachments, journal comments, update sets and ATF runs against the user's instance. Use whenever the user says sn, ServiceNow or SNOW, names an instance, pastes a record number (INC…, CHG…, RITM…, PRB…, TASK…), asks to look up or file or update a ticket, wants live record updates, or asks a question whose answer lives in a ServiceNow table.
---

# sn — ServiceNow from the command line

API data is JSON by default, with stable exit codes and JSON runtime errors on stderr.
Warnings and diagnostics can share stderr. Commands never prompt when stdin isn't a terminal. `sn <group> --help` is accurate and complete — read it for syntax.
This file covers only what the binary can't tell you: how the *instance* misleads you.

## The one dangerous silent failure

**ServiceNow can drop an invalid query term and apply only the remaining terms**,
returning more records than you intended with exit 0. If no valid filter remains, the
result can cover the whole table. Behavior also depends on instance configuration.

Check field names with `sn schema` and inspect returned values before making a decision
or write that depends on a filter. Compare counts to catch a suspiciously broad result;
`sn aggregate <table> --count` is one request without record rows:

```bash
sn aggregate incident --count                                        # 70  baseline
sn aggregate incident --count -q "assigned_to.name=Abel Tuter"       # 0   term survived
sn aggregate incident --count -q "assigned_two.name=Abel Tuter"      # 70  typo, dropped
```

Equal counts are a clue, not proof: a valid filter can match every record, and a
partly invalid query can still narrow the result.

**An empty result needs a check too.** "Nothing matched" and "my query broke"
look identical, so show the query *can* match — confirm the entity exists, or run the same
shape against a value you know is there.

`sn change list` surfaces ignored fields when the API reports them: a dropped term is a stderr warning naming it
(`sn: warning: ServiceNow ignored query field(s): assigned_two`). The full account — the
query the instance actually ran — is the `__meta` element kept under `--output raw`.

**Trust the CLI's own defenses rather than working around them.** `sn variables set` refuses
unknown names before writing, `sn cmdb` stringifies numeric attributes for you, `sn ping`
/ `sn user me` fail closed rather than naming a stranger, and a `table:number` record
reference that cannot be resolved errors instead of matching an arbitrary row. Those traps
are already shut.

## Shape traps — where the obvious jq returns nothing

Silent: `jq` prints empty and exits 0, so a wrong path reads as "no data".

| Command | The obvious path | The real path |
|---|---|---|
| `schema tables` | `.name` (always null) | **`.value`** |
| `schema columns` | `.default_value`, `.choice_field` | **`.default`**, and `type=="choice"` with options in **`.choices[]`** |
| `change *` | `.number` | **`.number.value`** — the Change API wraps *every* field as `{display_value, value}`; `state.value` is a float (`-5.0`) |
| `change nextstates` | a list of `{value,label}` | three keys: `available_states`, `state_label`, **`state_transitions`** (conditions + `transition_available`) |
| `cmdb get` | `.name` | **`.attributes.name`** — top level is only `attributes` + relations |
| `sn get` | `.number` | **`.record.number`** — top level is `{table, sys_id, record, variables, journal}` |
| `aggregate --group-by` | `.stats.groupby_fields` | top level becomes an **array**; `groupby_fields` is a **sibling** of `stats` |
| `aggregate --sum-fields` | `.stats.sum` | **`.stats.sum.<field>`** — sum/avg/min/max nest per field |
| `aggregate --count` | a number | a **string**: `"70"`; `gr --count` instead returns `{count: 70}` |
| `watch` | every line is an event | a line with **`sn_watch`** is a gap marker |

## Exit codes and permission failures

`0` ok · `1` usage/config · `2` instance refused or couldn't answer · `3` network/transport ·
`4` auth. Branch on the code first, parse stdout second. `sn_error` on stderr carries
ServiceNow's own error body — read it and self-correct instead of retrying blind.

**Exit 4 does not always mean "log in again."** Both 401 and 403 map to it. A successful
`sn ping` confirms that its probes worked, but another endpoint can still reject the
request because of roles, ACLs, or API access policies. A failing ping can also be a
network or configuration error. Check the exit code and error details before retrying.
`sn doctor --need-role <role>` names a missing role. Don't test roles with
`getMatchingRoles` or `gs.hasRole` yourself: under admin they answer yes to any name,
real or not.

`status_code` may be absent on exit 2 (a failure reported inside a 200). Test for the key,
don't default it.

## Values that don't round-trip

`--display-value` **defaults to `true`** on `table`, `get`, `gr`, `change`, `aggregate`, and `scores`, so you
get labels — and dates localized to the caller's timezone. A localized date fed back into
`--query` will not match. When a value will be *used* rather than shown, read it with
`--display-value false`.

## Working as an agent

- **Ask the instance before guessing a field name.** `sn schema tables --filter X` →
  `sn schema columns X --writable` → `sn schema choices X <field>`. A guessed name is how you
  land in the dropped-term case above.
- **Bound every watch** (`--max-events` / `--duration` / `--idle-timeout`), and note it
  requires `-q`; there is no bare "watch this table" form.
- **`updateset back-out` and `app rollback` deserve a human.** They can affect
  many configuration records. Establish the target and intended reversal from the user's
  request before running either command.
- **Pipe secrets** (`--password-stdin`, `--client-secret-stdin`, `--api-key-stdin`,
  `--token-stdin`); argv is visible to `ps`.
- **Prefer `sn profile add` over `sn init`** — it emits JSON, never prompts off a TTY, and
  leaves `default_profile` alone.
- **Authorization-code login needs a person** — `sn profile login` opens a browser and waits
  for authorization. `client_credentials`, `jwt_bearer`, and API keys (`--auth apikey`)
  support headless setup. Data commands never open a browser.
- **Journal has no write verb**: add a note with
  `sn table update incident <sys_id> --field work_notes="..."`.

## Where to go next

| File | Covers |
|---|---|
| `references/shapes-queries.md` | encoded-query hazards, `^OR`/`^NQ` precedence, `INSTANCEOF`, dates, aggregates |
| `references/change.md` | Change Management: routing by type, state transitions, tasks, conflicts |
| `references/watch.md` | live AMB streams: event anatomy, gap markers, `--on-change` caveats |
| `references/cicd.md` | `app`/`updateset`/`atf`/`progress` — the async `--wait` contract |

Other surfaces are well covered by `--help`; a few notes worth having anyway: `sn api search
<term>` discovers what endpoints the instance actually publishes (use it before hand-writing
`sn raw`); `sn codesearch <term>` answers "where is X referenced in code" across every
script table and scope in one call (rows are ACL-filtered, so a non-admin sees few or none);
`sn gr <table> -f number,caller_id.manager.email` reads dot-walked reference fields
in one round trip without writing GraphQL (`--count` for just the match count). Both
`sn graphql` and `sn gr` map GraphQL errors to exit 2 even under HTTP 200; only
`sn graphql` emits partial `data` on failure. `sn raw` has no confirmation guard,
including for DELETE; `sn attachment download --out` stages and renames, so a
failed download never leaves a truncated file, and reports `{"path","size"}`; `sn flow get <flow>
--outline` is the compact view of a Flow Designer model (the full one runs to hundreds of KB,
and each read takes tens of seconds); `sn identify
query` shows what the IRE *would* match before `create-update` writes; `sn catalog
item-variables` names what an order must carry, and the cart is server-side state that
survives a failed run.
Files in this package (5)
  • SKILL.md 8 KB
  • references/change.md 3 KB
  • references/cicd.md 2 KB
  • references/shapes-queries.md 4 KB
  • references/watch.md 4 KB

Versions

RepositoryScoreLicence
This page · tehubersheezy/servicenow-cli100MIT
tehubersheezy/servicenow-cli100MIT

Identical content appears in 1 other GitHub folders. We show one copy with the highest score.

Database snapshot: 13.11.2026 · package version 40482baf7de4 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 1 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100servicenow-queue
    Use when you look up what is open for a person in ServiceNow. Call the instance as that user, list their incidents, problems, changes, and requests, and do not create a record from this list.
  • 100servicenow-cmdb
    Auditing the CMDB as a data model: CI class hierarchy, raw relationships, CMDB health scorecards, data quality (duplicates, orphans, staleness, missing fields) and CSDM 5 conformance. Use when the user mentions CMDB health, CMDB audit, data quality, duplicates, orphaned or stale…
  • 100servicenow-api
    Work with ServiceNow through its REST APIs, with emphasis on setting up API access correctly (service accounts, roles, ACLs, basic/OAuth/API-key auth) and on CMDB data. Use it whenever a task mentions ServiceNow, service-now.com, a PDI or dev instance, the Table API,…
  • 100servicenow-problems
    Use when you open or update a ServiceNow problem for the signed-in user. Relate the incidents that share a cause, record a workaround, and send the fix through a change.
  • 100servicenow-itsm-integration
    Integrates ServiceNow Incident, Change, and Problem management with engineering paging/incident tools (PagerDuty, Opsgenie) for ITIL-heavy enterprises that need an auditable, compliance-grade record alongside fast real-time paging — Table API incident sync, Change Request…
  • 100servicenow-itsm-configuration-validation
    Validates ServiceNow Incident/Change/Problem workflow, approval, and assignment-routing configuration before it blocks or misroutes a real incident — checking CMDB CI-to-team mappings for gaps, Emergency Change approval routing for actual reachability, sync-flow idempotency, and…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.