OpenSpec icon indicating copy to clipboard operation
OpenSpec copied to clipboard

[Feature Request] Allow configurable OpenSpec directory name

Open diegohb opened this issue 10 months ago • 9 comments

Problem Statement

Currently, the OpenSpec directory name is hardcoded as OPENSPEC_DIR_NAME = 'openspec' in src/core/config.ts 1 . This prevents users from customizing the directory name to suit their project conventions or preferences.

Use Case

Users working in environments with specific naming conventions or those who want to integrate OpenSpec into existing project structures may need to use a different directory name than the default openspec/. For example, a team might prefer .openspec/, specs/, or docs/openspec/ to match their existing documentation structure.

Proposed Solution

Add configuration support for customizing the OpenSpec directory name through the existing configuration systems:

Option 1: Global Configuration

Add a directoryName field to the GlobalConfig interface 2 :

export interface GlobalConfig {
  featureFlags?: Record<string, boolean>;
  directoryName?: string; // New field
}

Option 2: Project Configuration

Add support for openspec.config.yaml (as discussed in docs/project-config-demo.md 3 ) with a directoryName field:

# openspec.config.yaml
directoryName: .openspec  # or any preferred name

Implementation Approach

  1. Modify config resolution: Update the configuration loading logic to check for a custom directory name, with precedence:

    • Project-level openspec.config.yaml (highest priority)
    • Global config 4
    • Default 'openspec' (fallback)
  2. Update directory references: Replace hardcoded OPENSPEC_DIR_NAME usage with a function that resolves the directory name based on configuration.

  3. Update CLI commands: Modify init, update, and other commands to use the configurable directory name.

Benefits

  • Flexibility: Teams can adopt OpenSpec without disrupting existing directory structures
  • Integration: Better compatibility with different project layouts and conventions
  • Backward compatibility: Default behavior remains unchanged for existing users

Files to Modify

  • src/core/config.ts - Add directory name resolution logic
  • src/core/global-config.ts - Extend GlobalConfig interface
  • src/core/init.ts - Use configurable directory name 5
  • src/core/update.ts - Update directory resolution 6
  • src/commands/config.ts - Add config management for directory name

Notes

This feature leverages the existing configuration infrastructure 7 and aligns with the project configuration work already documented in docs/project-config-demo.md 3 .

Citations

File: src/core/config.ts (L1-1)

export const OPENSPEC_DIR_NAME = 'openspec';

File: src/core/global-config.ts (L1-79)

import * as fs from 'node:fs';
import * as path from 'node:path';
import * as os from 'node:os';

// Constants
export const GLOBAL_CONFIG_DIR_NAME = 'openspec';
export const GLOBAL_CONFIG_FILE_NAME = 'config.json';
export const GLOBAL_DATA_DIR_NAME = 'openspec';

// TypeScript interfaces
export interface GlobalConfig {
  featureFlags?: Record<string, boolean>;
}

const DEFAULT_CONFIG: GlobalConfig = {
  featureFlags: {}
};

/**
 * Gets the global configuration directory path following XDG Base Directory Specification.
 *
 * - All platforms: $XDG_CONFIG_HOME/openspec/ if XDG_CONFIG_HOME is set
 * - Unix/macOS fallback: ~/.config/openspec/
 * - Windows fallback: %APPDATA%/openspec/
 */
export function getGlobalConfigDir(): string {
  // XDG_CONFIG_HOME takes precedence on all platforms when explicitly set
  const xdgConfigHome = process.env.XDG_CONFIG_HOME;
  if (xdgConfigHome) {
    return path.join(xdgConfigHome, GLOBAL_CONFIG_DIR_NAME);
  }

  const platform = os.platform();

  if (platform === 'win32') {
    // Windows: use %APPDATA%
    const appData = process.env.APPDATA;
    if (appData) {
      return path.join(appData, GLOBAL_CONFIG_DIR_NAME);
    }
    // Fallback for Windows if APPDATA is not set
    return path.join(os.homedir(), 'AppData', 'Roaming', GLOBAL_CONFIG_DIR_NAME);
  }

  // Unix/macOS fallback: ~/.config
  return path.join(os.homedir(), '.config', GLOBAL_CONFIG_DIR_NAME);
}

/**
 * Gets the global data directory path following XDG Base Directory Specification.
 * Used for user data like schema overrides.
 *
 * - All platforms: $XDG_DATA_HOME/openspec/ if XDG_DATA_HOME is set
 * - Unix/macOS fallback: ~/.local/share/openspec/
 * - Windows fallback: %LOCALAPPDATA%/openspec/
 */
