In recent years, public and private educational systems are making efforts to update their programmes as to integrate computational thinking and computer programming in K-12 grades. Despite the expertise of the academic world in teaching CS, and the vast amount of knowledge and tools available to evaluate programming skills in industry, there are no clear clues on how children do learn CS concepts, or what is the best strategy to develop coding skills in the school, and how to implement it with limited resources (hardware and trained personnel). The reason for these difficulties has to do with the variety of environments in the market, as well as the complexity to perform controlled multicenter experimentation with children that are exposed differently to computer programming (from no contact at all, to gaining skills at home, or in academies). We propose a curriculum to teach the most relevant concepts of CS, ranging from the very basic command execution, to problem-solving with Artificial Intelligence heuristics, covering the whole K-12 school grades. Instead of being based on computational thinking studies, this curriculum is the result of four years of field work, testing the ToolboX Academy programming environment on site, from a direct scrutiny of children interaction with the interface and tasks definition, to a controlled experiment where more than a thousand students became involved, from 30 different centers. The result is a detailed description of how the fundamental concepts of computer programming can be presented to primary-school students in order to reach a high level of coding proficiency, as well as acquiring the AI bases.