`courses/cleanup-commit.sh` is empty. You open the file to build a repeatable script to deprecate three end-of-life courses and merge all associated changes in a single repo commit, avoiding scattered, uncontextualized changes across multiple PRs.
Map active course statuses
You start by pulling the latest main branch of the core content repo to ensure you have real-time data for current enrollment counts, public page URLs, and existing redirect rules. You cross-reference the list of courses marked for sunset by the content team against the public catalog to confirm the three slugs targeted for removal are no longer open for new enrollment: intro-to-no-code-2021, advanced-saas-analytics-2022, and beginner-ux-research-2020. You log key details for each course in a reference table to keep track of required actions for each:

| Course slug | Active enrollments | Official sunset date |
|---|---|---|
| intro-to-no-code-2021 | 12 | 2024-03-15 |
| advanced-saas-analytics-2022 | 4 | 2024-04-02 |
| beginner-ux-research-2020 | 7 | 2024-02-29 |
Illustrative example: the 23 total active learners across all three courses have already been notified via segmented email of the sunset timeline, given permanent access to downloadable course materials, and offered 50% off the 2024 updated version of their respective course as a retention gesture. You add a check to your script to flag any future attempt to deprecate a course with more than 50 active enrollments, to prevent accidental removal of content that is still being used by a large group of learners. You also confirm all certificate records for past completers of the three courses are already stored in the separate user records database, so deleting the course content from the main repo will not impact users’ ability to access their earned certificates.
Flag deprecated course content
You add a standardized warning banner component to the top of each deprecated course’s landing page, lesson pages, and associated resource pages. The banner clearly states the course is no longer active, links to the archived materials hub for enrolled users, and suggests the most relevant replacement course for users who land on the page via old bookmarks or search engine results. You remove all internal links to the three courses from the main site navigation, onboarding course recommendation widget, homepage featured content block, and related course suggestions that appear at the end of all active course lessons. You run a local link checker to confirm no broken links appear on public pages after you remove these references, and you adjust any remaining links that point to the deprecated courses to point to their replacement counterparts instead. You make sure the warning banner uses existing design system components, so it renders correctly on mobile and desktop without requiring custom CSS that would add technical debt to the repo.
Draft permanent redirect rules
You write 301 permanent redirect rules for every public URL associated with the three deprecated courses, covering main landing pages, individual lesson URLs, quiz submission endpoints, resource download links, and old marketing campaign landing pages tied to each course. You map each old URL to the most relevant existing destination: main course slugs redirect to the 2024 updated version of the course where available, and lesson-specific URLs redirect to the matching lesson in the updated course, or the general archived materials hub if no direct match exists. You test each redirect rule locally to ensure there are no 404 errors, redirect loops, or misdirected links that send users to unrelated content. You add a comment to each redirect rule in the site’s redirect config file noting the date of the change, the course slug being redirected, and a link to the internal project ticket tracking the deprecation, to make future maintenance easier for other members of the engineering team. You also add a rule to redirect the old course sitemap entries to the main course catalog sitemap, so search engines will quickly deindex the deprecated content over the next few weeks.

Run bulk content deletion checks
You run a repo-wide search for all references to the three deprecated course slugs to catch any hidden references you missed during manual checks. You filter out references that appear in git commit history, public changelog entries, and archived release notes, since those do not appear on the public site and do not need to be modified or removed. You delete all course content files for the three deprecated courses from the `courses/content/` directory, including markdown lesson files, embedded media asset folders, quiz config files, and certificate templates that are no longer in use. You move a copy of all deleted content to the separate long-term archive repo managed by the content team, so the materials can be referenced later for content updates or user support requests without cluttering the main production repo. You also remove all course-specific user tracking configs for the three courses from the `data/courses/` directory, to stop the site from collecting unnecessary data related to courses that are no longer active. You run a local build of the site after completing deletions to confirm no build errors pop up from missing content files.
Append commit metadata to repo history
You stage all your changes for a single commit, including modified landing page files, updated redirect rules, deleted content directories, adjusted navigation configs, and the new cleanup script you are building. You write a clear, descriptive commit message that lists the three course slugs being removed, the official sunset date for each, and a link to the internal Asana ticket tracking the full deprecation project, so anyone reviewing the repo commit history in the future can easily find full context for the bulk changes. You pull the latest version of the main branch again to resolve any minor merge conflicts that popped up while you were working on the deprecation, and you push your feature branch to the remote repo to open a pull request for review. You tag the content lead and engineering lead on the pull request, so they can confirm all changes align with the planned deprecation timeline and no critical content is being removed accidentally. This process aligns with the standard content maintenance workflow documented in the Build Next Stack playbook, so you do not need to request a special exception for the bulk content deletion. You add a copy of the course status reference table to the pull request description to make review faster for the approvers.
Reference this script during future course deprecation work
The next time you open `courses/cleanup-commit.sh`, you are prepping to deprecate two additional 2022 courses that are being replaced with expanded 2024 versions focused on AI-powered tooling. You pull up the step-by-step comments you added to the script during this first round of deprecations to streamline the process, skipping the initial rule drafting work you already completed the first time. You adjust the script’s input variables to match the new course slugs, sunset dates, and redirect destinations for the two new courses being deprecated, and you run the modified script to cut the time you spend on manual checks and configuration by more than 60% compared to your first run. You add additional comments to the script noting edge cases you encountered during this second round of deprecations, like custom landing page links that were shared in past social media and email marketing campaigns, to make the process even more efficient for any team member who uses the script for deprecation work in the future. You also add a new automated check to the script that scans the marketing link database for any active links pointing to deprecated courses, to catch redirect gaps you would otherwise miss with only a repo-wide search. You save the updated version of the script to the repo’s internal tooling directory, so every member of the engineering and content teams can access it for future deprecation projects.