Synchronize AI coding–agent knowledge files (rules, templates, guidelines) across your project.

knowhub is a lightweight CLI tool that synchronizes “resources” (local files, directories, or remote URLs) into one or more output locations within your project. It was designed with AI coding agents in mind—Cursor, Copilot, Windsurf, and more—so you can centrally manage coding guidelines, AI prompts, rule files, or shared snippets and distribute them across different directories without manual copying.
Running npx knowhub will:
- Load & validate a single configuration.
- Fetch each resource (from disk or over HTTP(S)).
- Place each resource into all specified output paths by copying or symlinking (per your preference).
This ensures that any AI-agent rules, templates, or shared knowledge files stay in sync project-wide, with minimal overhead.
- AI Coding Agents Need Consistency: In large organizations, AI agents often rely on rule files (Cursor Rules, Copilot instructions, Windsurf settings, etc.) stored in project directories. Keeping those files up to date across multiple submodules or repos can be tedious.
- Centralized Knowledge, Decentralized Usage: With knowhub, you place your master rules (Markdown, YAML, JSON, or any format) in a central folder (or even a remote URL), then declare where each AI agent expects its rules. knowhub handles distribution automatically.
- Single-Command Synchronization: Run npx knowhub to fetch and place resources—no subcommands needed (aside from init).
- Explicit Overwrite Control: Each resource can be configured with overwrite: true | false. If false, existing outputs remain untouched; if true, outputs are overwritten.
- Copy or Symlink: Each resource's symlink property can be true (create symbolic links; auto-fallback to copy on Windows if symlinks aren't permitted) or false/omitted (duplicate files or directory trees).
- Remote Content Support: Resources defined by url are fetched via HTTP(S) and written as text files.
- Directory Tree Distribution: If a resource’s path points to a directory, knowhub can recursively copy or symlink that entire directory tree into each output folder.
- Dry-Run Mode: Preview actions with --dry-run to see which files would be written or skipped, without modifying disk.
Install knowhub as a development dependency:
knowhub searches for your configuration in these locations (in this order):
- .knowhubrc (JSON or YAML)
- .knowhubrc.json
- .knowhubrc.yaml or .knowhubrc.yml
- .knowhubrc.js
- .knowhubrc.ts
- package.json, under a top-level "knowhub" field
If multiple files exist, the one with highest precedence is loaded. If no configuration is found, knowhub exits with an error.
Each entry in the resources array must conform to this schema:
knowhub comes with several built-in plugins:
Handles local filesystem resources (files and directories).
Example:
Fetches resources from HTTP(S) URLs with advanced features.
Example:
Below is a minimal .knowhubrc.yaml that demonstrates common use cases:
You can also place this in a TypeScript file (.knowhubrc.ts) or JSON (.knowhubrc.json) with the same structure:
Simply run this in your project root:
The tool will:
-
Find and load your configuration.
-
Validate that each resource has a valid plugin name, proper pluginConfig, a boolean overwrite (defaults to true), and one or more outputs.
-
Fetch each resource using the specified plugin:
- Local plugin: Resolves files or directories on disk, optionally creating symlinks.
- HTTP plugin: Performs HTTP requests with custom headers, timeouts, and authentication.
- Custom plugins: Any registered plugins with their specific fetch logic.
-
Copy, Symlink, or Write each resource into every output path:
- Local files → copy or create symlinks based on plugin configuration; respect overwrite.
- Local directories → recursively copy or create directory symlinks; respect overwrite.
- Remote content → write the fetched content into each output file; respect overwrite.
-
Print Summary:
- Number of outputs created (new files/directories).
- Number of outputs updated (existing files/directories overwritten).
- Number of outputs skipped because they already existed and overwrite: false or content is identical.
Dry-run preview: To see what would happen without modifying anything, run:
This prints, for each resource and output, whether it would copy, symlink, or skip.
Quiet mode: To suppress all output (useful for CI/CD), run:
Custom config path: If your config file is not in the default location, specify:
Suppose you maintain a centralized set of Cursor Rules in a shared folder (./ai-rules/cursor). To distribute them to each project’s .cursor/rules folder:
Running npx knowhub will recursively copy everything under ./ai-rules/cursor/* into .cursor/rules/*.
Share Copilot Instructions
If you keep your Copilot instruction file in a single location (./ai-rules/copilot/instructions.md), and you want to place it in .github/copilot-instructions.md:
On POSIX systems, this will create a symlink:
On Windows, if symlinks aren't allowed, it will copy the file instead.
If your Windsurf configuration is hosted remotely:
Running npx knowhub will fetch the YAML text and write it to .windsurfrules and docs/ai/windsurf-config.yaml, unless those files already exist.
To copy a folder of AI prompt templates (./ai-templates) into two places:
This recursively copies all files and subdirectories from ./ai-templates/* into src/ai/prompt-templates/* and docs/ai/prompt-templates/*.
For APIs requiring authentication or custom headers:
This fetches from an authenticated API with custom headers and a 15-second timeout.
Integrate knowhub into your continuous-integration pipeline to ensure that generated outputs remain in sync with your configuration. For example, in GitHub Actions:
- Run npx knowhub to update all outputs.
- Commit and push any new or changed files so your repository always has the latest AI prompts, rules, or guidelines.
knowhub supports a powerful plugin system that allows you to extend its functionality with custom resource fetchers. You can create plugins to fetch from APIs, databases, cloud services, or any other data source.
knowhub automatically loads plugins specified in your configuration, eliminating the need for manual registration:
Add custom plugins to your knowhub configuration using the plugins field:
- Local plugins: Relative paths to your plugin files (.ts, .js)
- NPM packages: Node module names that export knowhub plugins
- Multiple export patterns: Supports both default and named exports
Example with multiple plugin types:
- Built-in plugins: local (filesystem), http (HTTP/HTTPS requests)
- Example plugins: See the examples/ directory for plugin development guides and sample implementations
- Community plugins: Check npm for community-contributed knowhub plugins
For detailed instructions on creating your own plugins, including a complete GitHub plugin example, see the Plugin Development Guide in the examples/ directory.
The guide covers:
- Plugin architecture and interfaces
- Dynamic loading setup
- Configuration validation
- Error handling best practices
- Complete working examples
This project is licensed under the MIT License. See the LICENSE file for details.