Manuscript Offprint
arXiv:2610.39872STORY2DIFF: A Dataset Linking Real-World User Stories to Code Changes
Benedetta Donato, Daniele Franchini, Alessandro Greco, Oliviero Riganelli, Daniela Micucci, Leonardo Mariani
University of Milano-Bicocca, Milan, Italy
{benedetta.donato,oliviero.riganelli,daniela.micucci,leonardo.mariani}@unimib.it, {d.franchini2,a.greco71}@campus.unimib.it
Abstract—Research on requirements-to-code tasks needs examples in which a genuine requirement is paired with the change that implemented it. Existing user-story collections, however, largely contain isolated or synthetic text. To address this limitation, we present STORY2DIFF, a dataset of 7,785 English user stories linked to merged pull requests from January 2017 to July 2026. The dataset is mined from a set of 982 public Java and Python repositories. Each record in the dataset combines the original issue, extracted Connextra elements, the associated pull request and commit metadata, a file-level diff capturing the code changes introduced by the associated pull request, and the affected files before and after the change. The tool we built to mine STORY2DIFF can be used to repeat the automatic extraction of the records, using different parameters (e.g., a different timeframe). The dataset can support a variety of tasks, including requirement discovery, traceability, change-impact estimation, and requirements-aware code generation. Dataset: https://github.com/riganelli/user-story-mining-pipeline/releases/tag/V4.0.1. Video: https://youtu.be/qOhXUeyeiTQ.
Index Terms—User Stories, Requirements Traceability, Mining Software Repositories
I. INTRODUCTION
User stories are commonly used to specify requirements from a stakeholder's perspective, often through the Connextra template: As a [role], I want [feature], so that [benefit] [1]. They are widely used in agile development processes, such as Scrum and XP.
A wide spectrum of techniques needs both large sets of requirements and their implementation to be properly assessed. This includes automated traceability recovery, which identifies links between requirements and implementation artifacts [2]; requirements-driven change-impact analysis, which identifies the code affected by a requirement change [3]; and code generation and modification from natural-language requirements [4]. Paired requirements and implementations provide reference artifacts against which recovered links, predicted changes, and generated code can be assessed.
Existing user-story datasets generally contain collections of stories without associated implementations [5], [6], [7]. Such datasets are sufficient to study, for instance, the linguistic quality of the requirements [5], but they are insufficient for investigating questions that cross the boundary between requirements and implementation.
To address this gap, we built STORY2DIFF, a dataset of user stories linked to the code changes introduced by the pull requests that close their corresponding GitHub issues, together with tool support to repeat and adapt the extraction process to future needs. In particular, we extract issues that contain user stories matching the Connextra template that are bound to merged pull requests (PRs).
In a nutshell, STORY2DIFF delivers 7,785 real-world user-story-implementation records spanning 982 Java and Python repositories and nearly ten years of development; and a documented and reproducible multi-stage mining process that combines LLM validation, issue analysis, and text verification.
Traceability datasets. Existing traceability datasets link issue or requirement artifacts to code but rarely adopt user-story framing. Rath et al. train a classifier that recovers missing issue-to-commit links [2]; SEOSS provides 33 projects with typed issue-to-issue and issue-to-commit trace links [8]. PI-Link contains 50,369 explicit issue-to-pull-request links mined from Android repositories [9], and Majidzadeh et al. release issue-to-commit and issue-to-method links mined from GitHub [10]. Elamin and Osman model user stories, tasks, and developer tests as typed nodes in a Neo4j graph [11], but their links never reach code-level artifacts such as commits or diffs. Pärtachi et al. suggest missing PR-issue links online, when a developer submits a PR or closes an issue [12]. None of these resources anchors the requirement side to canonical Connextra user stories paired with code changes associated with their implementation.
Code-generation benchmarks. SWE-bench [4] pairs 2,294 merged PRs from 12 Python repositories with the issues they resolve, and scores generated patches by running the project's tests; its requirement is the issue text as written, typically a bug report or feature request. Subsequent studies report leakage of the solution, weak tests [13], and possible memorization [14]. PR4Code [15] collects 13,339 Java and Python PRs with commit sequences and cumulative diffs, but selects them by keywords, so the textual side is a free-form PR description, and only 3,603 PRs use issue-closing syntax. Unlike both, each STORY2DIFF record links a user story to the merged PR that closed its issue, and keeps the full commit sequence, file-level diffs, and files before and after the change. Similar to PR4Code, the data collection process can be repeated on a more recent time window, enabling the construction of fresh benchmark instances and thereby reducing the risk of contamination.
STORY2DIFF complements prior work by providing a curated collection of user stories extracted from GitHub issues together with their corresponding code changes, materialized as pull requests. This pairing of natural-language requirements and concrete implementations enables empirical studies that directly examine how user stories relate to code.
III. DATASET CONSTRUCTION
Figure 1 summarizes the six-stage process we defined to construct the STORY2DIFF dataset. The pipeline first identifies eligible repositories (Repository Discovery), then extracts the candidate issues (Issue Extraction) and associates them with the merged pull requests that closed them (Merged-PR Linkage). It then uses an LLM to extract user stories from issues (Grounded LLM Validation). Next, it retrieves the implementation artifacts (Code Materialization), and finally, it retains only records whose extracted components form a user story that occurs verbatim in the original issue text (Literal Verification).
A. Repository Discovery
GitHub does not provide an explicit repository-level marker for user-story adoption. We therefore identify candidate repositories through five complementary strategies, implemented in Python using the requests library [16] and GitHub's REST Search API. We apply the strategies sequentially and maintain a shared set of previously encountered repositories to avoid duplicate processing across strategies. Repositories identified by any of the following strategies are considered for subsequent filtering:
LABEL: select repositories with closed issues whose labels indicate the use of user stories by matching user-story, user story, or user_story.
TEMPLATE: searches for repositories that store issue templates under .github/ISSUE_TEMPLATE with content that includes “user story” or a Connextra statement.
TAG: searches closed issue titles with the keyword US-, then applies a case-insensitive regular expression to the returned titles. The expression recognizes four marker families: (i) [US]; (ii) [USn], allowing zero or more hyphens, underscores, or whitespace characters between US and n; (iii) [userstory], allowing zero or more hyphens, underscores, or whitespace characters between user and story; and (iv) USn at the beginning of the title, allowing whitespace and an optional single hyphen or underscore between US and n, with a word boundary after n. Here, n denotes one or more digits. Surrounding whitespace is permitted inside brackets and before title-initial markers.
MENTION: searches for repositories containing issues whose titles or bodies include “user story”, without requiring a specific sentence structure.
CONNEXTRA: searches for repositories containing issues whose bodies include the definition of a role and a desired action, following the formulation “As a [role], I want [action]”. Since keyword searches can return unrelated matches, we use client-side regular expressions to refine the results. The expressions recognize both partial stories, containing a role and an action introduced by “I want”, “I need”, or “I would like”, and complete stories that additionally express a benefit through “so that”, “in order to”, or “so I can”.
For the construction of the dataset, we restrict the scope to Java and Python repositories, two widely used programming languages on GitHub [17]. We require at least one of these languages to individually account for at least 30% of the repository's code. Moreover, a repository is retained only if it has at least two stars. This phase examined 73,680 unique repositories and retained 5,638 for subsequent extraction.
B. Issue Extraction
This stage takes as input the repositories retained during Repository Discovery and identifies individual issues that may contain user stories. For each repository, the pipeline runs repository-scoped queries through GitHub's REST Search API (/search/issues), applying the five described discovery strategies and selecting issues closed between 1 January 2017 and 4 July 2026 (the mining date).
For each issue, the pipeline checks the language using the Python langid library. Before language identification, code blocks, URLs, and HTML tags are removed from the issue text to reduce interference from non-natural-language content. Issues classified as non-English with a confidence of at least 0.95 are discarded. Issues whose cleaned text contains fewer than 20 characters bypass language identification and are also retained for subsequent processing.
This stage returned a total of 99,194 candidate issues.
C. Merged-PR Linkage
Since the objective of the STORY2DIFF dataset is to associate requirements written as user stories with their implementations, this stage associates candidate issues with the corresponding merged pull requests. In particular, for each issue, the pipeline uses its repository and issue number to query GitHub's GraphQL API and identify the PR responsible for closing the issue, as recorded in the ClosedEvent.closer field. Only issues closed by a merged PR are retained, excluding those closed by commits or associated with PRs through references that did not result in issue closure. This ensures that the linked changes correspond to code integrated into the repository and provides an explicit traceability link between the user story and the associated code changes. Overall, this stage retained 23,527 issues associated with a merged PR that closed them.

