Skip to content

Conversation

@nearestnabors
Copy link
Contributor

@nearestnabors nearestnabors commented Jan 17, 2026

I got sick of broken links being reported, so I made this to ensure all deleted/moved markdown files are accounted for with redirects. The workflow does a lot of the heavy lifting of chain collapsing and updating internal links.

Summary

Adds automated redirect management when pages are deleted or moved. This ensures URL stability for bookmarks and SEO.

What's New

1. Pre-commit Hook Integration

When you delete a page file and try to commit:

  • Auto-detects deleted .mdx/.md page files
  • Auto-adds redirect entries to next.config.ts with placeholder destinations
  • Blocks commit until you provide actual redirect destinations

2. Redirect Chain Collapsing

When an old redirect points to a page you're deleting:

  • Detects the chain (e.g., old-path → deleted-path → new-path)
  • Auto-collapses by updating the old redirect to point directly to the final destination

3. Internal Link Auto-Update

When next.config.ts is staged with new redirects:

  • Scans all MDX/TSX files for internal links pointing to redirected paths
  • Auto-updates those links to use the new destinations
  • Auto-stages the modified files

Workflow

Deleting/Moving a Page

First commit attempt:

$ git rm app/en/guides/old-page/page.mdx
$ git commit -m "Remove old page"

🔗 Detected deleted page(s), checking for redirects...
✓ Added redirect entries to next.config.ts
❌ Commit blocked: Please update the placeholder destinations

Update the placeholder in next.config.ts:

// Change this:
destination: "/:locale/REPLACE_WITH_NEW_PATH",
// To this:
destination: "/:locale/guides/new-location",

Second commit attempt:

$ git add next.config.ts
$ git commit -m "Remove old page"

🔗 Updating internal links for new redirects...
✅ Internal links updated and staged
[commit succeeds]

Scripts Added/Modified

Script Purpose
scripts/update-internal-links.sh Updates internal links that point to redirected paths
scripts/check-redirects.sh Now includes --auto-fix flag for auto-adding redirects
.husky/pre-commit Integrates both scripts into the commit workflow

Test Plan

  • Delete a page → redirect entry auto-added with placeholder
  • Fill in placeholder → commit blocked until valid destination
  • Enter invalid destination → helpful error message shown
  • Old redirect points to deleted page → chain auto-collapsed
  • Internal links to old path → auto-updated to new path
  • All tests pass

🤖 Generated with Claude Code


Note

Introduces automated redirect enforcement and link maintenance for documentation.

  • Adds GitHub Action check-redirects.yml to detect deleted/renamed markdown pages lacking redirects, comment on PRs with details, and fail the check
  • Extends .husky/pre-commit to auto-add missing redirects (with placeholders), block commits until resolved, and auto-update/stage internal links when next.config.ts changes
  • New TypeScript utilities: scripts/check-redirects.ts (validates/auto-fixes redirects, collapses redirect chains) and scripts/update-internal-links.ts (rewrites links to new destinations); wired via package.json (check-redirects, update-links)
  • Updates next.config.ts with comprehensive redirects (notably moving guides/agent-frameworks and guides/tool-calling/mcp-clients to get-started/...) to preserve URLs
  • Adjusts docs and component links (e.g., ToolFooter, multiple page.mdx files) to new get-started structure; minor copy edits and meta cleanup
  • Regenerates public/llms.txt

Written by Cursor Bugbot for commit f552b84. This will update automatically on new commits. Configure here.

Adds a GitHub Action and local script that compares the branch to main,
detects deleted markdown files, and ensures each has a corresponding
redirect entry in next.config.ts. Prevents broken bookmarks and SEO issues.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Jan 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
docs Ready Ready Preview, Comment Jan 20, 2026 7:47pm

Request Review

cursor[bot]

This comment was marked as outdated.

nearestnabors and others added 3 commits January 17, 2026 21:59
…t checker

