mcpField
M
mikrotik-routeros-rsc

mikrotik-routeros-rsc

github.com/alexandre-machadoCloud & DevOps6324 installsUpdated 5w ago
Repository

About mikrotik-routeros-rsc

A skill for creating, editing, and reviewing MikroTik RouterOS .rsc scripts. It emphasizes idempotent patterns, linting, and safe validation before importing scripts.

Key features

  1. 01Idempotent script patterns
  2. 02Linting with lint_rsc.py
  3. 03Dry-run import validation
  4. 04Error handling guidance
  5. 05RouterOS v7 practices

Use cases

  1. 01Create RouterOS configuration scripts
  2. 02Review existing .rsc files for risk
  3. 03Validate syntax before importing
  4. 04Prepare controlled production imports

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/alexandre-machado/ai-stuffs --skill mikrotik-routeros-rsc

After installing, type/mikrotik-routeros-rscin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

references/
EXAMPLES.md
LANGUAGE.md
LINTER_RULES.md
RSC_GUIDE.md
SAFE_PRACTICES.md
scripts/
lint_rsc.py

Details

From the project README

Skill: RouterOS .rsc

This skill guides the creation, editing, and review of RouterOS (.rsc) scripts with safe and idempotent patterns, plus validation before import.

Quick workflow

  1. Define script objective and scope.
  2. Apply idempotent patterns (see References).
  3. Validate syntax and risks with the linter (scripts/lint_rsc.py).
  4. Test import with dry-run and on-error.
  5. Import in a controlled manner to production.

Essential practices

  • Prefer find where ... + conditionals before add/set.
  • Avoid broad policies in /system script add policy=....
  • Use :onerror and :jobname for robustness and single instance.
  • Never include destructive commands (system reset-configuration, etc.).
  • Parameterize and isolate scopes (:local vs :global).

Validation and testing

  • Lint: python scripts/lint_rsc.py path/to/script.rsc.
  • Safe import (RouterOS ≥ 7.16.x):
    • import test.rsc verbose=yes dry-run reports every syntax error in the file without applying any change.
    • :do { import test.rsc } on-error={ :put "Failure" } — on-error= is an import-specific parameter added in 7.16.x. Catches errors from import itself (missing file, syntax errors). Errors produced inside the imported script are not caught here.
    • :onerror e in={ import test.rsc } do={ :put "Failure - $e" } — :onerror is the general error-handling command (any RouterOS version that supports it). The error message is bound to the named variable.

References (use as needed)

  • Language and syntax: see references/LANGUAGE.md
  • .rsc export/import, dry-run and onerror: see references/RSC_GUIDE.md
  • Security and idempotency best practices: see references/SAFE_PRACTICES.md
  • Common examples and patterns: see references/EXAMPLES.md
  • Linter rules: see references/LINTER_RULES.md

Notes

  • Scripts should be consistent with RouterOS v7 (preferred) and compatible with v6 where possible.
  • Use print as-value, arrays, and where filters for robust queries.
  • For scheduled execution, use Scheduler with appropriate permissions.

Comments

Markdown supported