
Specstory Organize
- 270 installs
- 31 repo stars
- Updated January 31, 2026
- specstoryai/agent-skills
specstory-organize is a Claude agent skill that sorts SpecStory AI coding session files from .specstory/history into year/month folders for developers who need dated archives of agent session markdown without manual file
About
specstory-organize is a Claude Code skill from specstoryai/agent-skills (version 1.0.0, Apache-2.0) that organizes SpecStory session history by moving markdown files from .specstory/history into YYYY/MM subdirectories based on timestamps embedded in filenames like 2026-01-22_19-20-56Z-fix-bug.md. The skill scans the history directory, extracts dates from filenames, creates year and month folders, moves files, and reports a per-month breakdown. Developers reach for specstory-organize when hundreds of session files make it hard to find work from a specific period or keep the project directory clean. Invocation paths include the /specstory-organize slash command, natural phrases like organize my history, and direct execution of skills/specstory-organize/scripts/organize.py with an optional --dry-run preview. Files without recognizable date patterns are skipped; already-organized files in subdirectories are not moved again. The Python script is compatible with Python 2.7+ and Python 3.x and uses filename timestamps rather than file modification times.
- specstory-organize
Specstory Organize by the numbers
- 270 all-time installs (skills.sh)
- +1 installs in the week ending Aug 5, 2026 (Skillselion tracking)
- Ranked #1,440 of 4,347 Backend & APIs skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/specstoryai/agent-skills --skill specstory-organizeAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 270 |
|---|---|
| repo stars | ★ 31 |
| Last updated | January 31, 2026 |
| Repository | specstoryai/agent-skills ↗ |
How do you organize SpecStory session history files?
Use specstory-organize for development tasks
Who is it for?
Developers using SpecStory who accumulate large .specstory/history directories and need automated year/month archival sorting.
Skip if: Editing session content, syncing history to cloud storage, or organizing non-SpecStory project files outside .specstory/history.
When should I use this skill?
A user says organize my history, clean up specstory, sort my sessions, or wants /specstory-organize with optional dry-run preview.
What you get
Dated YYYY/MM folder tree under .specstory/history with moved session markdown files and a per-month move summary report.
- YYYY/MM folder tree
- organize summary report
By the numbers
- Version 1.0.0 under Apache-2.0 license from SpecStory, Inc.
- Organizes files into 2-level YYYY/MM directory paths
- Includes a Python organize.py script with --dry-run support
Files
SpecStory Organize
Organizes your .specstory/history directory by moving session files into YYYY/MM/ subdirectories based on the timestamp in each filename.
How It Works
1. Scans .specstory/history/ for markdown files 2. Extracts the date from filenames (e.g., 2026-01-22_19-20-56Z-fix-bug.md) 3. Creates year/month folders (e.g., 2026/01/) 4. Moves files into the appropriate subdirectory 5. Reports what was moved
Why Organize?
Over time, your history directory can accumulate hundreds of session files. Organizing by date makes it easier to:
- Find sessions from a specific time period
- Archive old sessions
- Keep your project directory clean
Usage
Slash Command
| User says | Action |
|---|---|
/specstory-organize | Organize all files (default) |
/specstory-organize dry run | Preview changes without moving |
/specstory-organize --dry-run | Preview changes without moving |
Direct Script Usage
# From project root
python skills/specstory-organize/scripts/organize.py
# Preview what would be moved (no changes made)
python skills/specstory-organize/scripts/organize.py --dry-runOutput
SpecStory History Organizer
===========================
Found 47 files to organize in .specstory/history/
Moving files:
2026-01-15_10-30-22Z-refactor-auth.md -> 2026/01/
2026-01-15_14-22-01Z-fix-tests.md -> 2026/01/
2026-01-22_19-20-56Z-add-feature.md -> 2026/01/
2025-12-28_09-15-33Z-cleanup.md -> 2025/12/
...
Summary:
--------
Files moved: 47
2026/01/: 23 files
2025/12/: 18 files
2025/11/: 6 files
Your history is now organized!Dry Run Output
When using --dry-run:
SpecStory History Organizer (DRY RUN)
=====================================
Would organize 47 files in .specstory/history/
Preview:
2026-01-15_10-30-22Z-refactor-auth.md -> 2026/01/
2026-01-15_14-22-01Z-fix-tests.md -> 2026/01/
...
No files were moved. Run without --dry-run to apply changes.Present Results to User
After running the organize script:
1. Confirm success - Tell the user how many files were organized 2. Show the breakdown - List how many files went to each month 3. Note any skips - If files couldn't be parsed (no date in filename), mention them
Example Response
Done! I organized 47 session files in your `.specstory/history/` directory:
- **2026/01/**: 23 files
- **2025/12/**: 18 files
- **2025/11/**: 6 files
Your history files are now sorted by year and month, making it much easier
to find sessions from specific time periods.Notes
- Files without a recognizable date pattern in the filename are skipped
- The script uses the filename timestamp, not the file's modification time
- Already-organized files (in subdirectories) are not moved again
- Compatible with Python 2.7+ and Python 3.x
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License./specstory-organize
Organizes the project's .specstory/history directory into year and month subfolders.
What It Does
Moves .md files from .specstory/history/ into .specstory/history/YYYY/MM/ subdirectories based on the timestamp in each filename (not the file's modification time). Creates year and month directories as needed, and leaves non-.md files or files without valid timestamps in place.
Installation
If using npx skills from the npx skills repository:
npx skills add specstoryai/agent-skillsTo install manually, clone the repo:
git clone https://github.com/specstoryai/agent-skills
cp -r agent-skills/skills/specstory-organize ~/.claude/skills/Usage
/specstory-organizeLicense
The /specstory-organize skill is licensed under the Apache 2.0 open source license.
Copyright 2025-2026 by SpecStory, Inc., All Rights Reserved.
SpecStory® is a registered trademark of SpecStory, Inc.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Organize SpecStory history files into YYYY/MM subdirectories.
Moves .md files from .specstory/history/ into .specstory/history/YYYY/MM/
based on the timestamp in the filename (not the file's modification time).
Compatible with Python 2.7+ and Python 3.x
"""
from __future__ import print_function
import os
import re
import shutil
import sys
# Pattern to extract YYYY-MM-DD from filenames like:
# 2025-09-17_13-45-37Z-description.md
# 2025-10-09_13-19Z-description.md
# 2025-10-15_02-58-52Z.md
DATE_PATTERN = re.compile(r'^(\d{4})-(\d{2})-\d{2}_')
def find_specstory_history():
"""
Find the .specstory/history directory relative to current working directory.
Returns the path if found, None otherwise.
"""
history_dir = os.path.join(os.getcwd(), '.specstory', 'history')
if os.path.isdir(history_dir):
return history_dir
return None
def extract_year_month(filename):
"""
Extract year and month from a filename.
Returns (year, month) tuple if found, None otherwise.
"""
match = DATE_PATTERN.match(filename)
if match:
return (match.group(1), match.group(2))
return None
def organize_history(history_dir, dry_run=False):
"""
Organize .md files in history_dir into YYYY/MM subdirectories.
Args:
history_dir: Path to the .specstory/history directory
dry_run: If True, only print what would be done without moving files
Returns:
Tuple of (moved_count, skipped_count, error_count)
"""
moved = 0
skipped = 0
errors = 0
# Get list of files in history directory (not subdirectories)
try:
entries = os.listdir(history_dir)
except OSError as e:
print("Error listing directory: %s" % e)
return (0, 0, 1)
for entry in entries:
entry_path = os.path.join(history_dir, entry)
# Skip directories
if os.path.isdir(entry_path):
continue
# Skip non-.md files
if not entry.endswith('.md'):
print("Skipping non-.md file: %s" % entry)
skipped += 1
continue
# Extract year and month from filename
date_parts = extract_year_month(entry)
if date_parts is None:
print("Skipping file without valid timestamp: %s" % entry)
skipped += 1
continue
year, month = date_parts
# Build destination directory path
dest_dir = os.path.join(history_dir, year, month)
dest_path = os.path.join(dest_dir, entry)
if dry_run:
print("Would move: %s -> %s/%s/" % (entry, year, month))
moved += 1
continue
try:
# Create year directory if needed
year_dir = os.path.join(history_dir, year)
if not os.path.exists(year_dir):
os.mkdir(year_dir)
# Create month directory if needed
if not os.path.exists(dest_dir):
os.mkdir(dest_dir)
# Remove destination file if it exists (to allow overwrite)
if os.path.exists(dest_path):
os.remove(dest_path)
# Move the file
shutil.move(entry_path, dest_path)
print("Moved: %s -> %s/%s/" % (entry, year, month))
moved += 1
except OSError as e:
print("Error moving %s: %s" % (entry, e))
errors += 1
except Exception as e:
print("Unexpected error moving %s: %s" % (entry, e))
errors += 1
return (moved, skipped, errors)
def main():
"""Main entry point."""
# Check for --dry-run flag
dry_run = '--dry-run' in sys.argv or '-n' in sys.argv
# Find the history directory
history_dir = find_specstory_history()
if history_dir is None:
print("Error: Could not find .specstory/history directory")
print("Make sure you are running this script from a project root")
print("that contains a .specstory/history directory.")
sys.exit(1)
print("Organizing: %s" % history_dir)
if dry_run:
print("(Dry run - no files will be moved)")
print("")
moved, skipped, errors = organize_history(history_dir, dry_run=dry_run)
print("")
print("Complete: %d moved, %d skipped, %d errors" % (moved, skipped, errors))
if errors > 0:
sys.exit(1)
if __name__ == '__main__':
main()
Related skills
How it compares
Use specstory-organize for SpecStory history folder sorting; use general filesystem skills when organizing code outside .specstory/history.
FAQ
How does specstory-organize determine folder placement?
specstory-organize extracts dates from session filenames such as 2026-01-22_19-20-56Z-fix-bug.md and moves each file into a YYYY/MM subdirectory like 2026/01/. The script uses the filename timestamp, not the file modification time, and skips files without a recognizable date patt
Can specstory-organize preview changes before moving files?
specstory-organize supports --dry-run on organize.py and phrases like dry run or /specstory-organize --dry-run to list planned moves without changing the filesystem. Running without --dry-run applies the year/month folder organization to all eligible files in .specstory/history.
What triggers specstory-organize activation?
specstory-organize activates when users say organize my history, clean up specstory, sort my sessions, or organize specstory files. The slash command /specstory-organize and direct python skills/specstory-organize/scripts/organize.py invocation are also supported paths.