> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tensor9.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Built-In Commands

`cmdlib` is the open-source reference repository of operational
command templates that ship ready-to-register against any Tensor9 app.
Most teams start by registering it as a source, then layer their own
app-specific templates on top.

It lives at [github.com/tensor9ine/cmdlib](https://github.com/tensor9ine/cmdlib),
Apache 2.0 licensed.

<img src="https://mintcdn.com/tensor9/Q7wEl9vOj9lICJg4/images/diagrams/cmdlib-howitworks-dark.svg?fit=max&auto=format&n=Q7wEl9vOj9lICJg4&q=85&s=ed2364d810a1d1b03dafdaaf98ba5f59" className="block dark:hidden" alt="How to use cmdlib: register the repo as a source, browse the categories, submit any template like your own." width="820" height="200" data-path="images/diagrams/cmdlib-howitworks-dark.svg" />

<img src="https://mintcdn.com/tensor9/Q7wEl9vOj9lICJg4/images/diagrams/cmdlib-howitworks-light.svg?fit=max&auto=format&n=Q7wEl9vOj9lICJg4&q=85&s=610f14c85d0d999d1edd8a18c06f753c" className="hidden dark:block" alt="How to use cmdlib: register the repo as a source, browse the categories, submit any template like your own." width="820" height="200" data-path="images/diagrams/cmdlib-howitworks-light.svg" />

## Why use it

Three reasons to register `cmdlib` on day one:

1. **Common ops are already written.** Disk usage, top processes, pod
   restarts, EBS snapshots, Temporal workflow termination, etc. The
   templates declare appropriate `data_access` tags and permission
   tiers so your customers can review them quickly.
2. **Templates evolve from real ops incidents.** Bug fixes and new
   templates land via PR in the cmdlib repo and propagate to every
   install that re-syncs.
3. **They're good reference for your own templates.** When you write
   an app-specific template, the closest match in `cmdlib` is usually
   a good starting point. Browse the directory that matches your
   target (linux, k8s, aws, etc.) and copy the closest file.

## What's in it

Templates are organized by target environment. Each category is a
directory under `src/`; every `.tensor9.tf` file inside contributes
one template.

| Category         | Examples                                                                                                                                                                                                                                                                                                                                                                          | Use when                                                                 |
| ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
| `linux/`         | `disk-usage`, `top-processes`, `journalctl-tail`, `dmesg-tail`, `network-connections`, `host-info`, `read-file`, `tail-app-log`                                                                                                                                                                                                                                                   | Triaging a Linux appliance host. Read-only diagnostics.                  |
| `darwin/`        | `disk-usage`, `disk-list`, `top-processes`, `log-tail`, `pmset-status`, `launchd-list`, `system-profile`, `host-info`, `network-connections`, `read-file`, `tail-app-log`                                                                                                                                                                                                         | Triaging a macOS appliance host. Read-only diagnostics.                  |
| `k8s/`           | `list-pods`, `list-nodes`, `list-services`, `describe-pod`, `describe-deployment`, `tail-pod-logs`, `tail-deployment-logs`, `top-pods`, `top-nodes`, `get-events`, `list-stuck-pods`, `restart-deployment`, `restart-pods-by-label`, `scale-deployment`, `rollback-deployment`, `delete-pod`, `delete-failed-evicted-pods`, `drain-node`, `read-pod-file`, `read-deployment-file` | Standard SRE operations on the appliance's Kubernetes cluster.           |
| `aws/`           | `find-idle-instances`, `find-untagged-resources`, `find-unused-security-groups`, `list-public-s3-buckets`, `list-old-snapshots`, `rotate-iam-access-key`, `snapshot-ebs-volume`, `rds-snapshot`, `terminate-stopped-instances`                                                                                                                                                    | Direct AWS resource operations (EC2, EBS, S3, RDS, IAM).                 |
| `node/`          | `cpu-profile`, `heap-snapshot`, `event-loop-lag`, `gc-trace`, `open-handles`, `tail-stderr`, `npm-list`, `process-info`                                                                                                                                                                                                                                                           | Debugging a Node.js process inside the appliance.                        |
| `temporal/`      | `list-running-workflows`, `list-failed-workflows`, `describe-workflow`, `signal-workflow`, `reset-workflow`, `terminate-workflow`                                                                                                                                                                                                                                                 | Inspecting and intervening in Temporal workflows.                        |
| `orchestration/` | `pre-deploy-backup`, `snapshot-then-restart`, `snapshot-then-resize-volume`, `drain-then-terminate-node`, `rollout-restart-then-tail`                                                                                                                                                                                                                                             | Multi-step compositions that chain primitives from the other categories. |

Open the category-level `README.md` in the repo for the full per-file
inventory and the trade-off notes for each template.

## Registering it

```bash theme={null}
tensor9 ops template source create \
  --sourceType GitHub \
  --sourceUrl https://github.com/tensor9ine/cmdlib \
  --appName my-app \
  --sourceName cmdlib
```

Source registration walks every `.tensor9.tf` under `src/`, persists
each as a template prefixed with its parent directory name
(`linux/disk-usage.tensor9.tf` becomes `linux-disk-usage`, so it does
not collide with `darwin/disk-usage.tensor9.tf` which becomes
`darwin-disk-usage`).

You can scope to a subset of categories with `--dirs`:

```bash theme={null}
# Only the Kubernetes and AWS templates
tensor9 ops template source create \
  --sourceType GitHub \
  --sourceUrl https://github.com/tensor9ine/cmdlib \
  --appName my-app \
  --sourceName cmdlib-k8s-aws \
  --dirs src/k8s,src/aws
```

After registration, see [Git template
libraries](/fundamentals/operations/sources) for the resync /
upgrade / retire commands as the upstream evolves.

## Reading a template

Every file is a small standalone Terraform template. The canonical
shape is documented in [Authoring
templates](/fundamentals/operations/templates); `linux/disk-usage.tensor9.tf`
is the example used there. Open any file in the repo to see the same
pattern applied to a different operation.

## Contributing

`cmdlib` accepts pull requests. Useful contributions tend to fall in
one of three buckets:

* **A new template for an existing category.** Follow the conventions
  in that category's `README.md`. Match the existing data-access tags
  and permission-tier choices unless you have a reason not to.
* **A new category.** Discuss in an issue first; new categories
  imply new conventions and shouldn't be added without coordination.
* **A bug fix or hardening change to an existing template.** Include
  a one-line reproducer in the PR description so reviewers can
  confirm the fix.

Templates that mutate state (`ReadWrite` or `Admin` tier) require an
extra reviewer and a dry-run plan in the PR description. The bias is
toward conservative defaults: prefer `ReadOnly` unless the operation
genuinely cannot be expressed that way.

## License

Apache 2.0. You can fork the repo, register your fork as a source
instead of upstream, and curate the template set that matches your
deployment shape.

## Related

* [Authoring templates](/fundamentals/operations/templates): the file format used by every `cmdlib` template.
* [Git template sources](/fundamentals/operations/sources): how to keep your registered `cmdlib` source up to date as the upstream evolves.
