From 77c9863b50595ff217218c82ddb477a6a321ef06 Mon Sep 17 00:00:00 2001 From: Toshii <94262432+0xToshii@users.noreply.github.com> Date: Thu, 1 May 2025 10:27:37 -0700 Subject: [PATCH] Create .clinerules directory when adding new cline rule in ui and .clinerules is currently a file (#3217) * create clinerules dir * change default * changeset * md --- .changeset/blue-lobsters-sort.md | 5 +++++ .../context/instructions/user-instructions/cline-rules.ts | 7 +++++++ 2 files changed, 12 insertions(+) create mode 100644 .changeset/blue-lobsters-sort.md diff --git a/.changeset/blue-lobsters-sort.md b/.changeset/blue-lobsters-sort.md new file mode 100644 index 00000000..d817bb3a --- /dev/null +++ b/.changeset/blue-lobsters-sort.md @@ -0,0 +1,5 @@ +--- +"claude-dev": minor +--- + +create clinerules folder if its currently a file and creating new rule diff --git a/src/core/context/instructions/user-instructions/cline-rules.ts b/src/core/context/instructions/user-instructions/cline-rules.ts index 8a2118d4..b66a1df9 100644 --- a/src/core/context/instructions/user-instructions/cline-rules.ts +++ b/src/core/context/instructions/user-instructions/cline-rules.ts @@ -221,7 +221,14 @@ export const createRuleFile = async (isGlobal: boolean, filename: string, cwd: s filePath = path.join(globalClineRulesFilePath, filename) } else { const localClineRulesFilePath = path.resolve(cwd, GlobalFileNames.clineRules) + + const hasError = await ensureLocalClinerulesDirExists(cwd) + if (hasError === true) { + return { filePath: null, fileExists: false } + } + await fs.mkdir(localClineRulesFilePath, { recursive: true }) + filePath = path.join(localClineRulesFilePath, filename) }