Preview quoted CSV fields, row counts, and column headers.

Preview quoted CSV fields, row counts, and column headers.
Use it when: Read an exported dataset without launching a spreadsheet.

Screenshot of this mod's render tree in the fixture preview, with sample data. This is not a capture of the Claude Code application. How previews are made.
claude plugin marketplace add whyashthakker/awesome-claude-code-mods
claude plugin install csv-table@awesome-claude-code-mods
Run /reload-plugins in an existing session, then /csv-table. Use Tab and Enter to operate controls; Esc closes the pane. Terminal and Desktop Code tab supported; pane UI is unavailable in claude -p and the VS Code chat panel.
Try the source without installing:
claude --plugin-dir ./mods/csv-table
Example: open /csv-table and enter data.csv in its input.
Reads the chosen file (up to 256 KiB) on request. No writes, processes, network, or persistence.
Module variables reset on hot reload. All display output is bounded; viewers may truncate long content to 9,000 characters. Relative file paths and Git commands use the session working directory.
Tested with Claude Code 2.1.288. Minimum documented mods version: 2.1.287. The API can change; validate against your installed version.
claude plugin validate mods/csv-table --strict
claude plugin test mods/csv-table
Tests cover plugin commands, pane isolation, both UI surfaces, and the behavior described in tests/register.test.ts. Drawing tests validate element trees; they do not verify pixels painted by the native apps. Validation details.
MIT licensed. No runtime packages or build step required.
hooks/register.js 69 lines1import { clean, text, code, row, frame, bar, pretty, bounded, entries, safePath } from './ui.js'
2const ID = "csv-table"
3let target="data.csv"
4let report='Open a file to inspect it.'
5
6
7export function parseCSV(source) {
8 const rows=[];let row=[],cell='',quoted=false
9 for(let i=0;i<source.length;i++) {
10 const c=source[i]
11 if(c==='"') { if(quoted&&source[i+1]==='"'){cell+='"';i++}else if(quoted || cell==='')quoted=!quoted;else throw new Error('Quote inside unquoted CSV field.') }
12 else if(c===','&&!quoted){row.push(cell);cell=''}
13 else if(c==='\n'&&!quoted){row.push(cell.replace(/\r$/,''));rows.push(row);row=[];cell=''}
14 else cell+=c
15 }
16 if(quoted)throw new Error('CSV has an unclosed quoted field.')
17 if(cell || row.length){row.push(cell.replace(/\r$/,''));rows.push(row)}
18 return rows
19}
20function transform(source) {
21 const rows=parseCSV(source)
22 if(!rows.length)return 'Empty CSV.'
23 return Math.max(0,rows.length-1)+' data rows · '+rows[0].length+' columns\n\n'+rows.slice(0,26).map(r=>r.map(c=>c.replace(/\n/g,' ↵ ').slice(0,24).padEnd(25)).join(' | ')).join('\n')
24}
25
26
27async function load($) {
28 try {
29 const path = safePath(target)
30 const info = await $.fs.stat(path)
31 if(info.size > 262144) throw new Error('File exceeds the 256 KiB viewer limit.')
32 const source = await $.fs.read(path)
33 report = transform(source)
34 } catch(error) { report='Could not inspect file: '+error.message }
35 $.ui.invalidate('ui.render')
36}
37
38export function register(on) {
39 on('session.start', async ($, e, next) => {
40
41 await $.command.register({name:ID, description:"Preview quoted CSV fields, row counts, and column headers.", immediate:true, argumentHint:"[path]"})
42 return next(e)
43 })
44 on('command.run', {command:"csv-table"}, async ($, e) => {
45 if(e.args.trim()) target=e.args.trim()
46await load($)
47 await $.ui.open({id:ID,title:"CSV Table",focus:true,closeOnEscape:true})
48 return {}
49 })
50
51 on('ui.render', {component:'Pane'}, async ($, e, next) => {
52 if(e.requestId !== ID) return next(e)
53 const E = $.ui.resolve(e)
54 try {
55 const body = await draw($, E)
56 return frame(E,"CSV Table","Preview quoted CSV fields, row counts, and column headers.",body)
57 } catch(error) {
58 return frame(E,"CSV Table",'Unable to inspect this data.',[text(E,error.message,{color:'yellow'}),E.Button({key:'refresh',label:'Refresh',onPress:()=>$.ui.invalidate('ui.render')})])
59 }
60 })
61}
62async function draw($, E) {
63 const refresh = E.Button({key:'refresh',label:'Refresh',hotkey:'r',plain:true,onPress:()=>$.ui.invalidate('ui.render')})
64
65return [E.Input({key:'target',label:'File',value:target,submitLabel:'open',onSubmit:async(value)=>{target=value;await load($)}}),
66 code(E,report,"text"),E.Button({key:'refresh',label:'Read file again',onPress:()=>load($)})]
67
68}
69hooks/ui.js 36 lines1// Pure UI helpers. No engine access; each plugin contains its own copy.
2export function clean(value, limit = 9000) {
3 return String(value ?? '').replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f]/g, '').slice(0, limit)
4}
5export function text(E, value, props = {}) {
6 return E.Text({ ...props, children: [clean(value)] })
7}
8export function code(E, value, language = 'text') {
9 return E.Code({ source: clean(value), language })
10}
11export function row(E, children) {
12 return E.Box({ flexDirection: 'row', columnGap: 2, flexWrap: 'wrap', children })
13}
14export function frame(E, title, subtitle, children) {
15 return E.Box({ flexDirection: 'column', gap: 1, children: [
16 text(E, title, { bold: true, color: 'cyan' }),
17 text(E, subtitle, { dimColor: true }), ...children,
18 ] })
19}
20export function bar(percent, width = 24) {
21 const p = Math.max(0, Math.min(100, Number(percent) || 0))
22 const n = Math.round(p / 100 * width)
23 return '[' + '#'.repeat(n) + '-'.repeat(width - n) + '] ' + p.toFixed(1) + '%'
24}
25export function pretty(value) { return JSON.stringify(value, null, 2) }
26export function bounded(value, max = 9000) {
27 if (value.length > max) throw new Error('Input exceeds ' + max + ' characters. Use a smaller selection.')
28 return value
29}
30export function entries(value) { return value && typeof value === 'object' ? Object.entries(value) : [] }
31export function safePath(value) {
32 const path = value.trim()
33 if (!path || path.startsWith('-') || /[\x00-\x1f]/.test(path)) throw new Error('Enter a path without control characters or leading flags.')
34 return path
35}
36