Content moves:
- Move guides/agent-frameworks/* to get-started/agent-frameworks/*
- Move guides/tool-calling/mcp-clients/* to get-started/mcp-clients/*
- Add wildcard redirects for moved content
- Fix stale _meta.tsx references

Redirect checker enhancements:
- Interactive mode prompts for redirect destinations
- Validates existing redirects for placeholder text (REPLACE_WITH, TODO, FIXME)
- Catches circular redirects (source == destination)
- Verifies destination pages exist
- Detects both deletes and renames

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Fail with error when base branch is unavailable instead of silent success
- Fix root page URL path handling (app/en/page.mdx -> /:locale)
- Only check page.md/mdx files (skip non-routable markdown like README.md)
- Use cut with tab delimiter instead of awk to handle filenames with spaces

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
cursor[bot]

This comment was marked as outdated.

- Adjusted the script to use cut for field extraction, improving handling of deleted and renamed page files.
- Updated informational messages to redirect stderr, ensuring clarity in user prompts.

This improves the user experience when managing redirects in the Arcade platform.
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

nearestnabors and others added 6 commits January 20, 2026 15:04
Companion to check-redirects.sh - this script reads redirect mappings
from next.config.ts and updates any internal links in MDX/TSX files
that point to old (redirected) paths.

Usage: ./scripts/update-internal-links.sh [--dry-run]

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Update internal links and redirect destinations that were incorrectly
pointing to /guides/ paths when the actual pages are under /get-started/:

- /guides/agent-frameworks/* -> /get-started/agent-frameworks/*
- /guides/tool-calling/mcp-clients/* -> /get-started/mcp-clients/*
- /home/quickstart -> /get-started/quickstarts/call-tool-agent
- /home/hosting-overview -> /guides/deployment-hosting

Files updated across MDX docs, TSX components, and next.config.ts redirects.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Changes to check-redirects.sh:
- Add --auto-fix flag that automatically inserts redirect entries
  into next.config.ts when pages are deleted
- Uses placeholder destinations that must be replaced before merge

Changes to pre-commit hook:
- When page files are deleted, runs check-redirects.sh --auto-fix
- Auto-adds redirect entries and stages next.config.ts
- Blocks commit until placeholder destinations are replaced
- When next.config.ts is staged, runs update-internal-links.sh
  to fix internal links pointing to redirected paths

Workflow:
1. Delete page -> commit blocked, redirect entry auto-added
2. Update placeholder destination in next.config.ts
3. Commit again -> internal links auto-fixed, commit succeeds

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The perl -pe approach failed because redirect entry strings contain
special characters (colons, slashes, quotes) that broke perl syntax.

Switch to awk with a temp file approach which handles arbitrary
content safely.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When a redirect points to a destination that itself has a redirect
(a chain like A → B → C), the script now:

1. Detects the chain during validation
2. In --auto-fix mode, automatically collapses it (A → C)
3. Updates next.config.ts with the collapsed redirect

This handles the case where an old redirect (e.g., from a previous
migration) points to a page that is now being deleted/moved.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Pre-commit hook now shows appropriate message based on error type:
  - Placeholder message only when REPLACE_WITH_NEW_PATH exists
  - Generic "fix issues shown above" for other errors
- Invalid redirect errors now include step-by-step fix instructions

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
cursor[bot]

This comment was marked as outdated.

- Accept main's llms.txt (auto-generated)
- Include workflow fix (set -o pipefail)
- Include new Copilot Studio MCP client docs
- Include LLM setup guide

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
cursor[bot]

This comment was marked as outdated.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style Review

Found 3 style suggestion(s).

Powered by Vale + Claude

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style Review

Found 3 style suggestion(s).

Powered by Vale + Claude

nearestnabors and others added 3 commits January 20, 2026 17:06
…ge.mdx

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…ge.mdx

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
cursor[bot]

This comment was marked as outdated.

Copy link
Contributor

@evantahler evantahler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A question: Why are your new scripts bash? pnpm run check-redirects seems ok since we are already in TS, and that would allow the use of the node file utilities + glob which would make those scripts much smaller and easier to read

@nearestnabors
Copy link
Contributor Author

A question: Why are your new scripts bash? pnpm run check-redirects seems ok since we are already in TS, and that would allow the use of the node file utilities + glob which would make those scripts much smaller and easier to read

Great question! I vibecoded this so had 0 opinion! IS this a blocker or a follow up, @evantahler ?

@evantahler
Copy link
Contributor

Yes, I think this would be a blocker because it's adding something that's very hard for the team that normally works on docs to maintain. We will want to adjust and understand these scripts in the future. You can split this PR into 2 - merge in the found redirecet problems now, and work on the script out-of-band?

@nearestnabors
Copy link
Contributor Author

@evantahler Nah, I'll do it now. We need to move both forward fast. I've tasked @torresmateo to check that it works, then I'll ping you for another look

nearestnabors and others added 2 commits January 20, 2026 18:22
- Rewrite check-redirects.sh as check-redirects.ts
- Rewrite update-internal-links.sh as update-internal-links.ts
- Add folder rename detection (R status) to pre-commit hook
- Update GitHub Actions workflow to use TypeScript scripts
- Add pnpm scripts: check-redirects, update-links

Benefits of TypeScript:
- Consistent with rest of codebase
- Uses fast-glob instead of bash find
- Easier to read and maintain
- Better error handling
- Properly parses next.config.ts

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
cursor[bot]

This comment was marked as outdated.

- Refactor regex matching to avoid assignment in expressions
- Extract magic numbers to named constants
- Rename variables to avoid shadowing
- Replace increment operators with += 1
- Collapse nested if statements
- Fix formatting issues

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
cursor[bot]

This comment was marked as outdated.

- Add --staged-only flag to check-redirects script
- When --staged-only is set, use git diff --cached instead of git diff HEAD
- Update pre-commit hook to pass --staged-only
- Fix chain collapse to follow entire chain to final destination
  (previously only resolved one hop)

Fixes:
- Script no longer flags file deletions in working directory that
  haven't been staged for commit
- Redirect chains like A→B→C→D are now fully collapsed to A→D
  in a single run

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
cursor[bot]

This comment was marked as outdated.

nearestnabors and others added 2 commits January 20, 2026 19:40
Component is at get-started/mcp-clients/, not guides/tool-calling/mcp-clients/

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
String replacement patterns like $1, $2, $& in paths would be incorrectly
expanded by the regex engine. Using replacer functions ensures the new
path is inserted literally.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

# Stage any files that were modified
UPDATED_FILES=$(git diff --name-only -- 'app/**/*.mdx' 'app/**/*.tsx' 'app/**/*.md' 2>/dev/null || true)
if [ -n "$UPDATED_FILES" ]; then
echo "$UPDATED_FILES" | xargs git add
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pre-commit hook stages unintended working directory changes

Medium Severity

After running pnpm update-links, the hook uses git diff --name-only to find modified files and stages them. However, this command returns ALL files differing between the working directory and the index, not just files modified by update-links. If a user has other mdx/tsx/md files modified in their working directory but intentionally not staged (perhaps saving changes for a future commit), those files get auto-staged by xargs git add, causing unintended changes to be included in the commit.

Fix in Cursor Fix in Web

Copy link
Contributor

@evantahler evantahler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's try it!

@nearestnabors nearestnabors merged commit da0ae54 into main Jan 21, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants