Oracle DBA - Common Foundation
This skill defines the contracts that every oracle-dba-<domain> skill MUST obey.
It ships no end-user task of its own; it is imported by all others.
Target environment (ground truth):
- OS: Linux (
.sh) AND Windows (.ps1) — both produced for every OS-level task.
- Oracle: 19c and 23ai (Enterprise Edition). Topology: single_instance and Data Guard. On-prem.
- In-DB work: SQLcl MCP server, saved named connection
dba_ai_conn.
- Secrets: Oracle Wallet / external password store. Never plaintext.
1. Connection contract
All in-database actions go through the SQLcl MCP server using the saved named
connection dba_ai_conn.
Rules:
- Connect ONLY by name:
sql -name dba_ai_conn (CLI) or the MCP connect/run-sql
tools targeting the saved connection dba_ai_conn. The connection's credentials
live in the SQLcl/Oracle Wallet store — they are resolved at connect time.
- Never connect as
SYS or SYSTEM unless a specific runbook explicitly
requires SYSDBA (e.g. media recovery, STARTUP MOUNT). When a runbook needs
SYSDBA it must say so and the operator supplies that privileged connection
interactively — it is never the default and never auto-executed.
- Never hardcode usernames, passwords, connect strings, or wallet paths in
SQL, scripts, argv, environment variables, or files.
- The helper
connect_db (in scripts/lib.sh / scripts/lib.ps1) is the only
sanctioned way to open a session. It refuses to run if a password-looking value
is passed to it.
Privilege model: dba_ai_conn is a least-privilege DBA-role account. SYSDBA is an
exception path, gated behind T3 runbooks.
2. Secret resolution (Oracle Wallet — no plaintext ever)
Secrets resolve from the Oracle Wallet / external password store only.
- DB auth: the connect string in
dba_ai_conn maps to a wallet credential
(mkstore/external password store or auto-login wallet cwallet.sso).
SQLcl resolves it; no password is ever typed or stored by us.
- For any other secret (e.g. backup catalog, OS account for
rman), use the
wallet entry referenced by alias — never the literal secret.
- FORBIDDEN, with no exceptions:
- passwords on the command line (
sql user/pass@db, rman target sys/pass),
- passwords in environment variables,
- passwords written to log files, temp files, or config files,
echo-ing secrets, or interpolating them into structured log lines.
connect_db and log_event actively scrub/refuse anything that looks like a
credential. If you find yourself needing a plaintext secret, STOP and add a
wallet entry instead.
3. Structured logging contract
Every script emits one structured log line per significant event via log_event.
Format — key=value pairs, space-separated, machine-greppable:
ts=<ISO8601-UTC> skill=<skill-name> task=<task-id> tier=<T1|T2|T3> dry_run=<true|false> outcome=<ok|noop|fail|blocked> [key=value ...] msg="<free text>"
ts is ISO-8601 UTC (e.g. 2026-06-03T14:22:05Z).
outcome vocabulary: ok (acted, success), noop (already-done / idempotent
skip), fail (error), blocked (guard refused: missing --execute or approval token).
- Extra metrics ride along as additional
key=value pairs or via emit_metric.
- Secrets are NEVER logged.
log_event redacts values that match credential patterns.
Canonical log paths
- Linux:
/var/log/oracle-dba/<skill>/
- Windows:
C:/ProgramData/oracle-dba/logs/<skill>/
<skill> is the domain skill name (e.g. backup, recovery). The log file is
<skill>.log inside that directory (e.g. /var/log/oracle-dba/backup/backup.log).
Helpers create the directory if missing (idempotent).
4. Exit-code convention
0 is the ONLY success code. All failure modes use documented non-zero codes so
callers and schedulers can branch deterministically. Never swallow an error.
| Code |
Name |
Meaning |
| 0 |
OK |
Action succeeded, or idempotent no-op (already done). |
| 1 |
ERR_GENERAL |
Unclassified failure. |
| 2 |
ERR_USAGE |
Bad/missing arguments, unknown flag. |
| 3 |
ERR_PRECHECK |
Precheck failed; action not attempted. |
| 4 |
ERR_CONNECT |
Could not open dba_ai_conn / DB unreachable. |
| 5 |
ERR_DRYRUN_GUARD |
T2+ action invoked without --execute (dry-run is default). |
| 6 |
ERR_APPROVAL |
T3 action invoked without a valid approval token/ticket. |
| 7 |
ERR_POSTCHECK |
Action ran but postcheck verification failed. |
| 8 |
ERR_SECRET |
Plaintext-secret usage detected / wallet resolution failed. |
Exit codes 5 and 6 are "blocked" outcomes, not crashes — they are the safety
guards firing as designed. The helper library exports these as named constants.
5. Risk-tier banner + autonomy policy
Every .sh/.ps1 MUST begin (after the shebang) with a one-line tier banner
comment so a human can see the blast radius at a glance:
# TIER: T2 | REVERSIBLE | requires --dry-run preview (default) ; --execute to act
Banner grammar: # TIER: <T1|T2|T3> | <OBSERVE|REVERSIBLE|DESTRUCTIVE> | <mechanism note>
At runtime the script also prints the banner to stderr and records tier= in logs.
Autonomy policy (hard rule; max self-execute tier = T2)
| Tier |
Class |
Self-execute? |
Required guards |
| T1 |
Observe (read-only) |
Yes, freely |
Structured logging. |
| T2 |
Reversible / low blast-radius |
Yes, gated |
--dry-run is DEFAULT; explicit --execute required to act; full logging; postcheck. |
| T3 |
Destructive / recovery / HA / structural |
NEVER |
require_approval_token (human token/ticket) AND default to emitting a runbook. |
- T1: monitoring, health/space/AWR reports, backup-status queries.
- T2: scheduled backups,
RMAN CONFIGURE, crosscheck+delete WITHIN retention,
Data Pump export, create restore point, gather stats.
- T3: any restore/recover (PITR, media, TSPITR, block, DR, cross-platform),
Flashback Database, switchover/failover, drops.
When in doubt, runbook. If a task cannot be made safe at or below T2, do not
ship an auto-executing script — downgrade it to a printed runbook for a human.
6. How to use this from a domain skill
- Read
references/conventions.md and follow the canonical SKILL.md template verbatim.
- In every script, source the shared helpers — do not reimplement them:
- Bash:
. "$(dirname "$0")/../../_common/scripts/lib.sh"
- PowerShell:
. "$PSScriptRoot/../../_common/scripts/lib.ps1"
- Use:
connect_db, log_event, require_dry_run, require_approval_token,
precheck, postcheck, emit_metric.
- Record any 19c-vs-23ai behavioural delta in your skill's
references/version-notes.md.
1---2name: oracle-dba-common3description: MANDATORY shared foundation for EVERY oracle-dba skill. Import this BEFORE writing or running any DBA task. It is the single source of truth for: the SQLcl MCP connection contract (saved named connection "dba_ai_conn" only — never SYS/SYSTEM, never hardcoded creds), secret resolution from the Oracle Wallet / external password store (NO plaintext in argv/env/files EVER), the structured logging contract and canonical log paths, the exit-code convention (0=ok, documented non-zero codes), and the risk-tier banner + autonomy policy (T1 observe / T2 reversible-with-dry-run / T3 destructive-runbook-only). Do NOT reinvent connection, logging, dry-run, or approval-token logic in any other skill — source _common/scripts/lib.sh or lib.ps1 and follow this contract verbatim.4---56# Oracle DBA - Common Foundation78This skill defines the contracts that every `oracle-dba-<domain>` skill MUST obey.9It ships no end-user task of its own; it is imported by all others.1011Target environment (ground truth):12- OS: Linux (`.sh`) AND Windows (`.ps1`) — both produced for every OS-level task.13- Oracle: 19c and 23ai (Enterprise Edition). Topology: single_instance and Data Guard. On-prem.14- In-DB work: SQLcl MCP server, saved named connection `dba_ai_conn`.15- Secrets: Oracle Wallet / external password store. Never plaintext.1617---1819## 1. Connection contract2021All in-database actions go through the **SQLcl MCP server** using the saved named22connection **`dba_ai_conn`**.2324Rules:251. Connect ONLY by name: `sql -name dba_ai_conn` (CLI) or the MCP `connect`/`run-sql`26 tools targeting the saved connection `dba_ai_conn`. The connection's credentials27 live in the SQLcl/Oracle Wallet store — they are resolved at connect time.282. **Never** connect as `SYS` or `SYSTEM` unless a specific runbook explicitly29 requires `SYSDBA` (e.g. media recovery, `STARTUP MOUNT`). When a runbook needs30 SYSDBA it must say so and the operator supplies that privileged connection31 interactively — it is never the default and never auto-executed.323. **Never** hardcode usernames, passwords, connect strings, or wallet paths in33 SQL, scripts, argv, environment variables, or files.344. The helper `connect_db` (in `scripts/lib.sh` / `scripts/lib.ps1`) is the only35 sanctioned way to open a session. It refuses to run if a password-looking value36 is passed to it.3738Privilege model: `dba_ai_conn` is a least-privilege DBA-role account. SYSDBA is an39exception path, gated behind T3 runbooks.4041---4243## 2. Secret resolution (Oracle Wallet — no plaintext ever)4445Secrets resolve from the **Oracle Wallet / external password store** only.4647- DB auth: the connect string in `dba_ai_conn` maps to a wallet credential48 (`mkstore`/external password store or auto-login wallet `cwallet.sso`).49 SQLcl resolves it; no password is ever typed or stored by us.50- For any other secret (e.g. backup catalog, OS account for `rman`), use the51 wallet entry referenced by alias — never the literal secret.52- FORBIDDEN, with no exceptions:53 - passwords on the command line (`sql user/pass@db`, `rman target sys/pass`),54 - passwords in environment variables,55 - passwords written to log files, temp files, or config files,56 - `echo`-ing secrets, or interpolating them into structured log lines.57- `connect_db` and `log_event` actively scrub/refuse anything that looks like a58 credential. If you find yourself needing a plaintext secret, STOP and add a59 wallet entry instead.6061---6263## 3. Structured logging contract6465Every script emits one structured log line per significant event via `log_event`.6667Format — key=value pairs, space-separated, machine-greppable:6869```70ts=<ISO8601-UTC> skill=<skill-name> task=<task-id> tier=<T1|T2|T3> dry_run=<true|false> outcome=<ok|noop|fail|blocked> [key=value ...] msg="<free text>"71```7273- `ts` is ISO-8601 UTC (e.g. `2026-06-03T14:22:05Z`).74- `outcome` vocabulary: `ok` (acted, success), `noop` (already-done / idempotent75 skip), `fail` (error), `blocked` (guard refused: missing `--execute` or approval token).76- Extra metrics ride along as additional `key=value` pairs or via `emit_metric`.77- Secrets are NEVER logged. `log_event` redacts values that match credential patterns.7879### Canonical log paths80- Linux: `/var/log/oracle-dba/<skill>/`81- Windows: `C:/ProgramData/oracle-dba/logs/<skill>/`8283`<skill>` is the domain skill name (e.g. `backup`, `recovery`). The log file is84`<skill>.log` inside that directory (e.g. `/var/log/oracle-dba/backup/backup.log`).85Helpers create the directory if missing (idempotent).8687---8889## 4. Exit-code convention9091`0` is the ONLY success code. All failure modes use documented non-zero codes so92callers and schedulers can branch deterministically. Never swallow an error.9394| Code | Name | Meaning |95|------|-------------------|----------------------------------------------------------------|96| 0 | OK | Action succeeded, or idempotent no-op (already done). |97| 1 | ERR_GENERAL | Unclassified failure. |98| 2 | ERR_USAGE | Bad/missing arguments, unknown flag. |99| 3 | ERR_PRECHECK | Precheck failed; action not attempted. |100| 4 | ERR_CONNECT | Could not open `dba_ai_conn` / DB unreachable. |101| 5 | ERR_DRYRUN_GUARD | T2+ action invoked without `--execute` (dry-run is default). |102| 6 | ERR_APPROVAL | T3 action invoked without a valid approval token/ticket. |103| 7 | ERR_POSTCHECK | Action ran but postcheck verification failed. |104| 8 | ERR_SECRET | Plaintext-secret usage detected / wallet resolution failed. |105106Exit codes 5 and 6 are "blocked" outcomes, not crashes — they are the safety107guards firing as designed. The helper library exports these as named constants.108109---110111## 5. Risk-tier banner + autonomy policy112113Every `.sh`/`.ps1` MUST begin (after the shebang) with a one-line tier banner114comment so a human can see the blast radius at a glance:115116```117# TIER: T2 | REVERSIBLE | requires --dry-run preview (default) ; --execute to act118```119120Banner grammar: `# TIER: <T1|T2|T3> | <OBSERVE|REVERSIBLE|DESTRUCTIVE> | <mechanism note>`121122At runtime the script also prints the banner to stderr and records `tier=` in logs.123124### Autonomy policy (hard rule; max self-execute tier = T2)125126| Tier | Class | Self-execute? | Required guards |127|------|------------------------------------|---------------|---------------------------------------------------------------------------------|128| T1 | Observe (read-only) | Yes, freely | Structured logging. |129| T2 | Reversible / low blast-radius | Yes, gated | `--dry-run` is DEFAULT; explicit `--execute` required to act; full logging; postcheck. |130| T3 | Destructive / recovery / HA / structural | NEVER | `require_approval_token` (human token/ticket) AND default to emitting a runbook. |131132- **T1**: monitoring, health/space/AWR reports, backup-status queries.133- **T2**: scheduled backups, `RMAN CONFIGURE`, crosscheck+delete WITHIN retention,134 Data Pump export, create restore point, gather stats.135- **T3**: any restore/recover (PITR, media, TSPITR, block, DR, cross-platform),136 Flashback Database, switchover/failover, drops.137138**When in doubt, runbook.** If a task cannot be made safe at or below T2, do not139ship an auto-executing script — downgrade it to a printed runbook for a human.140141---142143## 6. How to use this from a domain skill1441451. Read `references/conventions.md` and follow the canonical `SKILL.md` template verbatim.1462. In every script, source the shared helpers — do not reimplement them:147 - Bash: `. "$(dirname "$0")/../../_common/scripts/lib.sh"`148 - PowerShell: `. "$PSScriptRoot/../../_common/scripts/lib.ps1"`1493. Use: `connect_db`, `log_event`, `require_dry_run`, `require_approval_token`,150 `precheck`, `postcheck`, `emit_metric`.1514. Record any 19c-vs-23ai behavioural delta in your skill's `references/version-notes.md`.