export function getGlobalDataDir(): string {
  // XDG_DATA_HOME takes precedence on all platforms when explicitly set
  const xdgDataHome = process.env.XDG_DATA_HOME;
  if (xdgDataHome) {
    return path.join(xdgDataHome, GLOBAL_DATA_DIR_NAME);
  }

  const platform = os.platform();

  if (platform === 'win32') {
    // Windows: use %LOCALAPPDATA%
    const localAppData = process.env.LOCALAPPDATA;
    if (localAppData) {
      return path.join(localAppData, GLOBAL_DATA_DIR_NAME);
    }
    // Fallback for Windows if LOCALAPPDATA is not set
    return path.join(os.homedir(), 'AppData', 'Local', GLOBAL_DATA_DIR_NAME);
  }

  // Unix/macOS fallback: ~/.local/share
  return path.join(os.homedir(), '.local', 'share', GLOBAL_DATA_DIR_NAME);
}

diegohb avatar Jan 26 '26 04:01 diegohb

https://deepwiki.com/search/how-do-i-specify-the-location_89c903b6-06aa-4b54-9d32-f416833760ca?mode=fast

diegohb avatar Jan 26 '26 04:01 diegohb

This change also needs to consider that all openspec skills & commands (i.e the prompts we use) would also have to then reference the user configured version. (Including every and all future updates to the skills)

It also becomes a edge case we have to consider when building future features. I'm not too sure if the ROI is really justified because of the complexity it introduces for me as the single current maintainer of the project.

Don't get me wrong, is this technically possible? - Yes I'm not doubting that, I just don't think the complexity justifies the ROI especially when the name "openspec" is not common and would not conflict with anything at the root.

(Think of how many projects have a folder at the root .claude, .github, .changesets etc Yes we don't make it a hidden folder but that's intentional as in our testing agents do a worse job at grepping hidden folders )

TabishB avatar Jan 26 '26 10:01 TabishB

I have the same problem as OP. I'm working in a fairly big project with about 40 modules or something. OpenSpec just disappears in the midst of all of them, which makes navigation hard. I understand the reasoning, but I would prefer to have a hidden folder; it would appear at the top. It's not a hard requirement or anything like that, but I just wanted to give my experience and two cents.

chennemann avatar Jan 27 '26 15:01 chennemann

Good morning.

Our team currently has a monorepo with multiple packages and an existing ./specs/ directory that predates OpenSpec. These specs were created both manually and with other tools, and there is already a significant number of them. We have also created our own OpenSpec schema so that newly created specs are aligned with what already existed.

At the very least, OpenSpec’s configuration should provide an option to specify the final specs directory within the repository, so it can read from the already-final specs and ensure that new ones are generated into the project’s specs directory.

OpenSpec is just a tool; it should not impose where specs are created within a repository. Today we may use OpenSpec, tomorrow something else, but the specs belong to the project and should be able to live and move with the project outside of ./openspec/specs.

Currently, running openspec list --specs does not show any specs in our case unless they are located in ./openspec/specs, which obviously ties the specs to OpenSpec rather than to the project itself.

One possible workaround is to create a symbolic link from ./openspec/specs to ./specs, but this also causes agents to occasionally behave erratically when they see specs in multiple locations, or to make changes in one place or the other (I know it ultimately points to the same files, but it shouldn’t happen).

I believe that, at a minimum, having the option to specify the specs directory is fundamental.

lsmonki avatar Feb 02 '26 12:02 lsmonki

+1

  1. I want team to pick any spec coding method they want (spec-kit、open-spec、bmad), but all artifact output folders should follow the same rule.
  2. monorepo should have child workspace for each sub-package.

