Skip to content

Commit bb8969c

Browse files
committed
docs(notes): add working directory importance guide
1 parent 8c89dc9 commit bb8969c

File tree

9 files changed

+121
-8
lines changed

9 files changed

+121
-8
lines changed

_posts/en/2025-01-11-notes-en.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ generated: false
77
translated: false
88
---
99

10-
These 2133 notes are primarily generated by AI chatbots. I used them to summarize key points and will walk through them to enhance my understanding.
10+
These 2134 notes are primarily generated by AI chatbots. I used them to summarize key points and will walk through them to enhance my understanding.
1111

1212
* [Core Essentials of LLM Applications](/notes/2025-09-05-core-llm-essentials-en)
1313
* [Spring Web Application Setup Without Boot](/notes/2025-09-05-spring-webapp-setup-en)
14+
* [Working Directory Importance for Coding Agents](/notes/2025-09-05-working-directory-importance-en)
1415
* [AI Model Context Window Capacities](/notes/2025-09-03-ai-model-context-window-en)
1516
* [Alphabet Hits $186.66B in H1 2025](/notes/2025-09-03-alphabet-h1-2025-revenue-en)
1617
* [Building Trust Takes Time and Consistency](/notes/2025-09-03-building-trust-consistency-en)
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
title: Working Directory Importance for Coding Agents
3+
lang: en
4+
layout: post
5+
audio: false
6+
translated: false
7+
generated: true
8+
image: false
9+
---
10+
11+
Yes — you’ve got the right intuition.
12+
13+
When you’re running **Claude Code**, **Codex**, or similar coding agents, the working directory matters a lot because:
14+
15+
### 1. Context of File Operations
16+
17+
If you run the agent from a parent directory, but your actual code is inside a subdirectory, you’ll constantly need to reference paths like `subdir/foo.py`. That’s extra friction. Running it directly in the subdirectory means relative paths (like `./foo.py`) just work.
18+
19+
### 2. Dependency Resolution
20+
21+
Many projects use `requirements.txt`, `pyproject.toml`, `package.json`, or `pom.xml` that assume the **current working directory** is the project root. If you start from the wrong directory:
22+
23+
* Python/JavaScript may not find dependencies correctly.
24+
* Build tools like Maven/Gradle/NPM may fail.
25+
* Your virtual environment might not activate properly.
26+
27+
### 3. Git & Version Control
28+
29+
Git commands behave differently depending on where you are:
30+
31+
* At project root → works as expected.
32+
* In a submodule or nested dir → may show incomplete history or wrong repo.
33+
34+
### 4. Config & Agents
35+
36+
Claude Code (and Codex, Copilot CLI, etc.) often read:
37+
38+
* `.env` files
39+
* `.gitignore`
40+
* project configs (`.clauderc`, `.editorconfig`, etc.)
41+
42+
If you’re not in the intended project root/subdir, the agent might not pick up the right settings.
43+
44+
---
45+
46+
**Best practice:**
47+
48+
* If the subdirectory is an **independent project** (own `package.json`, `pom.xml`, etc.), run the agent there.
49+
* If it’s just part of a bigger project (like `src/` under one root), run from the **root directory** so configs/dependencies are consistent.
50+
51+
Would you like me to suggest a **workflow setup** where you can seamlessly jump between subprojects without having to `cd` manually every time?

original/2025-01-11-notes-en.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ generated: false
77
translated: false
88
---
99

10-
These 2133 notes are primarily generated by AI chatbots. I used them to summarize key points and will walk through them to enhance my understanding.
10+
These 2134 notes are primarily generated by AI chatbots. I used them to summarize key points and will walk through them to enhance my understanding.
1111

1212
* [Core Essentials of LLM Applications](/notes/2025-09-05-core-llm-essentials-en)
1313
* [Spring Web Application Setup Without Boot](/notes/2025-09-05-spring-webapp-setup-en)
14+
* [Working Directory Importance for Coding Agents](/notes/2025-09-05-working-directory-importance-en)
1415
* [AI Model Context Window Capacities](/notes/2025-09-03-ai-model-context-window-en)
1516
* [Alphabet Hits $186.66B in H1 2025](/notes/2025-09-03-alphabet-h1-2025-revenue-en)
1617
* [Building Trust Takes Time and Consistency](/notes/2025-09-03-building-trust-consistency-en)

