.agent/skills/json-data-patterns/SKILL.md
JSON persistence, schema validation, migration patterns. Use when working with JSON files in the bridge queue, memory files, or any file-based agent storage.
npx skillsauth add abzhaw/juliaz_agents json-data-patternsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
import fs from 'fs';
import path from 'path';
function readJson<T>(filePath: string, defaultValue: T): T {
try {
const raw = fs.readFileSync(filePath, 'utf-8');
return JSON.parse(raw) as T;
} catch {
return defaultValue;
}
}
function writeJson(filePath: string, data: unknown, pretty = true): void {
fs.mkdirSync(path.dirname(filePath), { recursive: true });
const tmp = `${filePath}.tmp`;
fs.writeFileSync(tmp, JSON.stringify(data, null, pretty ? 2 : 0));
fs.renameSync(tmp, filePath); // atomic write (avoids corrupt files on crash)
}
import { z } from 'zod';
const MessageSchema = z.object({
id: z.string().uuid(),
chatId: z.string(),
text: z.string(),
ts: z.number(),
processed: z.boolean().default(false),
});
type Message = z.infer<typeof MessageSchema>;
function loadMessages(file: string): Message[] {
const raw = readJson(file, []);
return z.array(MessageSchema).parse(raw); // throws if invalid
}
interface V1Message { text: string; chatId: string; }
interface V2Message { text: string; chatId: string; id: string; ts: number; }
function migrate(data: unknown): V2Message[] {
const messages = data as V1Message[];
return messages.map((m, i) => ({
...m,
id: crypto.randomUUID(), // add new field
ts: Date.now() - (messages.length - i) * 1000, // backfill
}));
}
bridge/data/queue.json — message queue (read/write every 3s)security-agent/memory/baseline.json — security scan baselinesadhd-agent/memory/state.json — structural drift trackingdevelopment
Fortschrittsverfolgung der Masterarbeit. Wortanzahl pro Kapitel, Fertigstellungsgrad, fehlende Elemente, Deadlines. Haelt den Ueberblick.
development
Kapitelarchitektur und Gliederung der Masterarbeit. Verwaltet die Struktur, schlaegt vor wo Inhalte hingehoeren, validiert den logischen Fluss zwischen Kapiteln.
tools
Konvertiert Protokolleinträge und Session-Logs in thesis-fähiges deutsches Narrativ. Transformiert Entwicklungsdokumentation in akademische Prosa.
research
Sucht und analysiert akademische Literatur. Findet relevante Papers, erstellt strukturierte Zusammenfassungen. Zitiert NIEMALS — schlaegt nur vor.