<?xml version="1.0" encoding="utf-8"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Anthropic · QuickRef</title><link>https://qref.eknath.dev/tags/anthropic/</link><description>Anthropic updates from QuickRef</description><language>en-us</language><atom:link href="https://qref.eknath.dev/tags/anthropic/index.xml" rel="self" type="application/rss+xml"/><lastBuildDate>Mon, 18 Aug 2025 00:00:00 +0000</lastBuildDate><item><title>Claude CLI</title><link>https://qref.eknath.dev/ai/claude/</link><guid isPermaLink="true">https://qref.eknath.dev/ai/claude/</guid><pubDate>Mon, 18 Aug 2025 00:00:00 +0000</pubDate><category>claude</category><category>cli</category><category>ai</category><category>anthropic</category><category>npm</category><description>A quick reference for installing and using the official Claude CLI to interact with Anthropic's AI models from your terminal.</description><content:encoded><![CDATA[<h2 id="overview">Overview</h2>
<p><code>@anthropic-ai/claude-code</code> is the official command-line interface (CLI) for Claude, developed by Anthropic. It allows developers to interact with Claude models directly from the terminal, making it easy to integrate AI into development workflows, analyze code, and generate content without leaving the command line.</p>
<h2 id="installation">Installation</h2>
<p>You must have Node.js (version 18 or higher) and npm installed.</p>
<p>To install the Claude CLI globally on your system, run the following command:</p>
<div class="highlight"><pre tabindex="0" style="color:#e6edf3;background-color:#0d1117;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>npm install -g @anthropic-ai/claude-code
</span></span></code></pre></div><h2 id="configuration">Configuration</h2>
<p>The first time you run the <code>claude</code> command, it will guide you through an authentication process in your web browser.</p>
<ol>
<li>Open your terminal.</li>
<li>Run the command <code>claude</code>.</li>
<li>Follow the on-screen prompts to log in to your Anthropic account. This requires an active subscription (like Claude Pro) or a funded account on the Anthropic Console.</li>
</ol>
<h2 id="usage">Usage</h2>
<h3 id="interactive-mode">Interactive Mode</h3>
<p>The primary way to use the tool is by starting an interactive chat session within your project directory.</p>
<div class="highlight"><pre tabindex="0" style="color:#e6edf3;background-color:#0d1117;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="color:#8b949e;font-style:italic"># Navigate to your project folder</span>
</span></span><span style="display:flex;"><span>cd /path/to/your-project
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#8b949e;font-style:italic"># Start the interactive CLI</span>
</span></span><span style="display:flex;"><span>claude
</span></span></code></pre></div><p>Once inside the session, you can ask questions about your codebase, generate files, or ask for explanations.</p>
<p><strong>Example Prompts:</strong></p>
<pre tabindex="0"><code>&gt; Explain the purpose of the `utils.js` file.
&gt; Write a README.md file for this project.
&gt; What are the main dependencies in package.json?
</code></pre><h3 id="piping-and-one-off-commands">Piping and One-off Commands</h3>
<p>You can pipe the content of files to the <code>claude</code> command for specific, one-time tasks using the <code>-p</code> (prompt) flag.</p>
<p><strong>Syntax:</strong></p>
<div class="highlight"><pre tabindex="0" style="color:#e6edf3;background-color:#0d1117;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>cat <span style="color:#ff7b72;font-weight:bold">[</span>FILENAME<span style="color:#ff7b72;font-weight:bold">]</span> | claude -p <span style="color:#a5d6ff">&#34;[YOUR_PROMPT]&#34;</span>
</span></span></code></pre></div><p><strong>Examples:</strong></p>
<div class="highlight"><pre tabindex="0" style="color:#e6edf3;background-color:#0d1117;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="color:#8b949e;font-style:italic"># Get an explanation of a file</span>
</span></span><span style="display:flex;"><span>cat src/api.js | claude -p <span style="color:#a5d6ff">&#34;Explain what this code does in simple terms.&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#8b949e;font-style:italic"># Refactor a file</span>
</span></span><span style="display:flex;"><span>cat components/LegacyComponent.jsx | claude -p <span style="color:#a5d6ff">&#34;Refactor this class component into a functional component using React Hooks.&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#8b949e;font-style:italic"># Add documentation to a file</span>
</span></span><span style="display:flex;"><span>cat scripts/deploy.sh | claude -p <span style="color:#a5d6ff">&#34;Add comments to this shell script explaining each step.&#34;</span>
</span></span></code></pre></div><h2 id="effective-usage-tips">Effective Usage Tips</h2>
<ul>
<li><strong>Context is Key:</strong> Always run the <code>claude</code> command from your project&rsquo;s root directory. The CLI automatically gathers context from your file structure to provide more relevant answers.</li>
<li><strong>Be Specific:</strong> When piping commands, be very clear in your prompt about the desired action and output format.</li>
<li><strong>Use for Reviews:</strong> Pipe your code before committing to get a quick code review and suggestions for improvement. <code>git diff HEAD | claude -p &quot;Review these changes for potential bugs.&quot;</code></li>
<li><strong>Combine with other tools:</strong> Use <code>claude</code> as part of a larger script. For example, you could find all <code>TODO</code> comments and ask Claude to suggest solutions for them.</li>
</ul>
]]></content:encoded></item></channel></rss>