Example:

  • {monorepo}/{package}/{docs}/{spec-kit}/*
  • {monorepo}/{package}/{docs}/{open-spec}/*
  • {monorepo}/{package}/{docs}/{bmad}/*

EggTronic avatar Feb 03 '26 07:02 EggTronic

  • {monorepo}/{package}/{docs}/{spec-kit}/*
  • {monorepo}/{package}/{docs}/{open-spec}/*
  • {monorepo}/{package}/{docs}/{bmad}/*

Well, in our case, even though it’s a monorepo, all the specs are located at the root, with this structure:

specs/
    _global/ (or shared/)
        capability-spec-1/
    package-1/
        capability-spec-2/
    package-2/
    .....
openspec/
    specs/ <- Not used, symlinked to ../specs/

At this point we have another issue: OpenSpec expects a flat, non-hierarchical list of folders, but we are preparing a feature to support this. We’ll send the PR later.

lsmonki avatar Feb 03 '26 09:02 lsmonki

Exploring #664 (customizable specsPath), we realized the same pattern could extend to make the entire OpenSpec directory structure configurable: config field + path resolution utility + placeholder replacement in templates.

The Idea

Instead of hardcoding openspec/ as the root, we can:

  1. Move config to project root as openspec.config.yaml (as @diegohb suggested)
  2. Add path fields for each directory: specsPath, changesPath, archivePath, schemasPath
  3. Support local overrides via openspec.config.local.yaml (gitignored)

This effectively makes the openspec/ directory optional — you can have everything wherever you want.

Example Configuration

# openspec.config.yaml (at project root)
schema: spec-driven

# All paths relative to project root. All optional with backwards-compatible defaults.
specsPath: specs                    # default: openspec/specs
changesPath: dev/changes            # default: openspec/changes
archivePath: dev/archive            # default: openspec/changes/archive
schemasPath: dev/sdd-schemas        # default: openspec/schemas

Use Cases

1. Existing specs directory

Projects with a specs/ directory predating OpenSpec can keep it:

specsPath: specs

No need to move anything or create symlinks.

2. Monorepos

2.1. Monorepo with single config (works today)

A monorepo with one config at the root works fine:

monorepo/
├── openspec.config.yaml      ← Single config at root
├── .claude/skills/           ← Skills here, used by AI
├── specs/                    ← Shared specs
├── changes/                  ← Shared changes
└── packages/
    ├── api/
    └── web/
# openspec.config.yaml
specsPath: specs
changesPath: changes

This is the recommended approach for monorepos until per-package support is addressed.

2.2. Monorepo per-package organization

As @EggTronic mentioned, monorepos need flexibility for per-package organization. Each package can have its own config and specs:

monorepo/
├── packages/
│   ├── api/
│   │   ├── openspec.config.yaml
│   │   ├── specs/
│   │   └── src/
│   └── web/
│       ├── openspec.config.yaml
│       ├── specs/
│       └── src/

Each package has its own config and specs. Run openspec from the package directory (or use --path packages/api)

Note: Full monorepo support with per-package configs doesn't work well currently. AI tools (Claude, Codex, etc.) look for the git root to find their skills directory.

So even if you run openspec update in a package, those skills (.claude/, .codex/, etc.) won't be used — the AI will use the skills at the monorepo root instead.

Proper monorepo support would require additional work: smarter skill prompts that discover configs dynamically, possibly a root-level monorepo config listing package paths, and maybe a new command to query project config at runtime. This is a separate topic to explore, but the path configuration foundation would enable it.

3. Custom directory naming

As @diegohb mentioned in the original issue (.openspec/, specs/, docs/openspec/), teams have different conventions:

# Use .openspec/ (hidden)
specsPath: .openspec/specs
changesPath: .openspec/changes

# Or under docs/
specsPath: docs/specifications
changesPath: docs/changes

4. Separate archive repository

Keep your main repo clean by archiving to a separate repository:

archivePath: ../archive-repo/my-project

When archiving, OpenSpec warns that the path is external and commits are the developer's responsibility.

5. Multi-repo shared archive

Multiple projects archiving to a shared history repo:

workspace/
├── project-a/
│   └── openspec.config.yaml  →  archivePath: ../shared-archive/project-a
├── project-b/
│   └── openspec.config.yaml  →  archivePath: ../shared-archive/project-b
└── shared-archive/
    ├── project-a/
    │   └── 2026-02-05-feature-x/
    └── project-b/
        └── 2026-02-04-bugfix-y/

6. Developer-specific local overrides

openspec.config.local.yaml (gitignored) allows developers to customize paths for their setup:

# openspec.config.local.yaml
# I keep my archive elsewhere locally
archivePath: ~/openspec-archives/this-project

Backwards Compatibility

  • No breaking changes — All fields optional, defaults match current behavior
  • Legacy config location — openspec/config.yaml still works if root config doesn't exist
  • No migration required — Existing projects work unchanged

This is an advanced feature for teams that need it. The default experience remains the same.

Thoughts?

lsmonki avatar Feb 06 '26 09:02 lsmonki

Love this idea lsmonki :)

Just getting into OpenSpec myself and ran into this issue right away with monorepos and the desire to rename the directory. When can we expect to see this implemented?

bgoewert-seiler avatar May 26 '26 14:05 bgoewert-seiler

Thanks for raising this, @diegohb 🙏

This is about Let users rename/relocate the hardcoded openspec/ directory (and later, all sub-paths). — an open-ended feature/design idea rather than a discrete, PR-actionable bug or task. To honor it properly we've moved it to Discussions, where it can keep evolving with community input and you can re-engage anytime:

👉 https://github.com/Fission-AI/OpenSpec/discussions/1555

The original issue (and any comments) stays here for the record, so nothing is lost — please continue the conversation in the discussion above. Closing the issue in favor of that thread.

clay-good avatar Aug 06 '26 18:08 clay-good