nyxcore-systems
7 min read

Unlocking Smarter Workflows: Injecting Repository Docs with `{{docs}}`

We've just shipped a powerful new feature that allows you to inject repository documentation directly into your AI workflows, enabling more context-aware and accurate automation. Dive into the `{{docs}}` variable, our new Extension Builder, and the technical journey.

workflow-automationLLM-opsdeveloper-toolsdocumentationnextjsprismagithub-apitypescript

Ever wished your AI workflows could truly understand the nuances of your codebase? For anyone building intelligent automation, especially with Large Language Models (LLMs), providing the right context is paramount. Without it, even the smartest models can veer off course, generating irrelevant or incorrect outputs. Manually feeding documentation, code snippets, or project specifications into every prompt is tedious, error-prone, and simply doesn't scale.

That's why we're thrilled to announce a significant leap forward in our workflow engine: the ability to inject repository documentation directly into your AI workflows. This isn't just about passing text; it's about making your workflows inherently smarter, more context-aware, and ultimately, more effective.

At the heart of this feature is the new {{docs}} template variable, a slick UI for selecting documentation, and a brand-new "Extension Builder" workflow template designed to leverage this power.

The Power of Context: Introducing {{docs}}

Imagine an AI agent tasked with adding a new feature to your project. Instead of guessing, it can now read your README.md, your ARCHITECTURE.md, or specific module documentation before generating a single line of code or a single prompt.

This is precisely what {{docs}} enables. Within any workflow step's prompt, you can now use:

  • {{docs}}: This variable will be dynamically populated with the content of all selected documentation files.
  • {{docs.ProjectName}}: If you're working with multiple linked projects, you can target documentation from a specific project.

Behind the scenes, our workflow engine now includes sophisticated logic to:

  1. Fetch Files from GitHub: Using your BYOK (Bring Your Own Key) token, we securely retrieve the specified files from your GitHub repositories.
  2. Smart Truncation: To keep context windows manageable and relevant, file content is truncated (currently at 50k characters per file), ensuring that only the most pertinent information is passed.
  3. Robust Error Handling: Each file fetch is handled individually, so if one file fails, it won't derail the entire documentation injection process.

This content is then seamlessly integrated into the ChainContext, making it available to any subsequent step that references {{docs}}, leading to significantly more accurate and relevant AI outputs.

A Seamless User Experience for Documentation Management

Integrating documentation into your workflows should be intuitive, not another chore. We've focused heavily on the user experience:

  • Documentation Picker UI: When creating or editing a workflow, you'll find a new, intuitive UI in the dashboard. Here, you can easily toggle available projects (any project with a configured GitHub repository) and select specific files by path. For convenience, we default to common documentation files like CLAUDE.md and README.md.
  • "Linked Documentation" Display: In the workflow settings panel, you can now quickly see which documentation files are linked to your workflow, providing an at-a-glance overview of the context being provided.
  • Enhanced Workflow Control: We've also rolled out several quality-of-life improvements for managing your workflows:
    • Inline Review Controls: For workflows paused at a review step, a prominent "Continue" button now appears directly on the step, making it easier to resume. These paused steps also auto-expand for immediate visibility.
    • Dashboard Actions: Each workflow card on your dashboard now includes quick-access Pause, Stop, and Delete action buttons, giving you immediate control over your running automations.
    • Cancel Mutation: A new backend cancel mutation allows you to gracefully stop running or paused workflows, marking them as failed.

Supercharging Development: The Extension Builder

To truly showcase the power of documentation injection, we've developed a brand-new workflow template: the Extension Builder. This template is designed to streamline the entire process of creating new extensions or features for an existing codebase.

The Extension Builder orchestrates a series of specialized steps, all leveraging {{docs}} for deep context:

  1. Analyze Target Repo: Understands the existing codebase structure and conventions.
  2. Design Features: Proposes new features based on requirements and existing documentation.
  3. Review Design: Allows human oversight and feedback on the proposed features.
  4. Extend Codebase: Generates implementation plans and code snippets.
  5. Implementation Prompts: Breaks down the work into actionable prompts for developers.

By feeding relevant repository documentation into each of these steps, the Extension Builder can generate more accurate analysis, more coherent feature designs, and more practical implementation prompts, drastically accelerating your development cycle. We've also updated existing templates like deepWisdom and deepPrompt to include a {{docs}} section, so they too can benefit from this enhanced context.

