The origin of the ninja is based on the spies and assassins that have existed throughout Japanese history. The title ninja has sometimes been attributed to the semi-legendary 4th century prince Yamato Takeru. In the Kojiki, the young Yamato Takeru disguised himself as a charming maiden, and assassinated two chiefs of the Kumaso people. However, these records take place at a very early stage of Japanese history, and is unlikely to be connected to the shinobi of later accounts.
The first recorded use of espionage was under the employment of Prince Shōtoku in the 6th century. Such tactics were considered unsavory even in early times, when, according to the 10th century Shōmonki, the boy spy Koharumaru was killed for spying against the insurgent Taira no Masakado. Later, the 14th century war chronicle Taiheiki contained many references to shinobi, and credited the destruction of a castle by fire to an unnamed but “highly skilled shinobi”.
However, it was not until the 15th century that spies were specially trained for their purpose. It was around this time that the word shinobi appeared to define and clearly identify ninjas as a secretive group of agents. Evidence for this can be seen in historical documents, which began to refer to stealthy soldiers as shinobi during the Sengoku period. Later manuals regarding espionage are often grounded in Chinese military strategy, quoting works such as The Art of War (Sunzi Bingfa), by Sun Tzu.