From a26d0ee6ed714cc3fa62d3160e1010c9f8f21f24 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 21 Jan 2026 23:08:46 +0000 Subject: [PATCH 1/4] Add .keep file to .deepwork/tmp for version control persistence The .deepwork/tmp directory is referenced in Claude Code permissions but wasn't being tracked by git, causing the directory to not exist when Claude Code starts in a fresh clone. This adds a .keep file to ensure the directory persists in version control and updates the install process to create it automatically. --- .deepwork/tmp/.keep | 3 +++ .gitignore | 5 +++-- src/deepwork/cli/install.py | 28 +++++++++++++++++++++++++++- 3 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 .deepwork/tmp/.keep diff --git a/.deepwork/tmp/.keep b/.deepwork/tmp/.keep new file mode 100644 index 00000000..971fbd5c --- /dev/null +++ b/.deepwork/tmp/.keep @@ -0,0 +1,3 @@ +# This file ensures the .deepwork/tmp directory exists in version control. +# The tmp directory is used for temporary files during DeepWork operations. +# Do not delete this file. diff --git a/.gitignore b/.gitignore index 93694a7d..c3f4096f 100644 --- a/.gitignore +++ b/.gitignore @@ -82,9 +82,10 @@ dmypy.json # Temporary files *.tmp .temp/ -tmp/ +/tmp/ # DeepWork runtime artifacts .deepwork/.last_work_tree .deepwork/.last_head_ref -.deepwork/tmp/ +.deepwork/tmp/* +!.deepwork/tmp/.keep diff --git a/src/deepwork/cli/install.py b/src/deepwork/cli/install.py index 96c68bb2..cad5a39d 100644 --- a/src/deepwork/cli/install.py +++ b/src/deepwork/cli/install.py @@ -124,6 +124,28 @@ def _create_deepwork_gitignore(deepwork_dir: Path) -> None: gitignore_path.write_text(gitignore_content) +def _create_tmp_directory(deepwork_dir: Path) -> None: + """ + Create the .deepwork/tmp directory with a .keep file. + + This ensures the tmp directory exists in version control, which is required + for file permissions to work correctly when Claude Code starts fresh. + + Args: + deepwork_dir: Path to .deepwork directory + """ + tmp_dir = deepwork_dir / "tmp" + ensure_dir(tmp_dir) + + keep_file = tmp_dir / ".keep" + if not keep_file.exists(): + keep_file.write_text( + "# This file ensures the .deepwork/tmp directory exists in version control.\n" + "# The tmp directory is used for temporary files during DeepWork operations.\n" + "# Do not delete this file.\n" + ) + + def _create_rules_directory(project_path: Path) -> bool: """ Create the v2 rules directory structure with example templates. @@ -333,7 +355,11 @@ def _install_deepwork(platform_name: str | None, project_path: Path) -> None: _create_deepwork_gitignore(deepwork_dir) console.print(" [green]✓[/green] Created .deepwork/.gitignore") - # Step 3d: Create rules directory with v2 templates + # Step 3d: Create tmp directory with .keep file for version control + _create_tmp_directory(deepwork_dir) + console.print(" [green]✓[/green] Created .deepwork/tmp/.keep") + + # Step 3e: Create rules directory with v2 templates if _create_rules_directory(project_path): console.print(" [green]✓[/green] Created .deepwork/rules/ with example templates") else: From fe36b8a8b48230f239917bf76f4cda45380e29e0 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 21 Jan 2026 23:16:49 +0000 Subject: [PATCH 2/4] Add .last_head_ref to installed .deepwork/.gitignore Include .last_head_ref alongside .last_work_tree in the .gitignore that gets created during deepwork install. --- src/deepwork/cli/install.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/deepwork/cli/install.py b/src/deepwork/cli/install.py index cad5a39d..e5e04066 100644 --- a/src/deepwork/cli/install.py +++ b/src/deepwork/cli/install.py @@ -111,15 +111,15 @@ def _create_deepwork_gitignore(deepwork_dir: Path) -> None: gitignore_content = """# DeepWork temporary files # These files are used for rules evaluation during sessions .last_work_tree +.last_head_ref """ - # Only write if it doesn't exist or doesn't contain the entry + # Only write if it doesn't exist or doesn't contain all entries if gitignore_path.exists(): existing_content = gitignore_path.read_text() - if ".last_work_tree" not in existing_content: - # Append to existing - with open(gitignore_path, "a") as f: - f.write("\n" + gitignore_content) + if ".last_work_tree" not in existing_content or ".last_head_ref" not in existing_content: + # Overwrite with complete content + gitignore_path.write_text(gitignore_content) else: gitignore_path.write_text(gitignore_content) From 313fbad0114587355ab34d0a1077803cfb23aa10 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 21 Jan 2026 23:52:52 +0000 Subject: [PATCH 3/4] Rename .keep to .gitkeep for clarity .gitkeep is the more widely recognized convention for placeholder files that ensure directories are tracked by git. --- .deepwork/tmp/{.keep => .gitkeep} | 0 .gitignore | 2 +- src/deepwork/cli/install.py | 12 ++++++------ 3 files changed, 7 insertions(+), 7 deletions(-) rename .deepwork/tmp/{.keep => .gitkeep} (100%) diff --git a/.deepwork/tmp/.keep b/.deepwork/tmp/.gitkeep similarity index 100% rename from .deepwork/tmp/.keep rename to .deepwork/tmp/.gitkeep diff --git a/.gitignore b/.gitignore index c3f4096f..3e320776 100644 --- a/.gitignore +++ b/.gitignore @@ -88,4 +88,4 @@ dmypy.json .deepwork/.last_work_tree .deepwork/.last_head_ref .deepwork/tmp/* -!.deepwork/tmp/.keep +!.deepwork/tmp/.gitkeep diff --git a/src/deepwork/cli/install.py b/src/deepwork/cli/install.py index e5e04066..3d950dc4 100644 --- a/src/deepwork/cli/install.py +++ b/src/deepwork/cli/install.py @@ -126,7 +126,7 @@ def _create_deepwork_gitignore(deepwork_dir: Path) -> None: def _create_tmp_directory(deepwork_dir: Path) -> None: """ - Create the .deepwork/tmp directory with a .keep file. + Create the .deepwork/tmp directory with a .gitkeep file. This ensures the tmp directory exists in version control, which is required for file permissions to work correctly when Claude Code starts fresh. @@ -137,9 +137,9 @@ def _create_tmp_directory(deepwork_dir: Path) -> None: tmp_dir = deepwork_dir / "tmp" ensure_dir(tmp_dir) - keep_file = tmp_dir / ".keep" - if not keep_file.exists(): - keep_file.write_text( + gitkeep_file = tmp_dir / ".gitkeep" + if not gitkeep_file.exists(): + gitkeep_file.write_text( "# This file ensures the .deepwork/tmp directory exists in version control.\n" "# The tmp directory is used for temporary files during DeepWork operations.\n" "# Do not delete this file.\n" @@ -355,9 +355,9 @@ def _install_deepwork(platform_name: str | None, project_path: Path) -> None: _create_deepwork_gitignore(deepwork_dir) console.print(" [green]✓[/green] Created .deepwork/.gitignore") - # Step 3d: Create tmp directory with .keep file for version control + # Step 3d: Create tmp directory with .gitkeep file for version control _create_tmp_directory(deepwork_dir) - console.print(" [green]✓[/green] Created .deepwork/tmp/.keep") + console.print(" [green]✓[/green] Created .deepwork/tmp/.gitkeep") # Step 3e: Create rules directory with v2 templates if _create_rules_directory(project_path): From 60a33c33a7fb74571c169efb06d4b6cd7c2351da Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 21 Jan 2026 23:59:34 +0000 Subject: [PATCH 4/4] Move .deepwork ignores from root .gitignore to .deepwork/.gitignore Consolidates all .deepwork-related gitignore rules into .deepwork/.gitignore where they belong. This avoids conflicts with users' root .gitignore files and keeps the ignore rules with the directory they apply to. --- .deepwork/.gitignore | 9 +++++++-- .gitignore | 6 ------ src/deepwork/cli/install.py | 21 ++++++++++----------- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/.deepwork/.gitignore b/.deepwork/.gitignore index 0ef10e54..7b273563 100644 --- a/.deepwork/.gitignore +++ b/.deepwork/.gitignore @@ -1,3 +1,8 @@ -# DeepWork temporary files -# These files are used for rules evaluation during sessions +# DeepWork runtime artifacts +# These files are generated during sessions and should not be committed .last_work_tree +.last_head_ref + +# Temporary files (but keep the directory via .gitkeep) +tmp/* +!tmp/.gitkeep diff --git a/.gitignore b/.gitignore index 3e320776..60a72bee 100644 --- a/.gitignore +++ b/.gitignore @@ -83,9 +83,3 @@ dmypy.json *.tmp .temp/ /tmp/ - -# DeepWork runtime artifacts -.deepwork/.last_work_tree -.deepwork/.last_head_ref -.deepwork/tmp/* -!.deepwork/tmp/.gitkeep diff --git a/src/deepwork/cli/install.py b/src/deepwork/cli/install.py index 3d950dc4..5d525475 100644 --- a/src/deepwork/cli/install.py +++ b/src/deepwork/cli/install.py @@ -102,26 +102,25 @@ def _create_deepwork_gitignore(deepwork_dir: Path) -> None: """ Create .gitignore file in .deepwork/ directory. - This ensures that temporary files like .last_work_tree are not committed. + This ensures that runtime artifacts are not committed while keeping + the tmp directory structure in version control. Args: deepwork_dir: Path to .deepwork directory """ gitignore_path = deepwork_dir / ".gitignore" - gitignore_content = """# DeepWork temporary files -# These files are used for rules evaluation during sessions + gitignore_content = """# DeepWork runtime artifacts +# These files are generated during sessions and should not be committed .last_work_tree .last_head_ref + +# Temporary files (but keep the directory via .gitkeep) +tmp/* +!tmp/.gitkeep """ - # Only write if it doesn't exist or doesn't contain all entries - if gitignore_path.exists(): - existing_content = gitignore_path.read_text() - if ".last_work_tree" not in existing_content or ".last_head_ref" not in existing_content: - # Overwrite with complete content - gitignore_path.write_text(gitignore_content) - else: - gitignore_path.write_text(gitignore_content) + # Always overwrite to ensure correct content + gitignore_path.write_text(gitignore_content) def _create_tmp_directory(deepwork_dir: Path) -> None: