<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Roger Chien</title>
    <description>The latest articles on DEV Community by Roger Chien (@rjchien728).</description>
    <link>https://dev.to/rjchien728</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3900174%2Ffc7ea168-9c68-4b50-812a-f0e96f753d31.jpeg</url>
      <title>DEV Community: Roger Chien</title>
      <link>https://dev.to/rjchien728</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rjchien728"/>
    <language>en</language>
    <item>
      <title>archery-cli: A psql-style CLI for Archery — Query Databases from Terminal or AI Agents</title>
      <dc:creator>Roger Chien</dc:creator>
      <pubDate>Mon, 27 Apr 2026 10:06:25 +0000</pubDate>
      <link>https://dev.to/rjchien728/archery-cli-connect-ai-tools-to-your-sql-audit-platform-4kdb</link>
      <guid>https://dev.to/rjchien728/archery-cli-connect-ai-tools-to-your-sql-audit-platform-4kdb</guid>
      <description>&lt;p&gt;If you've ever copy-pasted query results from a web UI just to paste them into ChatGPT, this might save you that step.&lt;/p&gt;

&lt;p&gt;At my company, we use &lt;a href="https://github.com/hhyo/Archery" rel="noopener noreferrer"&gt;Archery&lt;/a&gt; for SQL audit and read-only queries against our databases.&lt;/p&gt;

&lt;p&gt;Archery has a nice web UI, but our AI tools (Claude Code, Cursor, Codex) cannot use a web UI. So I built &lt;a href="https://github.com/rjchien728/archery-cli" rel="noopener noreferrer"&gt;&lt;code&gt;archery-cli&lt;/code&gt;&lt;/a&gt;: a small &lt;code&gt;psql&lt;/code&gt;-style command line client that wraps Archery's HTTP API. Both humans and AI agents can use it from the shell.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fktbwxmclujwe3ouydzev.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fktbwxmclujwe3ouydzev.png" alt=" " width="800" height="448"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why a CLI?
&lt;/h2&gt;

&lt;p&gt;A CLI is the easiest way to bring AI tools into a workflow that already exists.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;AI agents already know how to run shell commands.&lt;/li&gt;
&lt;li&gt;A &lt;code&gt;psql&lt;/code&gt;-style interface is familiar to engineers.&lt;/li&gt;
&lt;li&gt;It does not bypass Archery — every query still goes through the same audit endpoint.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So we keep the audit flow, and the AI gets a tool it can actually use.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it does
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Run &lt;code&gt;SELECT&lt;/code&gt; queries against any database that Archery exposes.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;psql&lt;/code&gt;-style meta commands: &lt;code&gt;\l&lt;/code&gt;, &lt;code&gt;\dt&lt;/code&gt;, &lt;code&gt;\d &amp;lt;table&amp;gt;&lt;/code&gt;, &lt;code&gt;\dn&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Multiple output formats: aligned table (default), CSV, JSON, and expanded (&lt;code&gt;-x&lt;/code&gt;) for wide rows.&lt;/li&gt;
&lt;li&gt;DB name aliases, e.g. &lt;code&gt;prod=db_orders_prod&lt;/code&gt;, so you can type &lt;code&gt;archery prod&lt;/code&gt; instead of the full name.&lt;/li&gt;
&lt;li&gt;Read SQL from &lt;code&gt;-c&lt;/code&gt;, from a file with &lt;code&gt;-f&lt;/code&gt;, or from stdin.&lt;/li&gt;
&lt;li&gt;One static Go binary. No runtime dependency.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;archery mydb &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s1"&gt;'SELECT count(*) FROM orders'&lt;/span&gt;
archery mydb &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s1"&gt;'SELECT * FROM users LIMIT 10'&lt;/span&gt; &lt;span class="nt"&gt;--csv&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; users.csv
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'SELECT version()'&lt;/span&gt; | archery mydb
archery mydb &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s1"&gt;'\dt'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  AI integration
&lt;/h2&gt;

&lt;p&gt;The repo ships a skill file: &lt;a href="https://github.com/rjchien728/archery-cli/blob/main/skills/archery.skill.md" rel="noopener noreferrer"&gt;&lt;code&gt;archery.skill.md&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For Claude Code, drop it into your skills folder:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-O&lt;/span&gt; https://raw.githubusercontent.com/rjchien728/archery-cli/main/skills/archery.skill.md
&lt;span class="nb"&gt;mv &lt;/span&gt;archery.skill.md ~/.claude/skills/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For other AI tools (Cursor, Windsurf, Codex…), the skill file is plain Markdown. Paste it into the tool's system prompt or custom instructions.&lt;/p&gt;

