Popular Posts

Atlassian Leverages Agentic Pipelines to Automate the Systematic Removal of Stale Feature Flags and Reduce Technical Debt

The lifecycle of a software feature flag is characterized by a fundamental irony: while the implementation of a flag is a relatively simple task designed to mitigate risk during rollout, the eventual removal of that flag frequently becomes a significant source of technical debt. In the high-pressure environment of modern software engineering, the "hard part" of feature flagging is rarely the initial deployment; rather, it is the discipline required to prune the code months later, long after the original context has faded and the rollout is considered a success. At Atlassian, this challenge has been addressed through the innovative application of Agentic Pipelines, a system designed to automate the cleanup of stale feature flags, thereby ensuring codebases remain lean and maintainable without placing an undue burden on engineering teams.

Since April 2026, an Atlassian engineering team has utilized Agentic Pipelines to manage their monthly backlog of stale feature flags. This automated workflow is designed to prepare necessary code changes and initiate pull requests, leaving the final review and merging responsibilities to human engineers. By automating the most repetitive and context-heavy aspects of the cleanup process, the team has successfully addressed a persistent bottleneck in their development cycle.

The necessity for such a system arises from the natural tendency for cleanup tickets to slip down the priority list. Within Atlassian’s internal infrastructure, feature flags are managed via a gating system where every flag is tracked by a corresponding ticket. As flags become stale—meaning the feature they controlled has been fully rolled out and the flag is no longer serving a purpose—automated tickets are generated in an internal Jira project. These tickets contain essential metadata, including the flag’s name, its final intended value, the flag type, and the current state of the gate. Despite this structured data, the manual cleanup of these flags is often neglected in favor of more urgent feature work. While a few stale flags are manageable, a growing backlog creates significant cognitive overhead. Engineers must navigate and reason around obsolete code paths, conditionals, and variables every time they interact with the surrounding codebase, leading to a gradual degradation of developer productivity.

The actual process of cleaning up a feature flag is conceptually straightforward but operationally tedious. It involves locating every instance of the flag across the repository, inlining the final behavior, deleting the dead code branches, removing related definitions or helpers, running a suite of tests to ensure no regressions were introduced, and finally opening a pull request. While many teams have these steps documented, the work requires codebase-specific knowledge that is difficult to capture in a simple, static script. Furthermore, the task must compete with high-priority product features for a developer’s limited time.

To solve this, Atlassian developed a two-part automation architecture consisting of a "dispatcher" and a "coding agent." The dispatcher, powered by a scheduled Rovo Studio automation rule, acts as the initiator. It queries Jira to identify open flag-cleanup tickets that are classified as stale and eligible for automated removal. For every eligible ticket identified, the dispatcher triggers a coding agent run via Bitbucket Pipelines, passing the specific ticket key as context. This "fan-out" approach allows the system to process numerous tickets in parallel, removing the need for engineers to manually hunt for stale flags or trigger individual cleanup runs.

The coding agent operates with a specific "skill" rather than relying solely on a broad, generic prompt. Atlassian engineers found that keeping the prompt "thin"—a minimal harness that loads a skill and reports results—was more effective than scattering domain logic across pipeline configurations. The logic of how to handle specific code patterns, such as ternaries, conditionals, and variable assignments, is housed within a versioned and reviewable skill file. This skill guides the agent through a rigorous process: it reads the ticket metadata, searches the codebase to verify the current state of the flag, and then executes the code modifications.

How we automated feature-flag cleanup with Agentic Pipelines

Verification is a critical component of the workflow. Because software repositories are dynamic and frequently updated, the state of the code can diverge from the information in a Jira ticket. Sometimes a flag has already been partially removed or its final value has been altered by another developer. By making verification the first step, the agent ensures it does not make erroneous changes based on outdated information. If the codebase and the ticket context do not align, or if the agent cannot safely validate the change, it halts the process and reports the discrepancy rather than proceeding with a potentially breaking change.

Once the agent modifies the code—keeping the enabled behavior and removing the obsolete gate definitions—it subjects the changes to the repository’s standard validation suite. This includes linters, type-checkers, and unit tests. A key philosophy of the Agentic Pipeline is that automated checks act as a gate: if the tests fail, no pull request is opened. The agent is instructed to attempt to investigate and repair minor issues within its defined scope, but if a passing change cannot be produced safely, the workflow stops. This prevents the "noise" of broken automated PRs from reaching human reviewers.

When a change successfully passes all checks, the agent opens a pull request, comments on the Jira ticket with a link to the PR, and labels the ticket as "automated." This ensures that the history of the cleanup remains queryable and transparent. The human engineer then enters the loop to review the code and merge the PR. Following the deploy, the flag is archived in the team’s flag service, and the Jira ticket is closed automatically.

The transition to this agentic workflow has yielded several key lessons for the Atlassian team. First, the importance of verification cannot be overstated; an agent must always confirm the state of the repository before editing. Second, the distinction between a "prompt" and a "skill" is vital for maintainability. By treating the skill as a living document that is versioned alongside the code, teams can adapt to shifting codebase conventions and edge cases that a static prompt might miss. Third, the use of automated checks as strict gates ensures that the agent only contributes high-quality, valid code. Finally, security is maintained by scoping permissions specifically to the task at hand. The agent is granted only the minimum necessary access—such as reading/writing to the repository and opening pull requests—using task-specific authentication tokens to limit potential risk.

The implementation of Agentic Pipelines has not removed the engineer from the process but has successfully eliminated the "drudge work" associated with technical debt management. Engineers no longer need to spend time reconstructing a flag’s history or manually hunting for every call site across frontend and backend systems. Instead, they focus on the high-level task of reviewing the final PR to ensure it meets the team’s standards.

This pattern of maintenance automation is not limited to feature flags. Atlassian has noted that similar workflows can be applied to dependency updates, documentation maintenance, and vulnerability remediation. The pattern is most effective for recurring tasks that have a clear trigger, bounded steps, reliable context, and an unambiguous definition of "done."

Currently, Agentic Pipelines are in beta for Bitbucket Cloud. Organizations interested in implementing similar automations must enable the feature within their workspace and meet specific requirements from their chosen AI model providers. Atlassian advises that teams carefully review documentation regarding permissions, credentials, and data handling before enabling agents with write access to their repositories. By shifting the burden of repetitive maintenance from humans to specialized agents, Atlassian is demonstrating a future where engineering teams can focus on innovation while automation handles the inevitable accumulation of technical debt.