Behind the Scenes: Our Technical Journey

Implementing this feature involved touching various parts of our stack:

  • Prisma Schema Evolution: We extended our Workflow model in prisma/schema.prisma with a docRefs Json? field to store the selected documentation references.
  • Backend Intelligence: In src/server/services/workflow-engine.ts, we introduced the DocRef interface and the loadDocumentationContent() function, which orchestrates the GitHub file fetching, content truncation, and per-file error handling. The ChainContext was extended with documentationContent and documentationByProject to make this data accessible.
  • Template Variable Resolution: Our resolvePrompt() logic was updated to correctly parse and inject content for {{docs}} and {{docs.ProjectName}}.
  • API & Validation: We added docRefSchema Zod validation and integrated docRefs into our create and duplicate workflow mutations in src/server/trpc/routers/workflows.ts. A new availableDocProjects query was also added to power the UI.
  • Next.js UI: The documentation picker was built into src/app/(dashboard)/dashboard/workflows/new/page.tsx, and the linked documentation display in src/app/(dashboard)/dashboard/workflows/[id]/page.tsx.

Navigating the Rapids: Lessons Learned

No development journey is without its challenges. Here are a couple of key lessons we picked up along the way:

The Prisma Client Caching Conundrum

After modifying our Prisma schema to add the docRefs field, we ran npx prisma db push and npx prisma generate. Both commands reported success. However, our dev server kept throwing runtime errors, complaining that docRefs didn't exist on the Workflow model.

  • Investigation: We first suspected a prisma generate failure, but a quick grep revealed docRefs was indeed present in node_modules/.prisma/client/index.d.ts (many occurrences!). This indicated the types were correctly generated.
  • The Culprit: The issue wasn't with Prisma, but with the Next.js dev server aggressively caching the old Prisma client in memory. Even though new files were generated, the running server wasn't picking them up.
  • Solution: The fix was surprisingly simple but crucial: kill the dev server, rm -rf .next (to clear all build artifacts and caches), and then restart the server.
  • Takeaway: When working with generated code (like Prisma clients) in a modern dev environment, always suspect caching issues with your dev server. A clean restart and cache clear can save hours of head-scratching.

Workflow Template Step Dependencies

When designing the Extension Builder, our initial thought was to reuse existing, generic steps like deepFeatures, deepReview1, deepExtend, and deepPrompt. However, these steps were designed for other workflows and referenced specific labels (e.g., {{steps.Idea.content}}, {{steps.Research.content}}) that didn't exist in the Extension Builder's new pipeline (where step 1 is "Analyze Target Repo").

  • Problem: Attempting to reuse these steps led to broken prompt references, as the required context from previous steps simply wasn't there under the expected labels.
  • Solution: We created five new, extension-specific step templates (extensionAnalyze, extensionFeatures, extensionReview, extensionExtend, extensionPrompt). Each of these was carefully crafted with the correct step label references (e.g., {{steps.Analyze Target Repo.content}}, {{steps.Design Features.content}}), ensuring a coherent flow for the Extension Builder.
  • Takeaway: Workflow design requires meticulous attention to step inputs, outputs, and their interdependencies. While reusability is great, new pipelines often demand bespoke templates tailored to their unique flow. It's also worth noting that once a workflow is created, its step prompts are "baked in" to the database; changing constants only affects new workflows.

What's Next on Our Horizon?

We're not stopping here! Our immediate next steps for enhancing the workflow experience include:

  • Improved Implementation Prompts Output: When the Extension Builder (or any workflow) generates multiple implementation prompts, we want to display each prompt as a separate, collapsible card with a brief description, rather than one massive markdown blob. This will significantly improve readability and usability.
  • "Copy Single Prompt" Button: For enhanced convenience, we'll add a button to easily copy individual prompts to the clipboard.
  • End-to-End Testing: A thorough end-to-end test of the full Extension Builder pipeline with a real GitHub repository is on the docket to ensure robustness.
  • Prompt Count Indicator: Adding a prompt count (e.g., "Implementation Prompts (7 prompts)") to the step header will provide immediate clarity on the amount of work generated.

Conclusion

The introduction of {{docs}} and the Extension Builder marks a pivotal moment in our mission to create smarter, more autonomous, and truly context-aware AI workflows. By bridging the gap between your codebase's documentation and your AI agents, we're empowering developers to build more reliable, efficient, and intelligent automation than ever before. We can't wait to see what you build with it!