Fig. 1: STORY2DIFF construction process
D. Grounded LLM Validation
Since the identification of user stories based on regular expressions might be imprecise, we further analyze issue descriptions using LLMs to (a) confirm whether an actual user story is present and (b) extract its individual components. To this end, we run a Qwen2.5 7B model locally at temperature zero to extract from the issues a JSON object containing: (a) a Boolean verdict (is_user_story), indicating whether the issue contains a user story; (b) a classification of the Connextra formulation as complete (role and feature with an explicit benefit), partial (role and feature without an explicit benefit), or absent (otherwise); (c) the extracted role, feature, and benefit, when present; and (d) the location of the user story within the issue, which can be the title, body, or both, with null allowed when no location is reported. We retain only issues for which the LLM returns is_user_story = true, without applying additional grounding or confidence-based constraints. The literal correspondence between the extracted components and the original issue text is verified in the subsequent Literal Verification stage. Overall, this stage retained 13,192 issues.
E. Code Materialization
For each issue, this stage retrieves the associated implementation artifacts through GitHub's REST API. Figure 2 visually exemplifies the main data retrieved for each issue and PR, considering the case of issue bcgov/wps#3582 and its PR #3597. The retrieved PR metadata includes its identifier, title, URL, source and target branches, merge timestamp, and the SHA identifiers of the base revision, head revision, and merge commit. The pipeline also retrieves the commit sequence between the base and head revisions (i.e., the full commit sequence that implements the PR), recording each commit's SHA, author, timestamp, and message.
For each changed file, the pipeline retrieves its path, change status, previous path when renamed, numbers of added and deleted lines, and textual patch. In addition, it downloads the complete file contents at the stored base and head revisions.
The retrieved metadata are stored in a data.json file together with data about the associated issue, while changed files are downloaded locally. Materialization completed for all 13,192 validated issues, with no records discarded at this stage.
F. Literal Verification
We finally retain only the records for which the complete user story occurs verbatim in the original issue text. This stage reconstructs the entire user story using the LLM-extracted components and a predefined set of Connextra connectors. The reconstructed story is then matched against the original issue text, considering both complete stories (role, feature, and benefit) and partial stories (role and feature only).

