> ## 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 BYOC 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.

![Register a GitHub source for your app, handle template-name conflicts, and inspect the imported versions and content hashes. Submit one selected template by ID or name; the command records its exact template ID, version and content hash. Registration does not authorize execution. Arrows show authoring and submission, not network traffic.](https://mintcdn.com/tensor9/U6vgXvfekfmP9LYQ/images/diagrams/cmdlib-registration-wide-dark.svg?fit=max\&auto=format\&n=U6vgXvfekfmP9LYQ\&q=85\&s=3e34ab902ec42d76e65296f2a715918d)

![Register a GitHub source for your app, handle template-name conflicts, and inspect the imported versions and content hashes. Submit one selected template by ID or name; the command records its exact template ID, version and content hash. Registration does not authorize execution. Arrows show authoring and submission, not network traffic.](https://mintcdn.com/tensor9/U6vgXvfekfmP9LYQ/images/diagrams/cmdlib-registration-wide-light.svg?fit=max\&auto=format\&n=U6vgXvfekfmP9LYQ\&q=85\&s=fd01711c4f12a732d688ec1d47ed99b0)

![Register a GitHub source for your app, handle template-name conflicts, and inspect the imported versions and content hashes. Submit one selected template by ID or name; the command records its exact template ID, version and content hash. Registration does not authorize execution. Arrows show authoring and submission, not network traffic.](https://mintcdn.com/tensor9/U6vgXvfekfmP9LYQ/images/diagrams/cmdlib-registration-stacked-dark.svg?fit=max\&auto=format\&n=U6vgXvfekfmP9LYQ\&q=85\&s=3b2c811b3ec3ecab25faecffb354f6f5)

![Register a GitHub source for your app, handle template-name conflicts, and inspect the imported versions and content hashes. Submit one selected template by ID or name; the command records its exact template ID, version and content hash. Registration does not authorize execution. Arrows show authoring and submission, not network traffic.](https://mintcdn.com/tensor9/U6vgXvfekfmP9LYQ/images/diagrams/cmdlib-registration-stacked-light.svg?fit=max\&auto=format\&n=U6vgXvfekfmP9LYQ\&q=85\&s=de457a15c7d462557673d000b46c7e8e)

Registration imports templates from the selected directories. A name conflict can fail, skip that file or use a renamed import, according to the selected policy. Inspect the imported version and content hash before submitting one command. Submission records the resolved template snapshot; it still follows the normal approval flow. Later Git changes require a separate diff and upgrade.

## 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. **Updates are explicit.** Use `tensor9 ops template source resync`
   to inspect upstream differences, then `tensor9 ops template source upgrade`
   to apply selected changes to imported templates. Each submitted command
   records the template ID, version and content hash resolved at submission;
   resync does not change that record.
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](https://docs.tensor9.com/byoc/fundamentals/operations/sources.md) 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](https://docs.tensor9.com/byoc/fundamentals/operations/templates.md); `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](https://docs.tensor9.com/byoc/fundamentals/operations/templates.md): the file format used by every `cmdlib` template.
* [Git template sources](https://docs.tensor9.com/byoc/fundamentals/operations/sources.md): how to keep your registered `cmdlib` source up to date as the upstream evolves.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.