playground-server/.claude/settings.local.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"permissions": {
33
"allow": [
4-
"Bash(mvn checkstyle:check:*)"
4+
"Bash(mvn checkstyle:check:*)",
5+
"Bash(mvn compile:*)"
56
],
67
"deny": [],
78
"ask": []

playground-server/pom.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424
<artifactId>spring-web</artifactId>
2525
<version>5.2.2.RELEASE</version>
2626
</dependency>
27+
<dependency>
28+
<groupId>org.springframework</groupId>
29+
<artifactId>spring-webmvc</artifactId>
30+
<version>5.2.2.RELEASE</version>
31+
</dependency>
2732
<dependency>
2833
<groupId>org.springframework</groupId>
2934
<artifactId>spring-core</artifactId>
@@ -167,6 +172,14 @@
167172
</execution>
168173
</executions>
169174
</plugin>
175+
<plugin>
176+
<groupId>org.apache.maven.plugins</groupId>
177+
<artifactId>maven-war-plugin</artifactId>
178+
<version>3.4.0</version>
179+
<configuration>
180+
<failOnMissingWebXml>true</failOnMissingWebXml>
181+
</configuration>
182+
</plugin>
170183
<plugin>
171184
<groupId>org.apache.maven.plugins</groupId>
172185
<artifactId>maven-surefire-plugin</artifactId>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package org.lzw;
2+
3+
import org.springframework.context.annotation.ComponentScan;
4+
import org.springframework.context.annotation.Configuration;
5+
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
6+
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
7+
8+
@Configuration
9+
@EnableWebMvc
10+
@ComponentScan(basePackages = "org.lzw")
11+
public class AppConfig implements WebMvcConfigurer {}

playground-server/src/main/java/org/lzw/Application.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,19 @@
22

33
import org.slf4j.Logger;
44
import org.slf4j.LoggerFactory;
5+
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
56

67
public class Application {
78

89
private static final Logger log = LoggerFactory.getLogger(Application.class);
910

1011
public static void main(String[] args) {
11-
log.info("Application started without Spring Boot");
12+
log.info("Starting Spring Web application...");
13+
14+
// Initialize Spring Application Context
15+
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);
16+
context.registerShutdownHook();
17+
18+
log.info("Spring Web application started successfully");
1219
}
1320
}

playground-server/src/main/java/org/lzw/MainController.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,20 @@
66
import org.slf4j.Logger;
77
import org.slf4j.LoggerFactory;
88
import org.springframework.http.ResponseEntity;
9+
import org.springframework.stereotype.Controller;
910
import org.springframework.web.bind.annotation.CrossOrigin;
10-
import org.springframework.web.bind.annotation.GetMapping;
11+
import org.springframework.web.bind.annotation.RequestMapping;
1112
import org.springframework.web.bind.annotation.RequestParam;
12-
import org.springframework.web.bind.annotation.RestController;
13+
import org.springframework.web.bind.annotation.ResponseBody;
1314

14-
@RestController
15+
@Controller
1516
public class MainController {
1617

1718
private static Logger logger = LoggerFactory.getLogger(MainController.class);
1819

20+
@ResponseBody
1921
@CrossOrigin(origins = "*")
20-
@GetMapping("/bandwidth")
22+
@RequestMapping("/bandwidth")
2123
public ResponseEntity<String> getBandwidth(@RequestParam(value = "i", required = false) String networkInterface) {
2224
try {
2325
String osName = System.getProperty("os.name").toLowerCase();
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
4+
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
5+
version="3.1">
6+
7+
<servlet>
8+
<servlet-name>dispatcher</servlet-name>
9+
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
10+
<init-param>
11+
<param-name>contextClass</param-name>
12+
<param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value>
13+
</init-param>
14+
<init-param>
15+
<param-name>contextConfigLocation</param-name>
16+
<param-value>org.lzw.AppConfig</param-value>
17+
</init-param>
18+
<load-on-startup>1</load-on-startup>
19+
</servlet>
20+
21+
<servlet-mapping>
22+
<servlet-name>dispatcher</servlet-name>
23+
<url-pattern>/</url-pattern>
24+
</servlet-mapping>
25+
26+
</web-app>

0 commit comments

Comments
 (0)