&lt;p&gt;After that, your AI can answer real data questions on its own:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;You:&lt;/strong&gt; How many orders came in last week in prod?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Claude:&lt;/strong&gt; &lt;em&gt;runs&lt;/em&gt; &lt;code&gt;archery prod -c 'SELECT count(*) FROM orders WHERE created_at &amp;gt; now() - interval 7 day'&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Claude:&lt;/strong&gt; 12,483 orders last week.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Security details
&lt;/h2&gt;

&lt;p&gt;This tool talks to a real production audit platform, so I want to be careful. Here is what &lt;code&gt;archery-cli&lt;/code&gt; does:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;SELECT-only.&lt;/strong&gt; Archery's &lt;code&gt;/query/&lt;/code&gt; endpoint blocks DML and DDL on the server side. The CLI documents itself as a read-only client and does not try to work around that.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No password in argv.&lt;/strong&gt; There is no &lt;code&gt;--password&lt;/code&gt; flag on purpose. Credentials never appear in &lt;code&gt;ps&lt;/code&gt; output or shell history.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Password prompt on &lt;code&gt;/dev/tty&lt;/code&gt;.&lt;/strong&gt; If &lt;code&gt;ARCHERY_PASSWORD&lt;/code&gt; is not set, the CLI asks for it on the terminal — even when stdin is a pipe. CI and containers should set the env var; humans get a normal prompt.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cookie cache with strict permissions.&lt;/strong&gt; After login, the session cookie is saved to &lt;code&gt;~/.cache/archery/cookies.json&lt;/code&gt; with mode &lt;code&gt;0600&lt;/code&gt;. If the home directory is not available, the CLI fails fast instead of falling back to an unsafe path.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TLS by default.&lt;/strong&gt; For internal deployments, &lt;code&gt;--cacert&lt;/code&gt; lets you trust a private CA. There is also &lt;code&gt;--insecure&lt;/code&gt; to skip verification, but it is clearly marked as unsafe in the help text and README.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CSRF handled the Django way.&lt;/strong&gt; The CLI reads the &lt;code&gt;csrftoken&lt;/code&gt; cookie from its jar and sends it as &lt;code&gt;X-CSRFToken&lt;/code&gt; on each request, like a normal Archery web client.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Proxy support.&lt;/strong&gt; Honours &lt;code&gt;HTTPS_PROXY&lt;/code&gt; / &lt;code&gt;HTTP_PROXY&lt;/code&gt;, with native support for &lt;code&gt;socks5://&lt;/code&gt; and &lt;code&gt;socks5h://&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are small details, but together they keep the tool safe enough to run in a real engineering team.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;go &lt;span class="nb"&gt;install &lt;/span&gt;github.com/rjchien728/archery-cli/cmd/archery@latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or grab a binary from the &lt;a href="https://github.com/rjchien728/archery-cli/releases" rel="noopener noreferrer"&gt;releases page&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Set a few environment variables (&lt;code&gt;ARCHERY_URL&lt;/code&gt;, &lt;code&gt;ARCHERY_INSTANCE&lt;/code&gt;, &lt;code&gt;ARCHERY_USERNAME&lt;/code&gt;, &lt;code&gt;ARCHERY_PASSWORD&lt;/code&gt;) and you are ready to go. Full setup is in the &lt;a href="https://github.com/rjchien728/archery-cli#configure" rel="noopener noreferrer"&gt;README&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Closing
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;archery-cli&lt;/code&gt; is open source under the MIT license. If your team also uses Archery and wants AI tools to query databases without leaving the audit flow, give it a try:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Repo: &lt;a href="https://github.com/rjchien728/archery-cli" rel="noopener noreferrer"&gt;github.com/rjchien728/archery-cli&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Issues and PRs are welcome.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Does your team use a similar setup? I'm curious what SQL audit tools other people are using, and how you connect AI tools to them — drop a comment below.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>cli</category>
      <category>sql</category>
      <category>showdev</category>
    </item>
  </channel>
</rss>
