---
name: save-artifact
description: >
  Save an AI-generated artifact to the artifacts repository with structured metadata.
  Triggers: /save-artifact, "save this artifact", "store this artifact", "add to artifacts", "save to artifacts repo"
---

# save-artifact

Save an AI-generated artifact to the artifacts repository with structured metadata.

## Triggers

- `/save-artifact`
- "save this artifact"
- "store this artifact"
- "add to artifacts"
- "save to artifacts repo"

## Behavior

1. **Identify the artifact**: Determine what file/content to save (either just created, or user specifies a path)
2. **Collect metadata**: Gather required and optional fields
3. **Save the artifact**: Copy/write to `/Users/meain/dev/src/ai-artifacts/artifacts/`
4. **Update catalog**: Append a line to `/Users/meain/dev/src/ai-artifacts/artifacts.jsonl`
5. **Confirm**: Show the artifact name and key metadata fields

## Required Metadata

- **type**: File extension or type (html, markdown, bash, python, json, yaml, etc.)
- **created**: ISO 8601 timestamp (use current time)
- **agent**: Agent harness (fin, codex, claude-code, etc.) - infer from context

## Optional Metadata (ask if not obvious)

- **description**: Brief description of what this does
- **tags**: Array of tags for categorization
- **repository**: Source repo context if relevant
- **model**: LLM model used (claude-3.5-sonnet, etc.)
- **purpose**: Why this was created - the problem it solves
- **dependencies**: External tools/libraries required
- **session_id**: Agent session ID if available
- **related**: Related artifact filenames
- **url**: Public URL if deployed
- **archived**: false (default)

## Filename Strategy

- Use descriptive kebab-case names
- Include version suffix if this is an iteration (e.g., `dashboard-v2.html`)
- Avoid generic names like `output.html` or `script.sh`
- If user doesn't specify, suggest a name based on content/purpose

## Implementation Notes

- Append a single JSON line to `artifacts.jsonl` — include `filename` as the first field
- Use `jq -c` to produce compact JSON: `jq -cn '{filename: "...", type: "...", ...}'  >> artifacts.jsonl`
- For the `created` timestamp, use ISO 8601 format: `date -u +"%Y-%m-%dT%H:%M:%SZ"`
- If artifact with same filename already exists in the file, ask user whether to overwrite (remove old line, append new) or create versioned copy

## Example

User: "save this dashboard to artifacts"

```bash
# Copy file
cp dashboard.html /Users/meain/dev/src/ai-artifacts/artifacts/adx-metrics-dashboard.html

# Append to catalog
cd /Users/meain/dev/src/ai-artifacts
jq -cn '{filename: "adx-metrics-dashboard.html", type: "html", description: "Interactive dashboard for ADX query metrics", tags: ["visualization", "monitoring", "adx"], repository: "veeam/control-plane-backend", agent: "fin", model: "claude-3.5-sonnet", created: "2026-06-26T13:50:00Z", purpose: "Debug ADX query performance issues", session_id: "23051bf6-89b7-44cb-b19f-cd9019a967bc"}' >> artifacts.jsonl
```

Response: "Saved as `adx-metrics-dashboard.html` — interactive dashboard for ADX query metrics"