Fig. 2: Example record linking the user story in bcgov/wps#3582 to PR #3597, commits, and changes.
This verification prevents text manipulation accidentally introduced by the LLM and ensures that the extracted user story matches the original issue text. Literal Verification thus guarantees by construction that every record contains a verbatim Connextra story written by the developers; a manual inspection of 150 randomly selected records confirmed that the stage behaves as intended. This final check retains 7,785 records (59.01% of the materialized corpus). Both the original issue title and body are preserved in the output dataset.
IV. DATA ORGANIZATION AND TOOL SUPPORT
The dataset is organized hierarchically by language, repository, and issue. Each issue folder contains the issue and associated PR data and metadata. The GitHub URLs and immutable commit SHAs identify the source artifacts.
The original_files/ and modified_files/ folders store file versions before and after the associated PR changes. This organization permits both requirement-to-code and code-to-requirement traversal without re-querying GitHub. We also provide Python scripts to automate the selection process and repeat the analysis with different parameters (e.g., temporal constraints). A Web application allows users to configure and launch the analysis, monitor its progress, and visualize the results, including through plots.
The code and usage instructions are available at https://github.com/riganelli/user-story-mining-pipeline.
V. DATASET CHARACTERIZATION, LIMITATIONS, AND USES
The final STORY2DIFF release contains 7,785 records from 982 GitHub repositories. Data quality is supported by two complementary checks: each issue must be explicitly closed by a merged PR, and the extracted user story must occur verbatim in the original issue text.
The dataset comprises 4,663 Python records (59.9%) and 3,122 Java records (40.1%). Figure 3 characterizes the textual and implementation-related properties of the dataset. User stories exhibit similar lengths across languages, with median values of 103 characters for Java and 107 for Python, while

(a) Issue length
(b) User story length
(c) User story commits
(d) Changed files per user story
Fig. 3: Overview of user story length, issue length, commits and changes
the corresponding issues are considerably longer (544 and 611 characters, respectively). Regarding implementation size, Java records involve slightly more commits (median 5 versus 4) and modified files (median 9 versus 6) than Python records.
Figure 4 further characterizes the extent of code modifications. Java records exhibit higher median values for additions, deletions, and changes. Both figures reveal substantial variability and numerous outliers, indicating that the dataset covers implementations of widely different sizes.
Limitations. The dataset is restricted to public Java and Python repositories and to user stories following the supported Connextra patterns. Literal verification ensures textual correspondence, but does not establish requirement completeness or implementation correctness. Moreover, associated PRs may contain changes unrelated to the user story.
Uses. STORY2DIFF supports several research tasks, including the following cases. Requirement recovery: generate user stories from code and compare them with the original requirements. Traceability: train or evaluate requirement–PR–code link creation, evolution, and recovery techniques. Effort and size prediction: relate user-story features to code churn and development time. Automated Code Generation: compare generated code with the changes associated with a user story. Project evolution: analyze the commit-level evolution of code changes associated with user stories.

