Skip to content

Feature Request: Add Project/Workspace Context Tags to Obsidian Frontmatter #24

@possebon

Description

@possebon

Feature Request: Add Project/Workspace Context Tags

Problem Statement

When working across multiple projects in Claude Code, all approved plans are saved to Obsidian with generic tags (plannotator, title words, code languages). This makes it difficult to:

  • Filter plans by project in Obsidian
  • Understand which workspace a plan belongs to
  • Organize plans in knowledge graphs by project context

Proposed Solution

Automatically detect and add a project tag to plan frontmatter based on the current working directory context.

Implementation Approaches

1. Git Repository Name (Recommended)

Priority: Fallback to directory name if not in a git repo

Advantages:

  • Most accurate for version-controlled projects
  • Consistent across different workspace paths
  • Matches developer mental model

Implementation:

async function detectProjectName(): Promise<string | null> {
  try {
    // Try git repository name first
    const gitResult = await $`git rev-parse --show-toplevel`.quiet().nothrow();
    if (gitResult.exitCode === 0) {
      const repoPath = gitResult.stdout.toString().trim();
      const repoName = repoPath.split('/').pop();
      if (repoName) {
        return repoName.toLowerCase();
      }
    }
  } catch {}

  // Fallback to current directory name
  const cwd = process.cwd();
  const dirName = cwd.split('/').pop();
  if (dirName && dirName !== '/' && dirName !== 'home') {
    return dirName.toLowerCase();
  }

  return null;
}

2. Working Directory Name Only

Advantages:

  • Simple implementation
  • Always works (no git dependency)
  • Fast execution

Disadvantages:

  • Less semantic (e.g., workspace vs my-awesome-app)
  • Can vary based on where code is cloned

3. Custom Environment Variable

Example: PROJECT_NAME=my-app

Advantages:

  • Maximum user control
  • Can override auto-detection
  • Works for any setup

Disadvantages:

  • Requires manual configuration per project
  • Easy to forget to set

4. Smart Detection Chain (Most Flexible)

Try in order:

  1. Environment variable (PROJECT_NAME)
  2. Git repository name
  3. Working directory name

Example Output

Current frontmatter:

---
created: 2026-01-05T14:30:49.314Z
source: plannotator
tags: [plannotator, authentication, typescript]
---

With project tag:

---
created: 2026-01-05T14:30:49.314Z
source: plannotator
tags: [plannotator, my-awesome-app, authentication, typescript]
---

Modified Functions

The extractTags() function would become async and call detectProjectName() early:

async function extractTags(markdown: string): Promise<string[]> {
  const tags = new Set<string>(["plannotator"]);

  // Add project name tag
  const projectName = await detectProjectName();
  if (projectName) {
    tags.add(projectName);
  }

  // ... existing tag extraction logic
  return Array.from(tags).slice(0, 7); // Increase limit to 7 for project tag
}

Benefits

  1. Better Organization: Plans grouped by project in Obsidian graph view
  2. Easier Filtering: Search tag:#my-project to see all related plans
  3. Context Preservation: Know which codebase a plan belongs to at a glance
  4. Multi-Project Workflows: Essential for consultants/agencies working on multiple clients

Use Case

Working on 5 different projects daily. When reviewing old plans in Obsidian weeks later, it's unclear which project they belong to without opening the file and reading the content.

With project tags: Instant filtering and organization by project context.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions