<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Rob Sketch on Medium]]></title>
        <description><![CDATA[Stories by Rob Sketch on Medium]]></description>
        <link>https://medium.com/@rob.sketch?source=rss-6f587d4ba20c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*D1-6yrlOFGUNNjDIBODMTA.jpeg</url>
            <title>Stories by Rob Sketch on Medium</title>
            <link>https://medium.com/@rob.sketch?source=rss-6f587d4ba20c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 23:28:12 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rob.sketch/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Configuring Claude Code for Q/KDB-X: A Practical Walkthrough]]></title>
            <link>https://medium.com/@rob.sketch/configuring-claude-code-for-q-kdb-x-a-practical-walkthrough-4d400f308c7a?source=rss-6f587d4ba20c------2</link>
            <guid isPermaLink="false">https://medium.com/p/4d400f308c7a</guid>
            <dc:creator><![CDATA[Rob Sketch]]></dc:creator>
            <pubDate>Wed, 29 Jul 2026 08:41:59 GMT</pubDate>
            <atom:updated>2026-07-29T08:41:59.772Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/625/1*jfe1UrTgycp9Gan79nB1RQ.png" /></figure><p>In my first blog, <a href="https://medium.com/@rob.sketch/trying-kx-skills-for-q-programming-with-claude-45d9e44bfc64">Trying KX Skills for Q Programming with Claude</a>, we saw that additional q context from the <a href="https://github.com/KxSystems/kx-skills">KX Claude Skills</a> enabled Claude to write better q code more efficiently. However, the use case shown in my first blog was quite trivial and was scoped to a couple of basic problems to test Claude’s q programming ability.</p><p>This post aims to extend the last one by focusing on how to configure a Claude Code project for a KDB-X based codebase, going beyond just loading a couple of plugins to work with Q/KDB-X.</p><p><strong>The main problem I want to investigate now is:</strong> <em>Can a full Claude Code configuration help Claude write good q and use my kdb/q libraries the way I actually want to use them?</em></p><p>As we know, frontier LLMs still tend to struggle with kdb/q problems out of the box. They struggle just as much with using KDB-X modules without additional context; you can imagine they might struggle even more to try and use bespoke in-house modules/frameworks. This is the main reason we still need to supplement the models with extra context for q.</p><p>In this working example, I will be starting with a fresh KDB-X project. I want to write a script that can easily allow me to generate some synthetic capital markets data to store in memory, or to save down to disk to have a kdb partitioned database handy. I then want to use this data to run some common analytics using qsql.</p><p>To achieve this with Claude, let’s look at three concepts of a Claude Code configuration to build this KDB-X based project: CLAUDE.md, Skills, and Hooks.</p><ul><li><strong>CLAUDE.md:</strong> Baseline context loaded into every session; this can include things like a project overview, relevant commands, coding standards, and other project-specific context that is useful for every session, regardless of the problem you are working on.</li><li><strong>Skills: A</strong>dditional context on-hand ready to go when it’s needed. Claude loads and applies this context/instruction automatically whenever the task you are working on requires it</li><li><strong>Hooks:</strong> User-defined commands, scripts, or AI prompts that execute automatically at specific lifecycle events during an agent’s run.</li></ul><h3>Claude Code Configuration: Where Do I Start?</h3><p>I found that a good order of operations for this use case is building the CLAUDE.md file first, then looking at building any useful skills and hooks thereafter based on project requirements.</p><p>If you are trying to configure Claude to an existing project, a good command to use is /init which will generate an initial CLAUDE.md file based on your existing codebase. This is typically a good baseline to use which you can then refine manually as needed.</p><p>My Claude Code configurations here will be set at the project level, more information on the available configuration scopes can be found on the <a href="https://code.claude.com/docs/en/settings#available-scopes">Claude Code documentation</a>.</p><p>Let’s start with CLAUDE.md.</p><h4>CLAUDE.md</h4><p><strong>CLAUDE.md</strong> is a plain markdown file in your project that Claude Code loads at the start of every session. It’s the standing brief you leave for Claude about your project (build commands, conventions, things not to touch), so you don’t have to re-explain them every time you launch a Claude Code session in your project.</p><p>This will be my starting point for configuring my Claude Code KDB-X project. When building a CLAUDE.md file for my use-case, the following points come to mind which I have initially included in the file:</p><ol><li><em>Project Overview:</em> give Claude context of what my project does and what it achieves</li><li><em>Commands:</em> Some basic commands for running q scripts within the project, and how to read logs for debugging purposes</li><li><em>Coding Standards:</em> Some coding standards based purely on personal preferences; included some non-negotiables as well as a few code-style choices</li><li><em>Project Modules:</em> Context on which KDB-X modules I want to use and when (I use KDB-X modules here, but this can be any bespoke/proprietary module set as well).</li><li><em>Directory structure:</em> Context on project layout, data locations on disk, etc.</li></ol><p>These are just some basic bits of context I feed to Claude, which I felt was relevant anytime I start up a Claude Code session for my KDB-X project.</p><p>The source code for my CLAUDE.md can be found in my public repository for this project <a href="https://github.com/robsketch/kdb-x-and-claude/blob/main/CLAUDE.md">here</a>.</p><p>Official guidelines for a good CLAUDE.md file can be found on Anthropic’s <a href="https://code.claude.com/docs/en/memory#claude-md-files">documentation</a>. I think it’s worth reviewing if you are working on building your own CLAUDE.md for your projects.</p><p>Now that I have constructed an initial CLAUDE.md I am happy with, I want to look at setting up skills to give Claude additional context when it is needed, and not necessarily context Claude needs in every session.</p><h4>Skills</h4><p>A <strong>skill </strong>is a folder of instructions you write once (as a SKILL.md file) that Claude Code reads and follows automatically whenever a task matches it.</p><p>The models Claude uses do not know how to use KDB-X modules out of the box; therefore the model is prone to working through errors as it tries to reason how to actually use them. To combat this, I opt to feed context on using the KDB-X modules I care about as their own separate skills.</p><p>The reason I choose to separate these into skills is that I might not always need context of using all modules in every session. This allows Claude to pick and choose what modules it might need when working on a specific problem and only pull those instructions into context when it is necessary (optimizing tokens).</p><p>I currently have three skills set up for this demo project, which I felt would be relevant to my goal of generating synthetic data and running some analytics against it:</p><ol><li><em>datagen:</em> context sourced as a snapshot from the <a href="https://github.com/KxSystems/datagen/tree/main/docs/references">source code documentation</a></li><li><em>logging:</em> context sourced as a snapshot from the <a href="https://github.com/KxSystems/logging/tree/main/docs">source code documentation</a></li><li><em>q-knowledge:</em> context sourced as a snapshot from the <a href="https://github.com/KxSystems/kx-skills/tree/main/plugins/q-knowledge/skills/q">q skill within the q-knowledge plugin from KX</a></li></ol><p>A downside to building the skill via a snapshot is that if the module ever changes, a manual sync would need to be run to reflect changes. A good workflow for this is if I ever update an existing KDB-X module in my workspace, I will need to make sure that the skills are updated accordingly.</p><p>This is what the structure of the skills looks like in my .claude/ project-level configuration:</p><pre>(.venv) rob@sketchPC:~/kdb-x-and-claude/.claude/skills$ tree -L 3<br>.<br>├── datagen<br>│   ├── SKILL.md<br>│   └── reference.md<br>├── logging<br>│   ├── SKILL.md<br>│   └── reference.md<br>└── q-knowledge<br>    ├── SKILL.md<br>    ├── reference.md<br>    └── references<br>        ├── common-errors.md<br>        ├── python-q-mapping.md<br>        ├── review-checklist.md<br>        └── shell-patterns.md</pre><p>Full markdown files are also on my <a href="https://github.com/robsketch/kdb-x-and-claude/tree/main/.claude/skills">public repo</a>.</p><p>What do each of these markdown files mean?</p><p><strong>SKILL.md:</strong>Always loaded in full the moment the skill triggers (based on its name/description metadata matching the task), so this is where the core instructions and workflow live.</p><p>The name/descriptions in all SKILL.md files are loaded into Claude’s context, which allows Claude to reason when the skill is relevant for a task and only load the full SKILL.md into context when it’s needed.</p><p><strong>reference.md:</strong>Not loaded automatically when a skill load is triggered; it only gets read into context if SKILL.md explicitly points to it (e.g. &quot;see reference.md for the full schema&quot;), so it&#39;s for deeper detail that would bloat SKILL.md if inlined. This is nice to save on context when most use cases are the same, and we only need deeper context of the module on occasion.</p><p><strong>references/:</strong> Contents also not loaded automatically and only pulled in if referenced/Claude decides it is needed.</p><p>The good thing about these skills is as Claude works with them, Claude can automatically suggest updates to the context files if what it deems as “gotchas” appear, to help avoid them in the future. As said in my previous blog, these context files are ever-changing; we must make updates in a way that keeps the context clean rather than bloating it.</p><p>Now that I have project-level context, as well as skills to inform Claude how to use the KDB-X modules I want to utilize along with additional q context, I’m nearly ready to start prompting to get work done with my agent.</p><p>But I’m not off the hook yet…</p><h4>Hooks</h4><p>In my previous blog, I mentioned the q linter skill provided by KX might work better for me as a PostToolUse hook, rather than a skill that is triggered when Claude decides it’s relevant. This gives me a deterministic trigger such that anytime the Write/Edit tool is called on *.q files, the linter runs and its findings go back to Claude.</p><p>For the hook we leverage the linter from <a href="https://code.kx.com/developer/linting/">KX Developer</a>. I install following the documented steps then utilize the run.sh script which runs the linter in the existing q-knowledge skill. I opt to use the script in the hook with the following stdin form, example call is:</p><pre>export QLINT_DIR=/home/rob/developer-1.6.0-linux/analyst/ws<br>cat &lt;&lt;&#39;EOF&#39; | /home/rob/kdb-x-and-claude/.claude/hooks/lib/run.sh<br>f:{[x]<br>  log:1;<br>  result:select from t where sym=`AAPL;<br>  result<br>  };<br>f[1]<br>EOF</pre><p>with result</p><pre>label                errorClass description                                                 problemText errorMessage startLine startCol endLine endCol<br>------------------------------------------------------------------------------------------------------------------------------------------------------<br>UNUSED_PARAM         warning    &quot;This param was declared then never used&quot;                   ,&quot;x&quot;        &quot;&quot;           1         5        1       5     <br>ASSIGN_RESERVED_WORD error      &quot;Assignment to a reserved word&quot;                             &quot;log:1&quot;     &quot;&quot;           2         3        2       7     <br>UNDECLARED_VAR       warning    &quot;Undeclared variable in function will be treated as global&quot; ,&quot;t&quot;        &quot;&quot;           3         22       3       22    </pre><p>This is useful information for Claude if Claude generates dirty q code (which doesn’t seem to happen too frequently with the additional q context) — the only caveat here is the output of this linter is a standard text table. In the hook we can provide Claude with additional context on what to do with the output table.</p><p>To implement the linter in a PostToolUse hook on Edit/Write tool calls for *.q files, I have added an extra script which dumps the text into the json objects Claude expects for additional context from the hook’s run. A summary of this flow is:</p><ol><li>Claude writes or edits a *.q file via the Write/Edit tool calls. Claude Code fires the PostToolUse hook, sending it JSON on stdin that includes the file path of the *.q file Claude is working on.</li><li>qlint.sh pulls the file path out of that JSON, reads the file, and pipes its contents into run.sh — the actual KX linter.</li><li>The linter runs qlint.q inside q and prints its findings as a plain-text table.</li><li>qlint.sh captures that raw text as one blob and hands it to a small python3 -c snippet, which wraps it inside a JSON object using json.dumps — this safely escapes the quotes/newlines in the table so the result is valid JSON, and drops it into the hookSpecificOutput.additionalContext field (with hookEventName set to PostToolUse) along with an instruction: “Fix all errors before moving on. Suggest changes on warnings.”</li><li>Claude Code injects that JSON’s additionalContext field into Claude’s next turn, as if the system had said it. Claude reads the lint table, fixes whatever’s flagged, and only then reports the work done. I have also prompted Claude to always try and fix errors, and suggest changes to me for any warnings, some of which can be benign.</li></ol><p>It’s a bit extra work, but now on each Edit/Write tool call for *.q files Claude works on, we can run a linter to catch any dirty q code and let Claude help resolve it. This can also be useful to prompt Claude to lint other scripts as needed that it might not have touched yet.</p><p>The full implementation on this hook along with the settings.json file can be found in the <a href="https://github.com/robsketch/kdb-x-and-claude/tree/main/.claude/hooks">repo</a>.</p><p>Hooks are a great way to have deterministic behavior on specific tool calls. This is just one use case of many useful hooks a Claude Code project can have based on a project’s requirements.</p><h3>Prompts</h3><p>I have a CLAUDE.md file for my project, some skills ready to go, and a q linter to help keep Claude’s q code clean. Let’s try out a few prompts to add some scripts to my project.</p><p><strong>Model Used:</strong> Opus 5</p><h4>Use Case 1: Generate a Partitioned KDB HDB</h4><p>As part of my project I want to have a script I can run to generate some synthetic historical capital markets data on my local machine. In this use case I am happy for Claude to make writes to my local HDB.</p><p>Prompt:</p><pre>write a q script called generate.q which generates a kdb partitioned historical database on disk on this machine.  the function used to generate the hdb data should take in a start date and end date for the partitioned database.  it should also take in what tables we want to generate, i.e. trade/quote/nbbo etc.  if no tables are passed, default to trade and quote.  provide a summary of everything you did to complete this task, also highlighting any errors you faced and how you fixed them.</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9BHUJ_Ha7-ZSsNRrsPxKTQ.png" /><figcaption>Claude Code loading all relevant skills on the first prompt</figcaption></figure><p>All three of the skills loading here is a good start. After running to completion, here is a summary from Claude:</p><pre>● Summary<br><br>  Created src/generate.q, which builds a date-partitioned HDB via the datagen module&#39;s capmkts.buildPersistedDB.<br><br>  What it does:<br>  - .generate.buildHdb[StartDate;EndDate;Tbls] — the core function requested. Takes a start date, end date, and a list of tables; defaults Tbls to  `trade`quote when an empty list is<br>  passed.<br>  - Resolves KX_HDB_DIR/KX_LOG_DIR from the environment (falling back to data/hdb/data/logs), per CLAUDE.md.<br>  - Loads kx.log and kx.datagen.capmkts via use (not \l), logs to both a file sink and stdout at info/warn/error.<br>  - .generate.main wraps the run with start/complete logging, and the script invokes it with a default one-month range (2026.01.01–2026.01.31,  `trade`quote) when run standalone.<br><br>  Errors hit and fixes:<br>  1. qlint warning — params shadows a q error message. The PostToolUse qlint hook flagged the variable name params as ambiguous with a built-in q error string. Renamed it to buildOpts.<br>  2. Runtime &#39; error on .log.add with a garbled message. I&#39;d bound the logger instance to .generate.log (per the project&#39;s dotted-global convention) but then called the bare, undefined<br>  .log.add/.log.info throughout the rest of the script. Since .log was never created, those calls failed. Fixed by using .generate.log.* consistently everywhere.<br><br>  Verification:<br>  - Ran q src/generate.q — completed in ~4s, logged cleanly to data/logs/generate.log.<br>  - Spot-checked disk output: 20 trading-day partitions for January 2026 under data/hdb/, each containing trade and quote splayed tables (holidays/weekends correctly excluded per datagen&#39;s<br>  known behavior).<br>  - Loaded the HDB (q data/hdb) and confirmed real queryable data: select from trade where date=2026.01.02 returned live rows, select count i by date from trade showed ~45K–53K trades/day<br>  across all partitions. (Plain #/select[n] without a where date=... filter throws &#39;par/&#39;nyi on partitioned tables — expected q behavior, not a script bug.)<br>  - Also tested .generate.buildHdb with a custom table list including nbbo and a different date range against a scratch directory — correctly produced 3 partitions each containing trade,<br>  quote, and nbbo, confirming the parameterization works beyond the hardcoded default call.</pre><p>Raw script written by Claude <a href="https://github.com/robsketch/kdb-x-and-claude/blob/main/src/generate.q">added to my github</a>.</p><p>Some notes:</p><ul><li>Claude successfully completes the task; the script successfully generated one month of synthetic trade and quote data.</li><li>The Q linter actually makes a decent suggestion to Claude, the linter picked up that Claude named a local variable params, and flagged that this could be confused with the built-in &#39;params error.</li><li>Claude does use the KDB-X modules for both datagen and logging. Notably Claude fails to use .generate.log the first time, but resolves on its own.</li><li>This issue with incorrectly using the logging module can be supplemented as context in the skill, where we can add a few examples of using the correct logger name when using the logging module.</li><li>While running some initial tests, Claude tries to run # on a partitioned table, and recognizes that this didn’t work and self corrected. Again, this can be additional context we feed to the q skill to help avoid this “gotcha” in the future.</li><li>Claude hard codes a date range when the main function is called. I didn’t specify this as a requirement, but if I wanted to change it I could run a follow-up prompt for Claude to pass it as a command line argument instead.</li></ul><h4>Use Case 2: Generate some analytics</h4><p>Now I have some synthetic hdb data on my local disk:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*Ezb1d8ZioT6kX7XV-9Zl4g.png" /><figcaption>Accessing the newly generated DB by Claude</figcaption></figure><p>Now let’s prompt Claude to write a script to write some basic analytics to run against some of my data:</p><pre>Now that I have some hdb data on my local disk, write a new script which contains function(s) that I can run in a standalone q process which calculates high, low, open, close, and vwap in 5 minute buckets for the trade table.  This script will eventually contain more functions for more analytics, but stick with this for now. Provide a summary of everything you did, including any errors you hit and how you fixed them.</pre><p>Claude’s summary after completion:</p><pre> What I did<br><br>  1. Loaded the q-knowledge and logging skills per CLAUDE.md before writing any q.<br>  2. Surveyed the project — src/generate.q, env.sh, and the HDB (20 partitions, 2026.01.02–2026.01.30).<br>  3. Inspected the trade schema: date d, sym s (parted), time n (timespan), price f, size j, stop b, cond c, ex s.<br>  4. Verified row ordering — time is ascending within each sym per partition, so first price / last price in the group-by are genuinely the open and close. No sort needed.<br>  5. Wrote src/analytics.q and ran it against the real HDB.<br>  6. Cross-checked correctness: recomputed the 2026.01.02 AAPL 09:30 bar by hand (sum size*price % sum size for vwap, explicit within filter for the bucket). All seven fields<br>  matched the function&#39;s output exactly.<br><br>  The script<br><br>  .analytics.tradeOhlcv[Dates]   // one date atom or a list of dates<br>  .analytics.main[Dates]         // loads HDB if needed, then the above<br><br>  Returns a table keyed on date,sym,bucket with open high low close vwap volume tradeCount. Bucket width is .analytics.bucketSize (0D00:05) — a namespace constant so you can<br>  change it in one place, or shadow it per-call later when more analytics land. .analytics.loadHdb[] runs on load and is a no-op if trade is already in your session, so it&#39;s<br>  safe either way.<br><br>  q)\l src/analytics.q<br>  q).analytics.tradeOhlcv[2026.01.02 2026.01.05]<br><br>  Errors hit and fixes<br><br>  - &#39;nyi on exec distinct date from trade — during exploration, not in the script. distinct on the partition column of a partitioned table isn&#39;t supported; used the date<br>  global (the partition vector) instead. That&#39;s also what the script&#39;s date validation uses.<br>  - env.sh: No such file or directory — my own shell mistake: the working directory persisted from a previous cd into the HDB. Fixed by using absolute paths in subsequent<br>  commands.<br><br>  Two things worth flagging<br><br>  - \l on a partitioned DB changes the process working directory to the HDB root. It&#39;s noted in the script header, but it means relative paths in your session shift after<br>  load.<br>  - VWAP includes every trade regardless of cond code. Real venue VWAP usually excludes certain condition codes; when you know which ones matter here, that filter belongs in<br>  tradeOhlcv.</pre><p>Raw script written by Claude <a href="https://github.com/robsketch/kdb-x-and-claude/blob/main/src/analytics.q">added to my github</a>.</p><p>Some notes on Claude’s work and the code:</p><ul><li>Note that only q-knowledge and logging loaded here, datagen was correctly skipped since no data generation was involved.</li><li>Claude runs a few sensible checks before writing the Q script. This included ensuring the underlying data is sorted by symbol on disk, meaning using first/last is suitable for the open/close fields.</li><li>Does follow my coding conventions overall, having a single entrypoint function which calls the full stack. Claude also correctly used the KDB-X logging module.</li><li>Questionable check for if the HDB has already been loaded. Used `trade in key `. for the check, but using something to also check the trade that is loaded is partitioned like .Q.qp might be a bit more complete of a check.</li><li>Does a check for if any dates requested are missing — I didn’t ask for this but it does seem like a sensible check/warning.</li><li>In the main select statement for the analytics, adds on a tradeCount:count i and volume:sum size which I don’t really need.</li><li>The HDB is loaded on startup and within the main function call, for this I only really need one, perhaps just on startup, and omit it from the main function call or just only use .analytics.tradeOhlcv.</li></ul><p>Overall, though, fairly impressed with the output from just the one prompt. Got a script working for what I wanted that largely followed my coding conventions. There are some bits that I would change manually after the fact, and I could feed some of those notes back to my CLAUDE.md/skills when/if necessary.</p><h3>Conclusion</h3><p>In this walkthrough, I moved beyond simply loading a couple of plugins and configured a more complete Claude Code setup for a simple KDB-X project using three core mechanisms: a CLAUDE.md for baseline project context, modular Skills for on-demand context on specific KDB-X modules/q knowledge, and a PostToolUse Hook that runs the KX q linter automatically on every *.q file edit.</p><p>Testing this configuration against two real prompts, Claude successfully generated a date-partitioned HDB of synthetic trade and quote data and an analytics script computing 5-minute OHLC and VWAP buckets, in both cases correctly loading the relevant skills, following my coding conventions, and using the KDB-X datagen and logging modules. Notably, the linter hook and Claude’s own self-correction caught and resolved some issues along the way. While the output still contained a few minor choices I’d tweak manually, these are exactly the kinds of “gotchas” that can be fed back into the CLAUDE.md and skills over time, showing how a well-configured, evolving context setup meaningfully improves Claude’s ability to work with Q/KDB-X.</p><p>These were just a few examples of how we can use Claude Code configuration to work on Q/KDB-X. I recommend having a look at Anthropic’s documentation on how to use a good configuration in more detail.</p><p>As always, if you have feedback, questions, or are using Claude Code in your own KDB/KX work, I’d love to hear from you!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d400f308c7a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Trying KX Skills for Q Programming with Claude]]></title>
            <link>https://medium.com/@rob.sketch/trying-kx-skills-for-q-programming-with-claude-45d9e44bfc64?source=rss-6f587d4ba20c------2</link>
            <guid isPermaLink="false">https://medium.com/p/45d9e44bfc64</guid>
            <category><![CDATA[claude]]></category>
            <category><![CDATA[kdb]]></category>
            <category><![CDATA[claude-code]]></category>
            <dc:creator><![CDATA[Rob Sketch]]></dc:creator>
            <pubDate>Wed, 01 Jul 2026 08:31:16 GMT</pubDate>
            <atom:updated>2026-07-25T21:18:07.458Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0qbb33FMVqfYpA7tjyJ2fw.png" /></figure><p>Here I share my hands-on experience with <a href="https://kx.com/blog/teaching-claude-code-to-speak-kx-open-source-plugins-for-q-pykx-kdb-x-and-kdb-ai/">KX’s new q-knowledge Claude plugin</a>— a set of skills designed to improve Claude’s fluency in q development. I’ll walk through a couple of practical examples, but my main observations after several days of use are:</p><ul><li>Claude handles q reasonably well without additional context from q skills, but is prone to feedback looping and increased reasoning overhead, which drives up token costs compared to skill-assisted runs.</li><li>The KX q-knowledge skill demonstrably improves Claude’s q fluency — it helped avoid upfront errors, produced cleaner solutions, and surfaced more idiomatic q behaviour in its responses (e.g. right-to-left evaluation, correct operator usage) when it had the relevant context available.</li><li>The skill has some coverage gaps — notably around knowing when/how to use utilities like .Q, meaning skill-assisted and non-assisted responses were similarly limited in cases where these could have been part of a cleaner or preferred solution.</li><li>Token cost savings from the KX skill are context-dependent — the skill pays for itself when it prevents error loops, but when Claude doesn’t hit errors anyway for simpler tasks, the context-loading overhead can make the no-skill run marginally cheaper at the start of a session. But more importantly…</li><li>The KX skill’s value compounds over a longer session — richer q context loaded early reduces trial-and-error on subsequent prompts, meaning the cost/quality benefit grows the longer the session runs (with good context management).</li><li>KX skill qlint-snippet auto-triggers intermittently when Claude is working on q. If qlint is not set up in your environment, Claude tries to help with this setup and wastes tokens. I argue this linting would be better suited as a PostToolUse hook rather than a skill with a q lint system dependency.</li></ul><p>Now, I’ll go through installing the KX Plugins which contain the open-source Claude Code skills. It’s pretty easy, only a couple of Claude commands to get started.</p><h3>Plugin Installation</h3><p>Assuming you have access to Claude Code, you open a Claude Code session and just run:</p><pre>/plugin marketplace add KxSystems/kx-skills</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nsboGAJmtGGAaT7eYJuFKg.png" /></figure><p>After making the kx-skills available from the marketplace, you can run the /plugin commands that install the plugins to your Claude workspace. For now, I am interested in q-knowledge and kdbx-knowledge (I will just use q-knowledge for this blog, but will use kdbx-knowledge for another one!) so I’ll keep it to those for now:</p><pre>/plugin install q-knowledge@kx-skills<br>/plugin install kdbx-knowledge@kx-skills</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/1*R-vFhCWq5yyuSQSW5b8j_w.png" /></figure><p>After running /reload-plugins we can see they are now installed and available in our Claude session.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p8-a287dp82strGBeFJdJA.png" /></figure><p>Now that I have the plugins ready, let’s try out some prompts which utilize the q-knowledge skill.</p><h3>Prompt/Response Comparisons with and without KX Skills</h3><p>I was curious to see Claude’s response to some basic q-related prompts before and after enabling the plugin in two separate sessions. I chose two prompts to share in more detail below.</p><p><strong>A quick note on reproducibility: </strong>LLM responses vary between sessions due to <a href="https://www.ibm.com/think/topics/llm-temperature">temperature</a>, so if you run these prompts yourself, don’t expect identical output. My comparisons are based on a sample size of one and are intentionally qualitative — the goal here is simply to get an initial feel for how Claude handles q tasks with and without the KX skill loaded.</p><p><strong>Model used:</strong> Opus 4.8 (definitely could have used Sonnet)</p><p>I include Claude’s action/response summary rather than raw output of the model’s reasoning to keep things a bit more readable. I also include the cost of each session where the prompt was run to get an idea of how expensive each task was for Claude.</p><p>I do not provide the model with any additional context (i.e. other skills or CLAUDE.md file) when doing this comparison. This is intentional to give a better idea of how the q-knowledge skill impacts model performance.</p><p>/cost command is run on a fresh Claude session after the single prompt/task is complete, showing the cost associated with Claude completing the task.</p><p>After showing the output/cost for the prompt I discuss some notable observations.</p><h3>Prompt 1:</h3><pre>Write a function in the q programming language which accepts an integer as a parameter and returns all odd numbers up to that integer.  Test that the solution works as expected. Cover any edge cases. After completion, provide a summary of everything you did to complete the task. Include any errors you encountered and how you fixed them. Don&#39;t use Q lint.</pre><h4>No KX Skills</h4><p>No skills enabled — purely base context from a fresh Claude Code session in my terminal.</p><p>Claude response summary:</p><pre>  The function<br><br>  oddsUpTo:{[n]<br>    if[n&lt;1; :`long$()];   / non-positive input -&gt; empty long list<br>    i:1+til n;            / 1 2 3 ... n<br>    i where 1=i mod 2     / keep the odd ones<br>    };<br><br>  It takes an integer n and returns all odd numbers from 1 up to and including n (e.g. oddsUpTo 10 → 1 3 5 7 9).<br><br>  What I did<br><br>  1. Confirmed q was available — found the kdb+/q interpreter at /home/rob/.kx/bin/q, so I could actually run the code rather than reason about it.<br>  2. Wrote the function using til to build the range 1..n, then where 1=i mod 2 to filter the odds.<br>  3. Wrote a test script (odds.q) with both visual output and hard ~-match assertions.<br>  4. Covered edge cases:<br>    - Even upper bound (n=10 → 1 3 5 7 9)<br>    - Odd upper bound (n=9 → 1 3 5 7 9, includes n itself)<br>    - Smallest odd (n=1 → ,1)<br>    - n=2 (→ ,1)<br>    - Zero (n=0 → empty `long$())<br>    - Negative (n=-5 → empty). This guard matters because til throws on a negative argument, so I short-circuit non-positive input to an empty long list.<br><br>  Errors I hit and how I fixed them<br><br>  1. &#39;match / &#39;assign error on the variable name exp. My test helper used exp as a parameter name, but exp is a built-in q function (exponential). It silently stayed bound to<br>  the builtin, so got~exp was always false and the assertion aborted. Fix: renamed the parameter to expected. (The oddsUpTo function itself was never affected — its output <br>  was correct from the first run.)<br>  2. &#39;, parse error on ,1. When ,1 (enlist-1) is the leading token of a bracketed argument like assert[...;,1], q&#39;s parser mis-reads the leading , as a join operator. Fix:<br>  used the explicit enlist 1 form instead, which is unambiguous.<br><br>  After both fixes the script runs clean: all six assertions report PASS and all assertions passed.</pre><p>Cost of session after completion via /cost:</p><pre>Session<br><br>  Total cost:            $0.4066<br>  Total duration (API):  1m 56s<br>  Total duration (wall): 4m 46s<br>  Total code changes:    30 lines added, 3 lines removed<br>  Usage by model:<br>      claude-haiku-4-5:  572 input, 16 output, 0 cache read, 0 cache write ($0.0007)<br>       claude-opus-4-8:  3.2k input, 6.8k output, 173.4k cache read, 13.3k cache write ($0.4060)</pre><h4>With q-knowledge skill triggered:</h4><p>Claude response summary:</p><pre>Solution<br><br>  / oddsUpTo: return all odd numbers from 1 up to and including x<br>  oddsUpTo:{[x]<br>    n:&quot;j&quot;$x;                 / coerce to long; guards float/bool atoms<br>    if[n&lt;1; :`long$()];      / nothing odd at or below 0 -&gt; empty long vector<br>    t:1+til n;               / 1 2 .. n<br>    t where 1=t mod 2 }      / keep the odds<br><br>  How it works (right-to-left, vectorized): til n builds 0..n-1, 1+ shifts it to 1..n, then t where 1=t mod 2 keeps elements where mod 2 is non-zero — i.e. the odds. No loops<br>  needed.<br><br>  What I did<br><br>  1. Loaded the q skill for correct idioms (notably mod for modulo, since % is division in q).<br>  2. Wrote oddsUpTo to odds.q in the scratchpad.<br>  3. Ran it against a batch of test cases via q odds.q -q &lt;&lt;&lt; &#39;...&#39; (loading the script before reading stdin, ending with exit 0).<br><br>  Test results<br><br>  ┌─────────────────┬──────────────┬───────────────────────────────────────────────────────────────┐<br>  │      Input      │    Output    │                             Notes                             │<br>  ├─────────────────┼──────────────┼───────────────────────────────────────────────────────────────┤<br>  │ 10              │ 1 3 5 7 9    │ even bound — odds below it                                    │<br>  ├─────────────────┼──────────────┼───────────────────────────────────────────────────────────────┤<br>  │ 11              │ 1 3 5 7 9 11 │ odd bound is inclusive                                        │<br>  ├─────────────────┼──────────────┼───────────────────────────────────────────────────────────────┤<br>  │ 1               │ ,1           │ single-element vector                                         │<br>  ├─────────────────┼──────────────┼───────────────────────────────────────────────────────────────┤<br>  │ 2               │ ,1           │                                                               │<br>  ├─────────────────┼──────────────┼───────────────────────────────────────────────────────────────┤<br>  │ 0               │ `long$()     │ empty                                                         │<br>  ├─────────────────┼──────────────┼───────────────────────────────────────────────────────────────┤<br>  │ -5              │ `long$()     │ negative handled gracefully                                   │<br>  ├─────────────────┼──────────────┼───────────────────────────────────────────────────────────────┤<br>  │ 7.9             │ 1 3 5 7      │ float coerced (&quot;j&quot;$7.9 → 8)                                   │<br>  ├─────────────────┼──────────────┼───────────────────────────────────────────────────────────────┤<br>  │ type oddsUpTo 0 │ 7h           │ empty result is still a long vector, not a generic empty list │<br>  └─────────────────┴──────────────┴───────────────────────────────────────────────────────────────┘<br><br>  Edge cases covered<br><br>  - n ≤ 0 (zero and negatives): returns an empty typed long vector `long$() rather than erroring. This matters because til of a negative argument throws, so the if[n&lt;1; :...]<br>  guard short-circuits before reaching til.<br>  - Type consistency: the empty-case return is `long$(), so the function always returns a long vector — callers won&#39;t hit a &#39;type mismatch on the empty path.<br>  - Non-integer atoms (float/bool): &quot;j&quot;$x coerces to long first, so 7.9 is handled without a type error.<br><br>  Errors encountered<br><br>  None — the function worked on the first run and all cases produced the expected output. One thing worth flagging: the shell tool reported &quot;Shell cwd was reset to<br>  /home/rob/claude-skills&quot; after the run; that&#39;s just the harness resetting the working directory, not an error in the q code.<br><br> </pre><p>Cost of session after completion via /cost :</p><pre> Session<br><br>  Total cost:            $0.2335<br>  Total duration (API):  36s<br>  Total duration (wall): 2m 25s<br>  Total code changes:    8 lines added, 0 lines removed<br>  Usage by model:<br>      claude-haiku-4-5:  576 input, 15 output, 0 cache read, 0 cache write ($0.0007)<br>       claude-opus-4-8:  3.4k input, 2.1k output, 75.4k cache read, 12.5k cache write ($0.2329)</pre><h4>Prompt 1 Comparison Observations</h4><p>Without any skill context, Claude’s solution is functional — it gets to the right answer. The limitation, visible here, is the feedback loop from errors: Claude hits avoidable mistakes, self-corrects, and iterates before landing on the final result. Each of those correction cycles costs tokens, which is reflected in the higher session cost compared to the skill-assisted run.</p><p>With the q skill loaded, the final solution is comparable (just some extra lines to handle floats that I didn’t really need, you still need to review the code!), but Claude reaches this solution without hitting any errors — the additional context heads off mistakes before they occur. It also reasons more explicitly about q’s semantics, calling out right-to-left evaluation and correctly noting that %is division and not modulo as it is in Python. The cleaner execution path brought the session cost down, and that saving compounds further as the richer q context carries over to subsequent prompts in the same session.</p><h3>Prompt 2:</h3><pre>Write a function in the q programming language which creates a file path based on two parameters, a base directory and a list of symbols which sets the full file path.  For example, given a base directory `:dir and a path denoted by `path`to`file, return a full path `:dir/path/to/file. After completion, provide a summary of everything you did to complete the task. Include any errors you encountered and how you fixed them. Don&#39;t use Q lint.</pre><h4>No KX skills:</h4><p>Claude response summary:</p><pre>  ● All test cases pass, including the example from your request. Here&#39;s the function:<br><br>  / makePath - build a full file path symbol from a base directory and a path<br>  / base: a file symbol like `:dir<br>  / path: a list of symbols like `path`to`file<br>  / returns: `:dir/path/to/file<br>  makePath:{[base;path] `$ (string base),&quot;/&quot;,(&quot;/&quot; sv string path)}<br><br>  How it works<br><br>  1. string base — converts the base symbol `:dir to the string &quot;:dir&quot;.<br>  2. string path — converts the symbol list `path`to`file to a list of strings (&quot;path&quot;;&quot;to&quot;;&quot;file&quot;).<br>  3. &quot;/&quot; sv ... — sv (&quot;scalar from vector&quot; / string-join) joins that list with / separators into &quot;path/to/file&quot;.<br>  4. Concatenate base + &quot;/&quot; + joined path → &quot;:dir/path/to/file&quot;.<br>  5. `$ casts the string back to a symbol → `:dir/path/to/file.<br><br>  Test results<br><br>  ┌───────────────────────────────────────────────┬─────────────────────────────────────┐<br>  │                     Call                      │               Result                │<br>  ├───────────────────────────────────────────────┼─────────────────────────────────────┤<br>  │ makePath[:dir; pathtofile]                    │ `:dir/path/to/file ✓ (your example) │<br>  ├───────────────────────────────────────────────┼─────────────────────────────────────┤<br>  │ makePath[:dir; enlist single]                 │ `:dir/single                        │<br>  ├───────────────────────────────────────────────┼─────────────────────────────────────┤<br>  │ makePath[:/abs/base; ab]| ``:/abs/base/a/b `` │                                     │<br>  └───────────────────────────────────────────────┴─────────────────────────────────────┘<br><br>  Errors encountered<br><br>  None. The implementation worked on the first run. The one thing I deliberately accounted for was the single-element path case: a lone symbol like `single is an atom, not a list, so it must be passed as enlist singleforstring/sv` to<br>  behave. With a proper list (one or more elements) it works as-is, which is the normal usage. I verified this edge case explicitly rather than assuming it.<br><br>  The function is saved to makepath.q. As requested, I did not use q lint.</pre><p>Cost:</p><pre>Session<br><br>  Total cost:            $0.1496<br>  Total duration (API):  26s<br>  Total duration (wall): 1m 10s<br>  Total code changes:    6 lines added, 0 lines removed<br>  Usage by model:<br>      claude-haiku-4-5:  601 input, 14 output, 0 cache read, 0 cache write ($0.0007)<br>       claude-opus-4-8:  3.1k input, 1.4k output, 63.3k cache read, 6.6k cache write ($0.1490)</pre><h4>With q-knowledge skill triggered:</h4><p>Claude response summary:</p><pre>● The function works. Here&#39;s the result:<br><br>  mkpath:{[base;path] ` sv base,path}<br><br>  q) mkpath[`:dir; `path`to`file]   / `:dir/path/to/file<br><br>  How it works<br><br>  - base,path joins the base handle with the path symbols into a single symbol vector: `:dir`path`to`file.<br>  - ` sv (the sv &quot;scalar from vector&quot; operator with a backtick left argument) is q&#39;s built-in path joiner — it concatenates a symbol vector into one file-handle symbol separated by /, producing `:dir/path/to/file.<br><br>  Using the built-in sv is the idiomatic approach (rather than manually casting to strings and inserting &quot;/&quot;), and it correctly handles both relative (:dir) and absolute (:/abs/base) base handles.<br><br>  Summary of what I did<br><br>  1. Loaded the q skill to ground the implementation in idiomatic q.<br>  2. Wrote mkpath.q with a one-line function. I deliberately reached for ` sv rather than a string-manipulation approach, because sv with a backtick left argument is q&#39;s purpose-built operator for assembling file-path handles from symbol<br>  vectors — shorter, faster, and avoids the symbol↔string conversion traps the skill warns about.<br>  3. Tested it from the shell using the q script.q -q &lt;&lt;&lt; &quot;...; exit 0&quot; pattern (loading the script as a positional arg so it&#39;s parsed before stdin, and ending with exit 0 so q doesn&#39;t hang). I ran three cases: the example from the<br>  prompt, a single-element path (enlist file`), and an absolute base directory.<br><br>  Errors encountered<br><br>  None. All three test cases produced the expected output on the first run:<br>  - mkpath[`:dir; `path`to`file] → `:dir/path/to/file (matches the requested example)<br>  - mkpath[`:dir; enlist `file] → `:dir/file<br>  - mkpath[`:/abs/base; `sub`leaf] → `:/abs/base/sub/leaf<br><br>  Per your instruction, I did not run qlint on the code.<br><br>  One thing worth noting: the path argument should be a symbol list. If you ever want to pass a single sub-directory, use enlist `file (a one-element list) rather than a bare `file atom — ` sv expects a vector, which is the standard<br>  atom-vs-vector distinction in q.</pre><p>Cost:</p><pre>Session<br><br>  Total cost:            $0.2287<br>  Total duration (API):  41s<br>  Total duration (wall): 54s<br>  Total code changes:    4 lines added, 0 lines removed<br>  Usage by model:<br>      claude-haiku-4-5:  572 input, 16 output, 0 cache read, 0 cache write ($0.0007)<br>       claude-opus-4-8:  3.0k input, 1.9k output, 98.4k cache read, 11.5k cache write ($0.2281)</pre><h4>Prompt 2 Comparison Observations:</h4><p>I chose to showcase this prompt because it highlights a couple of interesting observations.</p><ol><li>Q knowledge gives a more concise q solution with sv. Claude without the additional q context writes a working solution, but with a more convoluted implementation of sv.</li><li>In both cases Claude was unable to mention or use the built-in Q utility .Q.dd — I did notice in various prompts that Claude’s ability to use built-in .Q functions was lacking sometimes, and this was one example of this happening. This could be related to an incomplete set of the .Qutilities referenced in the skill.</li><li>This also raises an interesting point where not using the q skill to get a working solution saves a tiny bit, likely down to Claude saving on context not being loaded from the q-knowledge skill (it’s pretty negligible, though, and longer sessions will almost always give savings with the additional q context loaded in).</li></ol><h3>Q linting — Skill or Hook?</h3><p>One notable general observation I made when prompting Claude with q tasks is the unpredictability with which the Q linting skill is triggered. This was particularly frustrating before I set up the Q linting dependencies in my environment; when the skill auto-triggered, Claude struggled and tried to get me to set it up (wasting tokens).</p><pre>● I&#39;ll start by loading the q skill for guidance, then write the function.<br><br>● Skill(q-knowledge:q)<br>  ⎿  Successfully loaded skill<br><br>● Write(joinsym.q)<br>  ⎿  Wrote 2 lines to joinsym.q<br>      1 / joinsym - join a symbol with an extension symbol, e.g. (`AAPL;`O) -&gt; `AAPL.O<br>      2 joinsym:{[sym;ext] `$ (string sym),&quot;.&quot;,string ext}<br><br>● Now let me test it and lint it:<br><br>● Bash(q joinsym.q -q &lt;&lt;&lt; &quot;show joinsym[\`AAPL;\`O]; exit 0&quot;)<br>  ⎿  `AAPL.O<br><br>● Skill(q-knowledge:qlint-snippet)<br>  ⎿  Successfully loaded skill<br><br>● The function works (AAPL.O). Now let me run qlint:<br><br>● Bash(/home/rob/.claude/plugins/cache/kx-skills/q-knowledge/0.1.0/skills/qlint-snippet/scripts/run.sh &lt;&lt;&#39;EOF&#39;<br>      joinsym:{[sym;ext] `$ (string sym),&quot;.&quot;,string ext}…)<br>  ⎿  qlint_snippet: qlint.q_ not found at /home/rob/developer-1.6.0-linux/analyst/ws/qlint.q_<br>       Set QLINT_DIR to the directory containing qlint.q_<br>     EXIT: 2<br><br>● qlint isn&#39;t found at the configured path. Let me do a quick narrow check in obvious locations before asking:<br><br>  Listing 1 directory… (ctrl+o to expand)<br>  ⎿  $ ls -d /home/rob/developer-1.6.0-linux 2&gt;/dev/null; find /home/rob/.kx /home/rob/developer* -name &#39;qlint.q_&#39; 2&gt;/dev/null | head</pre><p>I would argue any post-code generation linting should be implemented as a PostToolUse <a href="https://code.claude.com/docs/en/hooks-guide">hook</a>, not a skill. This gives the user opt-in control — set it up if you want it, and when it runs, it runs deterministically on every edit Claude makes to Q code. At the moment, if someone wants to use the q-knowledge skill but doesn’t have q-lint set up, Claude struggles whenever it decides the qlint skill is relevant.</p><h3>Conclusion and Next Steps</h3><p>This was an initial practical look at how the KX q-knowledge skill shapes Claude’s behaviour as a q programming assistant. A more rigorous evaluation would test across a broader range of q tasks and aggregate results across multiple runs per prompt — I&#39;ll leave this one to someone with more tokens to burn.</p><p>The KX q-knowledge skill demonstrably improves output quality and reduces token cost in error-prone sessions. Perfect context doesn’t exist on day one (or ever); building it is an iterative and fluid process. The gaps identified here are a useful starting point.</p><p>In a future post, I will showcase constructing a CLAUDE.md file and how project-level context can further accelerate development and enable Claude to actively use KDB-X modules in the code it writes, going well beyond basic coding questions that probably don’t require Claude to begin with.</p><p>If you have feedback, questions, or are using Claude Code in your own KDB/KX work, I’d love to hear from you!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=45d9e44bfc64" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>