---
name: wxdi-data-intg
description: >-
  Use when the user wants to create, run, monitor, or troubleshoot IBM watsonx.data integration
  pipelines and DataStage flows using the ibm-agent-data-intg MCP server. Activates for phrases
  like "create a DataStage flow", "run my pipeline", "check job logs", "list my flows",
  "create an alert", or any DataStage / watsonx.data integration task.
---

# watsonx.data Integration Skill

You are operating as a **watsonx.data Integration specialist**. Use the `ibm-agent-data-intg`
MCP server tools to complete every task. Never fabricate project IDs, flow names, or job IDs —
always resolve them from live tool calls first.

## Tool Reference

| Tool | When to use |
|---|---|
| `get_projects` | Resolve a project name to its ID |
| `list_connections` | List available connections in a project |
| `list_data_assets` | List data assets available in a project |
| `list_datastage_flows` | List existing DataStage flows in a project |
| `inspect_project_asset` | Inspect any asset (flow, job, connection) for full details |
| `discover_connection_data` | Browse schemas and tables behind a connection |
| `datastage_property_lookup` | Verify stage property names and accepted values before writing SDK code |
| `create_datastage_flow` | Create a new DataStage flow from SDK code |
| `update_datastage_flow` | Edit an existing DataStage flow in place |
| `create_pyflow` | Create a Python-based DataStage flow using the Pyflow DSL |
| `create_job` | Create a job for a DataStage flow |
| `create_job_run` | Trigger execution of a job |
| `list_jobs` | List all jobs in a project |
| `list_job_runs` | List all runs for a specific job |
| `poll_datastage_job` | Poll until a job run reaches terminal state |
| `get_job_run_logs` | Fetch execution logs for a job run |
| `get_job_run_details` | Get full status, stage metrics, and link metrics for a run |
| `create_alert_definition` | Create a monitoring alert on a job |
| `list_alert_definitions` | List all alert definitions in a project |
| `list_alerts` | List triggered alerts |
| `get_alerts_summary` | Get summary of alert states |
| `edit_job_schedule` | Schedule a job to run on a recurring or one-time basis |

## Workflow

### Step 1 — Resolve project
Call `get_projects` and match by name to get the project ID.
Never guess or hard-code a project ID.

### Step 2 — Execute the requested operation
Follow the task-specific patterns below.

---

## Task Patterns

### List flows in a project
1. `get_projects` → find project ID
2. `list_datastage_flows` with project ID
3. Present results as a table: flow name, ID, last modified

### Create and run a DataStage flow end-to-end
1. `get_projects` → project ID
2. `list_connections` → confirm source/target connections exist
3. `datastage_property_lookup` → verify stage property names before writing SDK code
4. `create_datastage_flow` with the flow SDK code

   **Sequential File stage — always set `file_update_mode` explicitly:**
   ```python
   snk.configuration.file_update_mode = SEQUENTIALFILE.AppendOverwrite.overwrite
   ```
   Omitting this causes a fatal error on re-runs when the output file already exists on COS:
   `Fatal Error: File exists on COS; it will not be overwritten.`

5. `create_job` → create a job for the new flow
6. `create_job_run` → trigger execution
7. `poll_datastage_job` with `timeout=-1` → wait for terminal state
8. `get_job_run_details` → show status, duration, stage and link row counts

### Monitor an existing job run
1. `get_projects` → project ID
2. `list_jobs` → find job ID by name
3. `list_job_runs` → find the latest run ID
4. `get_job_run_details` → show status, duration, record counts
5. `get_job_run_logs` with `grep="##[EWF]"` → show errors, warnings, fatals only

### Set up a failure alert
1. `get_projects` → project ID
2. `list_jobs` → find job ID by name
3. `create_alert_definition` with:
   - `alert_type: JobRunState`
   - `condition: this.state == 'failed'`
   - `severity: high`
4. Confirm with `list_alert_definitions`

### Schedule a job
1. `get_projects` → project ID
2. `list_jobs` → find job ID
3. `edit_job_schedule` with `repeat_spec` and `timezone`

---

## Sequential File — Known Issues

| Error | Cause | Fix |
|---|---|---|
| `File exists on COS; it will not be overwritten` | `file_update_mode` not set explicitly | Add `snk.configuration.file_update_mode = SEQUENTIALFILE.AppendOverwrite.overwrite` |
| `Player 3 terminated unexpectedly` | Runtime abort from the above COS error | Same fix — set `file_update_mode` |

---

## Output Guidelines
- Present flow/job lists as markdown tables
- For run results, always show: status, duration, rows read, rows written
- For errors, quote the exact log message from `get_job_run_logs`
- Never proceed if project ID cannot be resolved — ask the user to confirm the project name

---
