OpenParable
Skip to content
← Back to skills

Sort Redirects

Documents
sort-redirects

Sort Redirects is an Agent Skill for documents published in the dotnet/docs repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

Sorts redirect entries in Open Publishing redirection JSON files alphabetically by path. Use after adding redirects or when the file becomes unsorted.

View on GitHub ↗
QUICK START

How to use this skill

Bring this guide into your coding agent with a prompt tailored to the tool you use.

  1. Open your project in Codex.
  2. Copy and paste the prompt below.
  3. Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/dotnet/docs/blob/HEAD/.github/skills/sort-redirects/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/sort-redirects, but wait for my approval before writing files or running scripts.

Copying this prompt does not install or run the skill. Review third-party files before use.

Sort Redirects

Sort redirect entries in Open Publishing redirection JSON files alphabetically by path. This ensures consistency and makes the redirect files easier to maintain.

When to Use

  • After adding redirect entries to a JSON file
  • When the redirect file has become unsorted
  • After merging branches that may have caused unsorted entries

Steps

  1. Identify the redirection file - Determine which .openpublishing.redirection.*.json file needs sorting.
  2. Run the sort script - Use the sort-redirects.ps1 script with the file path.

Scripts

sort-redirects.ps1

Sorts all entries in the JSON file alphabetically by path (ignoring leading / for source_path_from_root). Handles both source_path_from_root and source_path properties.

Location (relative to this skill file): ./scripts/sort-redirects.ps1

ParameterRequiredDescription
RedirectionFileYesThe path to a redirection JSON file (e.g., .openpublishing.redirection.csharp.json)

Example:

.\scripts\sort-redirects.ps1 -RedirectionFile ".openpublishing.redirection.csharp.json"

Important Notes

  • The script preserves all existing redirect entries, only changing their order.
  • Sorting is case-sensitive and alphabetical by the normalized path (without leading /).