Introduction

The design philosophy of DeepSeek Harness (DSH) is “everything is a plugin.” In practice, it is common to need the model to remember long-term constraints, such as “comments in this session must be written in Chinese” or “do not modify existing test cases.” These requirements often need to persist across turns.

dsh-baize-rules (Baize) is a DSH plugin designed to solve this problem. It injects user-defined persistent “must do / must not do” requirements as plain-text rules into the model request at the beginning of a conversation.

Core Features

The plugin provides a complete rule management mechanism:

  1. Triple scopes, all injected
    Rules are divided into three scopes: global (global, applies to all sessions), session (current session), and project (current working directory). Wherever a rule is stored, as long as it is active, it is injected into the model.

  2. Persistent storage
    All rule data is written to $DSH_HOME (default is ~/.dsh), and is preserved across sessions and restarts.

  3. Specificity priority
    Rendering order is project > session > global. When context budget is limited, more specific rules are retained first.

  4. Fault tolerance
    Rule file reading is fault tolerant. If a scope’s file is corrupted or broken by manual editing, that scope is set to empty and a warning is issued, rather than interrupting the entire conversation flow.

  5. Deduplication and long-thread retention
    Duplicate injection is suppressed via SHA-1 hashing. After session lifecycle changes (such as startup, resume, clear, compaction) or rule text updates, the rule snapshot is automatically republished, ensuring rules are not forgotten in long conversations.

  6. Safety protection
    Special characters in rule content (such as </system-reminder>) are escaped to prevent user text from unintentionally closing the plugin’s injected wrapper.

  7. Unified data source
    The command-line interface (CLI) and Web UI share the same storage core, ensuring consistent state.

  8. Tags and templates
    Rules support tags (such as #frontend) for UI filtering. Tags do not consume the model context budget by default unless the injectTags option is enabled. Frequently used rules can be saved as templates. Applying a template creates a copy of its content, and later template changes do not affect rules that have already been applied.

  9. Conflict-safe writes
    Writes carry a file version number. If the file is detected as modified elsewhere, the write operation is rejected and the user is prompted to retry, avoiding data loss.

Installation and Enablement

Install the plugin via npm to the specified profile (default web profile):

dsh plugin --profile web add dsh-baize-rules@0.2.4

If DSH is managed by pm2, restart the process after installation to load the new plugin:

pm2 restart dsh

Typical Usage

The plugin provides a complete set of CLI commands for management:

  • View current rules:
    /baize-rules
This is equivalent to listing rules across all scopes.
  • Add a rule (added to the session scope by default):
    /baize-rules add Write comments in Chinese.
  • Add a global rule:
    /baize-rules global add Don't delete or rewrite existing tests.
  • List a specific scope:
    /baize-rules list project
  • Edit, disable, or enable rules:
    /baize-rules edit <id>
    /baize-rules disable <id>
    /baize-rules enable <id>
  • Switch the default scope:
    /baize-rules scope global
  • Clear rules:
    /baize-rules clear session

Applicable Scenarios and Notes

Applicable scenarios:
- Enforced constraints for personal habits (such as language and format).
- General rules across projects.
- Temporary constraints within a single session.

Difference from AGENTS.md:
DSH includes the @deepseek-ai/dsh-agent-instructions plugin by default, which reads AGENTS.md in the workspace. dsh-baize-rules complements it: the former is suitable for project-level, version-controlled, team-shared conventions; the latter is suitable for personal, cross-project, or session-specific needs. Both are injected via user/message and share the same priority mechanism.

Important notes:
- Rules are plain text and do not require must/mustNot markers; the meaning is expressed by the content language itself.
- If no rules are currently active, nothing is injected.
- The plugin runs with the permissions of the current DSH process. It is recommended to check the source code and license before installation.

Conclusion

dsh-baize-rules provides DSH users with a tool to manage model behavior at the conversation level. By injecting rules as persistent user/message entries, it addresses the problem of remembering long-term constraints and makes model behavior more controllable.

  • Directory page: https://www.skillhub.cn/plugins/bvcvb/dsh-baize-rules
  • GitHub: https://github.com/bvcvb/dsh-baize-rules