CLI workflow

Analyze CSV Files with a CLI

Profile the file, query it locally with DuckDB or csvkit, and save the analysis separately from the source.

Data and textLocal write

Prepare tools, authentication, and evidence first

Install the recommended tools, confirm minimum permissions, and keep compatibility separate from real execution records.

csvstatdocs-verified
Inspect, convert, query, and reshape CSV data with composable command-line utilities.

Recommended install

$ shell
pipx install csvkit
Authentication
No authentication for the base operation
Tested agents
No agent-specific execution record
Evidence status
docs-verified · Documentation checked 2026-07-10
Independent CLI execution
No independently executed version recorded
duckdbdocs-verified
Query local files and analytical data directly with fast SQL and structured exports.

Recommended install

$ shell
brew install duckdb
Authentication
No authentication for the base operation
Tested agents
No agent-specific execution record
Evidence status
docs-verified · Documentation checked 2026-07-10
Independent CLI execution
No independently executed version recorded
jqverified
Parse, filter, validate, and transform JSON locally with deterministic output.

Recommended install

$ shell
brew install jq
Authentication
No authentication for the base operation
Tested agents
No agent-specific execution record
Evidence status
verified · Documentation checked 2026-07-10
Independent CLI execution
jq-1.7.1-apple · 4 checks

Copy or download this workflow Skill

The Skill includes input and output contracts, recommended tools, approval points, rollback, and evidence boundaries. Review it against the active environment before saving.

analyze-csv-SKILL.md
---
name: analyze-csv-workflow
description: "Profile the file, query it locally with DuckDB or csvkit, and save the analysis separately from the source."
---

# Analyze CSV files

## Intended outcome

Answer a tabular data question with reproducible commands and clearly stated data-quality limits.

## Evidence boundary

- Tool status distinguishes `docs-verified` material from independent execution; the two are not interchangeable.
- The current registry does not attribute a tool execution to a particular agent, so compatible agents cannot be called tested agents.
- Reconfirm the target account, environment, version, and official documentation before execution.
- Never auto-execute an R2, R3, or confirmation-marked step; obtain explicit approval immediately before it runs.

## Recommended tools, installation, and authentication

- **csvkit** (evidence: `docs-verified`, docs checked: `2026-07-10`, no independently executed version recorded)
  - Install: `pipx install csvkit`
  - Authentication: not required for the base operation
  - Minimum permissions: No service credential is required; restrict filesystem and network access to the task.
- **DuckDB CLI** (evidence: `docs-verified`, docs checked: `2026-07-10`, no independently executed version recorded)
  - Install: `brew install duckdb`
  - Authentication: not required for the base operation
  - Minimum permissions: No service credential is required; restrict filesystem and network access to the task.
- **jq** (evidence: `verified`, docs checked: `2026-07-10`, independently tested version jq-1.7.1-apple recorded)
  - Install: `brew install jq`
  - Authentication: not required for the base operation
  - Minimum permissions: No service credential is required; restrict filesystem and network access to the task.

## Input contract

- CSV path
- analysis question
- delimiter and encoding assumptions
- sensitive-column policy

## Output contract

- Schema profile
- bounded query result
- summary table
- data-quality warnings

## Safe workflow

1. **Profile the file** — Inspect size, header, inferred types, nulls, and a small sample.
   - Input: Source CSV
   - Output: Schema and quality profile
   - Risk: `read-only`
   - Command: `duckdb -c "describe select * from read_csv_auto('input.csv')"`
2. **Run bounded analysis** — Execute explicit SELECT queries without attaching or writing an external database.
   - Input: Reviewed SQL and source file
   - Output: Query results in CSV or JSON
   - Risk: `read-only`
   - Command: `duckdb -csv -c "select category, count(*) from read_csv_auto('input.csv') group by 1 order by 2 desc"`
3. **Save a reproducible summary** — Record commands, assumptions, row counts, and warnings in a separate artifact.
   - Input: Results and profile
   - Output: Analysis report
   - Risk: `local-write`

## Ask before proceeding

- Uploading the dataset
- Overwriting or rewriting the source CSV
- Joining sensitive data or exporting row-level records

## Rollback

- Keep analysis outputs in a separate directory
- Delete temporary extracts containing sensitive fields
- Restore generated files from version control if they replace existing reports

## Official sources

- [DuckDB CLI documentation](https://duckdb.org/docs/stable/clients/cli/overview.html) — Official CLI documentation for querying local files and formatting results.
- [jq manual](https://jqlang.github.io/jq/manual/) — Official filters, input modes, exit status, and JSON transformation reference.

Outcome, inputs, and outputs

Define the result and evidence before the agent selects a command.

Goal

Answer a tabular data question with reproducible commands and clearly stated data-quality limits.

Required inputs

  • CSV path
  • analysis question
  • delimiter and encoding assumptions
  • sensitive-column policy

Expected outputs

  • Schema profile
  • bounded query result
  • summary table
  • data-quality warnings

Analyze CSV Files with a CLI: safe workflow

Run each step inside its stated boundary and verify the output before continuing.

Step 1Read only

Profile the file

Inspect size, header, inferred types, nulls, and a small sample.
Input
Source CSV
Output
Schema and quality profile
$ Profile the file
duckdb -c "describe select * from read_csv_auto('input.csv')"
Step 2Read only

Run bounded analysis

Execute explicit SELECT queries without attaching or writing an external database.
Input
Reviewed SQL and source file
Output
Query results in CSV or JSON
$ Run bounded analysis
duckdb -csv -c "select category, count(*) from read_csv_auto('input.csv') group by 1 order by 2 desc"
Step 3Local write

Save a reproducible summary

Record commands, assumptions, row counts, and warnings in a separate artifact.
Input
Results and profile
Output
Analysis report

Approval points and rollback

Pause at the listed decision points and keep recovery instructions beside the action.

Ask before these actions

  • Uploading the dataset
  • Overwriting or rewriting the source CSV
  • Joining sensitive data or exporting row-level records

Recovery plan

  • Keep analysis outputs in a separate directory
  • Delete temporary extracts containing sensitive fields
  • Restore generated files from version control if they replace existing reports

CLI, MCP, or API?

Choose the interface by execution location, identity, output contract, and permission boundary.

CLI

Best for local, repeatable analysis that keeps data on the machine.

MCP

Useful when the data lives in a governed analytics system with approved query tools.

API

Use when the dataset and analysis contract are provided by a shared service.

Recommended approach

Use DuckDB for SQL-shaped analysis and csvkit for lightweight CSV inspection and conversion.

Official evidence and references

Use these primary or upstream sources to verify current command behavior before acting.

DuckDB CLI documentation

Official CLI documentation for querying local files and formatting results.

jq manual

Official filters, input modes, exit status, and JSON transformation reference.

Questions before you run it

Will type inference always be correct?

No. Inspect inferred types and specify parsing options when dates, leading zeros, null markers, or mixed columns matter.

Should an agent load the CSV into production?

Not as part of analysis. Keep the default path local and read-only unless import is a separately approved task.

Related tools and guides

Browse sibling guides and choose the next page that best matches the active task.

Continue with tool evidence, a workflow, or a decision guide related to this task.

Continue with tool evidence, a workflow, or a decision guide related to this task.

Continue with tool evidence, a workflow, or a decision guide related to this task.

Inspect installation, authentication, structured output, command risk, and official evidence.

Inspect installation, authentication, structured output, command risk, and official evidence.