Fig. 4: Lines changed per user story
REFERENCES
[1] M. Cohn, User Stories Applied: For Agile Software Development. Addison-Wesley Professional, 2004.
[2] M. Rath, J. Rendall, J. L. C. Guo, J. Cleland-Huang, and P. Mäder, "Traceability in the Wild: Automatically Augmenting Incomplete Trace Links," in Proceedings of the International Conference on Software Engineering (ICSE), 2018.
[3] D. Falessi, J. Roll, J. L. Guo, and J. Cleland-Huang, “Leveraging Historical Associations between Requirements and Source Code to Identify Impacted Classes,” IEEE Transactions on Software Engineering (TSE), vol. 46, no. 4, 2020.
[4] C. E. Jimenez, J. Yang, A. Wettig, S. Yao, K. Pei, O. Press, and K. Narasimhan, “SWE-bench: Can Language Models Resolve Real-World GitHub Issues?” in Proceedings of the International Conference on Learning Representations (ICLR), 2024.
[5] G. Lucassen, F. Dalpiaz, J. M. E. M. van der Werf, and S. Brinkkemper, "Improving Agile Requirements: The Quality User Story Framework and Tool," Requirements Engineering (RE), vol. 21, no. 3, pp. 383–403, 2016.
[6] G. Quattrocchi, L. Pasquale, P. Spoletini, and L. Baresi, “Can LLMs Generate User Stories and Assess Their Quality?” IEEE Transactions on Software Engineering (TSE), 2026, early access.
[7] A. Yamani, M. Baslyman, and M. Ahmed, “Leveraging LLMs for User Stories in AI Systems: UStAI Dataset,” in Proceedings of the International Conference on Predictive Models and Data Analytics in Software Engineering (PROMISE), 2025.
[8] M. Rath and P. Mäder, “The SEOSS 33 dataset — Requirements, bug reports, code history, and trace links for entire projects,” Data in Brief, vol. 25, p. 104005, 2019.
[9] Z. Alshara, A. Shatnawi, H. Eyal-Salman, A.-D. Seriai, and M. Shatnawi, "PI-Link: A Ground-Truth Dataset of Links Between Pull-Requests and Issues in GitHub," IEEE Access, vol. 11, pp. 697–710, 2023.
[10] A. Majidzadeh, M. Ashtiani, and M. Zakeri-Nasrabadi, “Datasets of Issue-Commit and Issue-Method Links Extracted from GitHub Repositories,” 2022. [Online]. Available: https://doi.org/10.5281/zenodo.7876253
[11] R. Elamin and R. Osman, “Implementing Traceability Repositories as Graph Databases for Software Quality Improvement,” in Proceedings of the International Conference on Software Quality, Reliability and Security (QRS), 2018.
[12] P.-P. Pärtachi, D. R. White, and E. T. Barr, “Aide-Mémoire: Improving a Project’s Collective Memory via Pull Request–Issue Links,” ACM TOSEM, vol. 32, no. 2, pp. 1–36, 2023.
[13] H. Xue, R. Aleithan, N. Enan, G. Uddin, and S. Wang, “SWE-Bench+: Enhanced llm coding benchmark,” in Proceedings of the International Conference on AI-powered Software (AIware), 2026.
[14] S. Liang, S. Garg, and R. Z. Moghaddam, “The SWE-Bench Illusion: When State-of-the-Art LLMs Remember Instead of Reason,” in Proceedings of the IEEE/ACM International Conference on Software Engineering: Software Engineering in Practice (ICSE-SEIP), 2026.
[15] B. Donato, L. Mariani, D. Micucci, and O. Riganelli, “PR4Code: A Pull Requests Dataset for AI Code Generation,” IEEE Access, vol. 14, pp. 108479–108491, 2026.
[16] K. Reitz et al., “Requests: HTTP for Humans.” [Online]. Available: https://requests.readthedocs.io/en/latest/
[17] GitHub, “GitHub 2.0, A small place to discover languages in GitHub,” https://madnight.github.io/github/#/pull_requests/2024/1, 2024.