Skip to main content

What it does

  • Accepts questions from the terminal
  • Searches Alchemyst for relevant stored context
  • Injects that context into the prompt
  • Generates grounded responses using an LLM
This pattern is ideal for developer tools, internal assistants, and debugging workflows. The full source code for this CLI agent is also available in our public repository. It includes this Node.js implementation as well as a Python version of the same context-aware agent. If you prefer Python, you can use that implementation directly or adapt it to your workflow. View the repository:

Prerequisites

You’ll need:
  • Node.js 18+
  • An Alchemyst AI API key
  • A Google Gemini API key

1. Set your environment variables

How it works

The flow is simple:
  • Accept a user question from the CLI
  • Search Alchemyst for relevant context
  • Inject retrieved context into the LLM prompt
  • Generate and display the response
If no relevant context is found, the agent falls back to general model knowledge.

2.Install dependencies

3.Add the code

4. Run the code

Build Beyond the CLI

You’ve built a foundational context-aware agent, but this is just the beginning. The Alchemyst AI platform is designed to be the “brain” of your larger systems. From here, you can extend this pattern to: Persistent Memory: Enable long-term recall by saving user preferences in dedicated namespaces. Knowledge Ingestion: Connect your agent to PDFs, GitHub repos, or Slack history for deep domain expertise. Serverless Agents: Wrap this logic in a FastAPI or Next.js route to power a web-based AI microservice.